优化动态心率 98/1 98/head 99/target/1
authorpenglei <1624952103@qq.com>
Sat, 27 Apr 2024 06:53:32 +0000 (14:53 +0800)
committerpenglei <1624952103@qq.com>
Sat, 27 Apr 2024 06:53:32 +0000 (14:53 +0800)
code/sdk/drivers/peripheral/cywee/src/main_dml.c
code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c
code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp

index 793de1b..57509ea 100644 (file)
 
 #define AP_ENABLE_DML_SDO_LISTEN
 
-#define GSENSON_MSG_COUNT   8
+#define GSENSON_MSG_COUNT   25
 
 static gsenson_t gxyz_t;
 static uint8_t gsenson_falg=0;
 
 static uint16 num_falg=0;
-static gsenson_t gxyz_t_queue[8]={0};
+static gsenson_t gxyz_t_queue[25]={0};
 static int16 left_falg=0;
 static int16 right_falg=-1;
 
@@ -279,7 +279,7 @@ void gsensor_get_n_data(uint8_t cnt,gsenson_t t[])
         //     CWM_OS_dbgPrintf("get_gsonsen_xyz_fail\n");
         //     return;
         // }
-        //CWM_OS_dbgPrintf("x : %d , y : %d , z : %d\n", gxyz_t_queue[left_falg].x, gxyz_t_queue[left_falg].y, gxyz_t_queue[left_falg].z);
+        CWM_OS_dbgPrintf("x=%.3f, y=%.3f, z=%.3f\n", gxyz_t_queue[left_falg].x, gxyz_t_queue[left_falg].y, gxyz_t_queue[left_falg].z);
         t[i].x= gxyz_t_queue[left_falg].x;
         t[i].y= gxyz_t_queue[left_falg].y;
         t[i].z= gxyz_t_queue[left_falg].z;
@@ -287,7 +287,7 @@ void gsensor_get_n_data(uint8_t cnt,gsenson_t t[])
         if(num_falg)
         {
             left_falg++;
-            left_falg=left_falg%8;
+            left_falg=left_falg%25;
             num_falg--;
 
         }   
@@ -308,12 +308,12 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
             //                                            sensorEVT->fData[1],
             //                                            sensorEVT->fData[2]
             //                                             );
-            if(num_falg==8)
+            if(num_falg==25)
             {
                 left_falg++;
                 right_falg++;
-                right_falg=right_falg%8;
-                left_falg=left_falg%8;
+                right_falg=right_falg%25;
+                left_falg=left_falg%25;
                 gxyz_t_queue[right_falg].x= sensorEVT->fData[0];
                 gxyz_t_queue[right_falg].y= sensorEVT->fData[1];
                 gxyz_t_queue[right_falg].z= sensorEVT->fData[2];
@@ -322,7 +322,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
             {
                 //left_falg++;
                 right_falg++;
-                right_falg=right_falg%8;
+                right_falg=right_falg%25;
                 //left_falg=left_falg%16;
                 num_falg++;
                 gxyz_t_queue[right_falg].x= sensorEVT->fData[0];
@@ -391,12 +391,9 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
             {
                 CWM_OS_dbgPrintf("CUSTOM_OFFBODY_DETECT !!! \r\n");
                 if((int)sensorEVT->fData[2] == 1)
-                {
-                    memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT));
-                    csd.sensorType = CUSTOM_OFFBODY_DETECT;
-                    csd.fData[0] = 1;
-                    CWM_CustomSensorInput(&csd);
-                }    
+                    send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST); 
+                else
+                    send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST); 
             }
             if((int)sensorEVT->fData[1] == CUSTOM_ON_CHARGING)
             {
@@ -845,18 +842,18 @@ int cywee_main_dml(void)
     CWM_SettingControl(SCL_DML_DRV_ENABLE, &scl);
     //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
 
-    memset(&scl, 0, sizeof(scl));
-    scl.iData[0] = 1;
-    scl.iData[3] = 3;
-    scl.iData[4] = 5;
+    // memset(&scl, 0, sizeof(scl));
+    // scl.iData[0] = 1;
+    // scl.iData[3] = 3;
+    // scl.iData[4] = 5;
 
     CWM_Sensor_Enable(IDX_REQUEST_SENSOR);
     // //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
     CWM_Sensor_Enable(IDX_ALGO_WATCH_HANDUP);
     CWM_Sensor_Enable(IDX_ALGO_ACTIVITY_OUTPUT);
-    //CWM_Sensor_Enable(IDX_ALGO_INACTIVITY_OUTPUT);
-    //CWM_Sensor_Enable(IDX_ALGO_SEDENTARY);
-    //CWM_Sensor_Enable(IDX_ALGO_SLEEP);
+    CWM_Sensor_Enable(IDX_ALGO_INACTIVITY_OUTPUT);
+    // CWM_Sensor_Enable(IDX_ALGO_SEDENTARY);
+    // CWM_Sensor_Enable(IDX_ALGO_SLEEP);
     CWM_Sensor_Enable(IDX_ACCEL);
     //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
     // CWM_Sensor_Enable(IDX_GYRO);
@@ -868,9 +865,8 @@ int cywee_main_dml(void)
 
     cyw_activity_mode_change(SPORT_ACTIVE_MODE_NORMAL);
     
-    //cyw_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY);
+    cyw_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY);
 
