From: p15692025051 <846603105@qq.com> Date: Fri, 22 Dec 2023 07:36:21 +0000 (+0800) Subject: 跌倒报警算法修改 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=c90f415458fa4b6f4f822fd4aff99783b150a6a4;p=mirrors%2FASR3603_Z5.git 跌倒报警算法修改 --- diff --git a/2.sdk/sdk/gui/lv_drivers/indev/my_xMotion.c b/2.sdk/sdk/gui/lv_drivers/indev/my_xMotion.c index 7d7e3220..a7364118 100644 --- a/2.sdk/sdk/gui/lv_drivers/indev/my_xMotion.c +++ b/2.sdk/sdk/gui/lv_drivers/indev/my_xMotion.c @@ -298,6 +298,47 @@ short Gsensor_x[32]; short Gsensor_y[32]; short Gsensor_z[32]; int Gsensor_xyz_len = 0; +#define FALL_DETECH_LOW_THRESHOLD 45 +#define FALL_COUNTER_THRESHOLD 5 +typedef struct +{ + float x; + float y; + float z; +}acc_g_data_t; +static uint16_t fall_counter = 0; +uint8_t gsensor_sc7a20_fall_detect(acc_g_data_t * acc) +{ + double acc_square = (double)((acc->x) * (acc->x)) + (double)((acc->y) * (acc->y)) + (double)((acc->z) * (acc->z)); + + // if(MMIApi_IsOpenGsensorTestWin()) + // { + // memcpy(&s_sc7a20_test_info, acc, sizeof(acc_g_data_t)); + // } + + if(acc_square < FALL_DETECH_LOW_THRESHOLD ) + { + fall_counter++; + } + else + { + fall_counter = 0; + } + + if(fall_counter >= FALL_COUNTER_THRESHOLD) + { + fall_counter = 0; + + // #if defined(GPS_CHIP_AT6558R_DEBUG) && !defined(ZMAEE_APP) + // // if(get_motion_status() == 1)//有运动才发跌倒报警 + // // _Gps_SendMessagetoClient(GPS_SOCKET_FALL_DOWN, 0); + // #endif + + return 1; + } + + return 0; +} #if USE_HX3918 extern void hx3918_set_gsen_fifo(short *x,short *y,short *z, int count); #endif @@ -305,6 +346,7 @@ static void My_Motion_Main(VOID * argv) { uint16_t MsgId; lv_driver_msg_xmotion_t * pOsMsg; + acc_g_data_t s_acc = {0}; #if XMOTION_TIMER_DEBUG UINT32 T1, T2; #endif @@ -338,6 +380,14 @@ static void My_Motion_Main(VOID * argv) gpio_enable_edge_detect(my_xm_info.irq_pin, EDGE_FLAG_FALL); #endif Gsensor_xyz_len = xMotion_FIFO_Read_XYZ(Gsensor_x,Gsensor_y,Gsensor_z); + for(int i = 0;i< Gsensor_xyz_len;i++) + { + s_acc.x= Gsensor_x[i]; + s_acc.y= Gsensor_y[i]; + s_acc.z= Gsensor_z[i]; + if(gsensor_sc7a20_fall_detect(&s_acc) == 1)//跌倒报警 + mmi_gsensor_sensor_fall_alarm(); + } #if USE_HX3918 hx3918_set_gsen_fifo(Gsensor_x,Gsensor_y,Gsensor_z,Gsensor_xyz_len); #endif