跌倒报警优化
authorp15692025051 <846603105@qq.com>
Fri, 22 Dec 2023 09:16:40 +0000 (17:16 +0800)
committerp15692025051 <846603105@qq.com>
Fri, 22 Dec 2023 09:16:40 +0000 (17:16 +0800)
2.sdk/sdk/gui/lv_drivers/indev/my_xMotion.c

index a736411..9ec4cee 100644 (file)
@@ -272,6 +272,7 @@ static void xmotion_timer_callback(uint32_t val)
         my_xmotion_sleep_suspend();
         xmotion_send_message(XMOTION_MSG_PROCESS_DATA,0);
     }
+    //cplog_printf("xmotion_timer_callback:!!!!!!\n");
 }
 #if (USE_POLLING_MODE == POLLING_MODE_INT)
 static void xmotion_hisr_callback(void)
@@ -298,6 +299,9 @@ short Gsensor_x[32];
 short Gsensor_y[32];
 short Gsensor_z[32];
 int Gsensor_xyz_len = 0;
+#define ACC_0G_X      8192 //4096
+#define ACC_0G_Y      8192   
+#define ACC_0G_Z      8192       
 #define  FALL_DETECH_LOW_THRESHOLD 45
 #define FALL_COUNTER_THRESHOLD 5
 typedef struct
@@ -380,11 +384,15 @@ 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);
+            //cplog_printf("xMotion_FIFO_Read_XYZ:Gsensor_xyz_len%d\n",Gsensor_xyz_len);
             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];
+                // s_acc.x= Gsensor_x[i];
+                // s_acc.y= Gsensor_y[i];
+                // s_acc.z= Gsensor_z[i];
+                s_acc.x = (float)((Gsensor_x[i]*9.8f)/((uint16_t)ACC_0G_X));
+                s_acc.y = (float)((Gsensor_y[i]*9.8f)/((uint16_t)ACC_0G_Y));
+                s_acc.z = (float)((Gsensor_z[i]*9.8f)/((uint16_t)ACC_0G_Z));
                 if(gsensor_sc7a20_fall_detect(&s_acc) == 1)//跌倒报警
                                    mmi_gsensor_sensor_fall_alarm();    
             }
@@ -721,7 +729,7 @@ int xMotion_my_init()
     mfp_config((uint32_t *)my_xm_mfp_cfgs);
     //xMotion Init
     ret = xMotion_Init(&ops_handle);
-    printf("xMotion_Init ret =%d\n",ret);
+    //cplog_printf("xMotion_Init ret =%d\n",ret);
 
        if(ret){
        printf("xMotion init fail\n");
@@ -760,6 +768,7 @@ int xMotion_my_init()
         uos_timer_create(&pptimer);
         uos_timer_start(pptimer, XMOTION_TIME, XMOTION_TIME, xmotion_timer_callback, NULL);
         xmotion_timer_start_flag = true;
+        //cplog_printf("uos_timer_start(pptimer, XMOTION_TIME, XMOTION_TIME, xmotion_timer_callback, NULL);\n");
     }
 #endif