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
}
运行结果:

推论:
- 项目是显示音频曲线 100ms 接收 60个点,也就是 1s 接收 600个点。 handletickevent 至少执行十次。
- 需要保证不卡顿需要让 handletickevent 执行频率为 25Hz , 即使每2次执行绘制一帧,每次进行抽点显示(60个点抽20个点显示,一次显示10个点)。在音频曲线变化较大的时候,会出现卡顿(实测降至 2 Hz),严重影响显示效果。
参考文档:Touchgfx 动态图表绘制原理
根据其他帖子的回复,因为线模式需要计算,所以比较慢。直方图的方式知道底部会更快,但对于波形使用直方图没有意义,需要探索其他方法。

1031

被折叠的 条评论
为什么被折叠?



