[QNX]绘制一个正弦波

    xiaoxiao2021-12-14  19

    /********************************************************************* * Author : lile * Modified : 2019年12月28日星期六 10:56:13 * Email : roger0212@163.com * HomePage : lile777.blog.csdn.net * CopyRight : 该文章版权由lile所有。 * 保留原文出处链接和本声明的前提下,可在非商业目的下任意传播和复制。 * 对于商业目的下对本文的任何行为需经作者同意。 *********************************************************************/

    目录

    效果图实现代码

    效果图

    实现代码

    #define N_SAMPLE 100 // 波长最大值 #define AMP_MAX 50 // 振幅最大值 /* * amplitude —— 振幅 * wavelength —— 波长 */ int sin_wave(int amplitude, int wavelength) { int i = 0; int value_array[N_SAMPLE] = { 0 }; if (wavelength > N_SAMPLE) wavelength = N_SAMPLE; if (amplitude > AMP_MAX) amplitude = AMP_MAX; for (i = 0; i < N_SAMPLE; i++) { value_array[i] = (int) amplitude * sin((atan(1) * 8 * (i % wavelength)) / wavelength) + AMP_MAX; } PtMTrendAddData(ABW_PtMTrend_data, 0, value_array, N_SAMPLE ); return 0; } int mtrend_init(void) { PtMTrendAttr_t graph1_attr = { Pt_MTREND_STATE_SHOWN, Pg_RED, 3, Pg_MITER_JOIN, 0, AMP_MAX*2, NULL, { 0, 0, 0, 0 } }; PtArg_t args[4]; int i = 0; PtSetArg( &args[i++], Pt_ARG_MTREND_N_GRAPHS, 1, 0 ); PtSetArg( &args[i++], Pt_ARG_MTREND_N_SAMPLES, N_SAMPLE, 0 ); PtSetArg( &args[i++], Pt_ARG_MTREND_FLAGS, Pt_TRUE, Pt_MTREND_BLIT ); PtSetArg( &args[i++], Pt_ARG_MTREND_GRAPH_ATTR, &graph1_attr, 0 ); PtSetResources(ABW_PtMTrend_data, 4, args); }
    转载请注明原文地址: https://ju.6miu.com/read-963594.html

    最新回复(0)