-    send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST);
     // cyw_activity_mode_change(cmd);
     // if(cmd == SPORT_ACTIVE_MODE_NORMAL)
     // {
index a0b7223..c508439 100644 (file)
@@ -2765,8 +2765,8 @@ void hx3695_hrs_ppg_Int_handle(void)
     if(*count < 10)\r
     {\r
       gsensor_get_n_data(8,gsensordata);\r
-      for(ii=0; ii<*count; ii++)\r
-      {\r
+       for(ii=0; ii<*count; ii++)\r
+       {\r
           if(ii == 8)\r
           {\r
               gsen_fifo_x_send[ii] = gsen_fifo_x_send[ii - 1];\r
@@ -2778,12 +2778,13 @@ void hx3695_hrs_ppg_Int_handle(void)
               // gsen_fifo_x_send[ii] = (gsensordata[ii*2].x + gsensordata[2*ii + 1].x)/2;\r
               // gsen_fifo_y_send[ii] = (gsensordata[ii*2].y + gsensordata[2*ii + 1].y)/2;\r
               // gsen_fifo_z_send[ii] = (gsensordata[ii*2].z + gsensordata[2*ii + 1].z)/2;\r
-              gsen_fifo_x_send[ii] = gsensordata[ii].x;\r
-              gsen_fifo_y_send[ii] = gsensordata[ii].y;\r
-              gsen_fifo_z_send[ii] = gsensordata[ii].z;\r
+              gsen_fifo_x_send[ii] = gsensordata[ii].x * 2048;\r
+              gsen_fifo_y_send[ii] = gsensordata[ii].y * 2048;\r
+              gsen_fifo_z_send[ii] = gsensordata[ii].z * 2048;\r
           }\r
-          PRINT("hxdata:%d/%d %d %d %.2f %.2f %.2f %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii],ppg_s_data.green_cur);\r
-      }\r
+          //PRINT("hxdata:%d/%d %d %d %.3f %.3f %.3f %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii],ppg_s_data.green_cur);\r
+          PRINT("hxdata:%d/%d %d %d %d %d %d %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii],ppg_s_data.green_cur);\r
+       }\r
 \r
       hrs_wear_status = hx3695_hrs_get_wear_status();\r
       PRINT("hrs_wear_status:    %d !!\r\n", hrs_wear_status);\r
@@ -3492,7 +3493,7 @@ void hx3695_wear_ppg_Int_handle(void)
     hx3695_check_touch_read(&ppg_s_data);\r
     hx3695_wear_status = hx3695_check_touch_send_data(ir_buf,*count);\r
     hrsresult.wearstatus = hx3695_wear_status;\r
-    PRINT("hx3695_wear_status : %d \r\n",hx3695_wear_status);\r
+    // PRINT("hx3695_wear_status : %d \r\n",hx3695_wear_status);\r
     if(wear_mode_status != hx3695_wear_status)\r
     {\r
         wear_mode_status = hx3695_wear_status;\r
index c9d5a99..2ce4175 100644 (file)
@@ -57,7 +57,7 @@ uint8_t light_databuf[64] = {0};
 
 
 #define PPG_SERVICE_MSG_COUNT       16
-#define PPG_SERVICE_TASK_SIZE       0x900
+#define PPG_SERVICE_TASK_SIZE       0x1000
 #define PPG_SERVICE_TASK_PRIO       5
 
 #define MAG_CHECK_MS 20