更改闪灯x轴判断预制800-1000ms,短时间缓动数据会在800ms内重复进来,1000ms暂时看效果还可以

This commit is contained in:
dianke3yu 2025-07-05 18:13:20 +08:00
parent a69a3cb154
commit 2414c96851

View File

@ -232,7 +232,7 @@ static void shake_set_onoff(unsigned char onoff)
shake_alg_param.shake_threshold_v = 140;
shake_alg_param.stability_threshold_v = 130;
shake_alg_param.shake_check_number = 1;
shake_alg_param.shake_time_limit_ms = 800;
shake_alg_param.shake_time_limit_ms = 1000;
}
void shake_arithmetic_set_parameter(shake_recognition_alg_param_t *shake_alg_p)
@ -313,6 +313,8 @@ void shake_arithmetic_set_parameter(shake_recognition_alg_param_t *shake_alg_p)
signed short prev_x = 0, prev_y = 0, prev_z = 0; // 记录上一次的三轴数据
int first = 0;
uint64_t gsen_last_time = 0;
static void shake_arithmetic_task_handler(void *param)
{
signed short x;//, y, z;
@ -331,14 +333,14 @@ static void shake_arithmetic_task_handler(void *param)
//os_printf("%s: Entering the function.\n", __func__); // 添加进入函数的日志
/* if shake close, so return. */
if (0 == shake_info.onoff) {
os_printf("%s: Shake detection is off, returning.\n", __func__);
return;
}
// if (0 == shake_info.onoff) {
// os_printf("%s: Shake detection is off, returning.\n", __func__);
// return;
// }
uint64_t timestmp = 0;
uint64_t shake_t_l_ms = shake_alg_param.shake_time_limit_ms;
//uint64_t shake_t_l_ms = 800;
for (unsigned int i = 0; i < count; i += 3) {
/* get x,y,z data */
x = data_buf[i+0];
@ -361,9 +363,19 @@ static void shake_arithmetic_task_handler(void *param)
// 判断差值是否超过阈值
if (diff_x > diff_threshold ) {
timestmp = bk_aon_rtc_get_ms();
// os_printf("%s timestmp:%llu gsen_last_time:%llu gsen_last_time + shake_t_l_ms:%llu shake_t_l_ms :%llu\r\n", __func__, timestmp, gsen_last_time, gsen_last_time + shake_t_l_ms,shake_t_l_ms);
// os_printf("%s: Difference exceeds the threshold, checking time condition.\n", __func__); // 添加差值超过阈值的日志
if ((shake_info.last_time + shake_t_l_ms) < timestmp) {
shake_info.last_time = timestmp;
if ((gsen_last_time + shake_t_l_ms) < timestmp) {
// os_printf("limiande %s: timestmp=%llu, last_time=%llu, threshold=%llu shake_t_l_ms= %llu\r\n",
//__func__, timestmp, gsen_last_time, gsen_last_time + shake_t_l_ms,shake_t_l_ms);
gsen_last_time = timestmp;
// os_printf("Current timestmp: %llu\n", timestmp);
//bk_printf("gsen_last_time55555 %llu\r\n", gsen_last_time);
// bk_printf("gsen_last_time55555 %lu timestmp =%lu \r\n",gsen_last_time,timestmp);
rtos_delay_milliseconds(180);//过滤刚语音会闪灯
if(first == 1 && get_binary_data_status() == 1){