【Touchgfx】DynamicDataGraph 动态图表 绘制性能慢问题

1. 问题复现

性能曲线图

1.模拟每次 handletickevent 添加一个点

#define FLAG_MONITOR_HANDLE_TICK_EVENT_FEQ

int8_t test_tmp_cnt = 0;
uint32_t monitor_1s_index;
uint32_t monitor_begin_time_1ms = 0;
uint32_t monitor_1s_cnt[30];

void main_screenView::handleTickEvent()
{
	test_tmp_cnt++;
#ifdef FLAG_MONITOR_HANDLE_TICK_EVENT_FEQ
	// 获取开始时间
	monitor_start_time[monitor_index_1] = time_cnt_1ms;
	// 重置参数
	if(monitor_begin_time_1ms == 0)
	{
		monitor_1s_cnt[monitor_1s_index] = 0;
		monitor_begin_time_1ms = time_cnt_1ms;
	}
#endif
	// 模拟添加添加点
	audio_dynamicGraph.addDataPoint(test_tmp_cnt);


#ifdef FLAG_MONITOR_HANDLE_TICK_EVENT_FEQ

		// 1s
		if(time_cnt_1ms - monitor_begin_time_1ms > 1000 )
		{
			monitor_begin_time_1ms = 0;
			monitor_1s_index++;
		}
		else
		{
			// 记录执行次数
			monitor_1s_cnt[monitor_1s_index]++;
		}

		// 记录 30 s
		if(monitor_1s_index >= 30)
		{
			monitor_1s_index = 0;
		}

#endif
}

运行结果:
幅值变化较小的时候

2.模拟每次 handletickevent 添加1个点 但反向

#define FLAG_MONITOR_HANDLE_TICK_EVENT_FEQ

int8_t test_tmp_cnt = 0;
uint32_t monitor_1s_index;
uint32_t monitor_begin_time_1ms = 0;
uint32_t monitor_1s_cnt[30];
uint8_t flag_cnt = 0;
void main_screenView::handleTickEvent()
{
	test_tmp_cnt++;
#ifdef FLAG_MONITOR_HANDLE_TICK_EVENT_FEQ
	// 获取开始时间
	monitor_start_time[monitor_index_1] = time_cnt_1ms;
	// 重置参数
	if(monitor_begin_time_1ms == 0)
	{
		monitor_1s_cnt[monitor_1s_index] = 0;
		monitor_begin_time_1ms = time_cnt_1ms;
	}
#endif
	// 模拟添加添加点
	if(flag == 0)
	{
		flag = 1;
		audio_dynamicGraph.addDataPoint(test_tmp_cnt);
	}
	else 
	{
		flag = 0; 
		audio_dynamicGraph.addDataPoint(-test_tmp_cnt);
	}
#ifdef FLAG_MONITOR_HANDLE_TICK_EVENT_FEQ

		// 1s
		if(time_cnt_1ms - monitor_begin_time_1ms > 1000 )
		{
			monitor_begin_time_1ms = 0;
			monitor_1s_index++;
		}
		else
		{
			// 记录执行次数
			monitor_1s_cnt[monitor_1s_index]++;
		}

		// 记录 30 s
		if(monitor_1s_index >= 30)
		{
			monitor_1s_index = 0;
		}

#endif
}

运行结果:
幅值较大时频率
推论:

  1. 项目是显示音频曲线 100ms 接收 60个点,也就是 1s 接收 600个点。 handletickevent 至少执行十次。
  2. 需要保证不卡顿需要让 handletickevent 执行频率为 25Hz , 即使每2次执行绘制一帧,每次进行抽点显示(60个点抽20个点显示,一次显示10个点)。在音频曲线变化较大的时候,会出现卡顿(实测降至 2 Hz),严重影响显示效果。

参考文档:Touchgfx 动态图表绘制原理
根据其他帖子的回复,因为线模式需要计算,所以比较慢。直方图的方式知道底部会更快,但对于波形使用直方图没有意义,需要探索其他方法。
回复

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值