优化睡眠模式时间戳计算,不使用心率数据输入睡眠算法。
authorpenglei <1624952103@qq.com>
Wed, 21 Aug 2024 03:12:28 +0000 (11:12 +0800)
committerpenglei <1624952103@qq.com>
Wed, 21 Aug 2024 03:12:28 +0000 (11:12 +0800)
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/drivers/peripheral/cywee/src/main_dml.c
code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c
code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h
code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c

index a36b74a..3fec2b4 100644 (file)
@@ -1204,21 +1204,37 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req)
         //睡眠
         case INACTIVITY_MODE_SLEEPING_OUTPUT:
 #ifdef FD230
+            // if(state_num < 20)
+            // {
+            //     sleep_data.sleep_status[state_num].timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
+            //     sleep_data.sleep_status[state_num].stat = cywee_Inactivity_Info->status;
+            //     state_num ++;
+            // }
+            // if(cywee_Inactivity_Info->status == 0) //0进入睡眠  1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡
+            // {
+            //     sleep_data.fall_asleep_timestamp = day_timestamp +  cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
+            //     fall_asleep_state_num = state_num;
+            // }
+            // else if(cywee_Inactivity_Info->status == 4)
+            // {
+            //     sleep_data.wake_up_timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
+            // }
             if(state_num < 20)
             {
                 sleep_data.sleep_status[state_num].timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
                 sleep_data.sleep_status[state_num].stat = cywee_Inactivity_Info->status;
-                fall_asleep_state_num = state_num;
+                
+                if(sleep_data.sleep_status[state_num].stat == 0) //0进入睡眠  1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡
+                {
+                    sleep_data.fall_asleep_timestamp = sleep_data.sleep_status[state_num].timestamp;
+                    fall_asleep_state_num = state_num;
+                }
+                else if(sleep_data.sleep_status[state_num].stat == 4)
+                {
+                    sleep_data.wake_up_timestamp = sleep_data.sleep_status[state_num].timestamp;
+                }
                 state_num ++;
             }
-            if(cywee_Inactivity_Info->status == 0) //0进入睡眠  1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡
-            {
-                sleep_data.fall_asleep_timestamp = day_timestamp +  cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
-            }
-            else if(cywee_Inactivity_Info->status == 4)
-            {
-                sleep_data.wake_up_timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60;
-            }
 #endif
             break;
 
index 6059fc2..f8d173e 100644 (file)
@@ -514,7 +514,7 @@ void cywee_inactivity_mode_change(int mode)
             //设置睡眠
             memset(&scl, 0, sizeof(scl));
             scl.iData[0] = 1;
-            scl.iData[2] = 1; // 0.不使用心率 1.使用心率 (暂时关闭,不使用心率数据输入算法)
+            scl.iData[2] = 0; // 0.不使用心率 1.使用心率 (暂时关闭,不使用心率数据输入算法)
             CWM_SettingControl(SCL_SLEEP_CONFIG, &scl);
 
             memset(&scl, 0, sizeof(scl));
index fb706a5..ef80e51 100644 (file)
@@ -2727,7 +2727,7 @@ static void get_avg_hrs(int32_t hrs)
 }\r
 \r
 \r
-void hx3695_hrs_wearstatus_update(void)\r
+void hx3695_wearstatus_update(void)\r
 {\r
     if(wear_status != hrsresult.wearstatus)\r
     {\r
@@ -2735,11 +2735,6 @@ void hx3695_hrs_wearstatus_update(void)
         cywee_data = wear_status;\r
         do_cywee_service_check_msg(CYWEE_SERVICE_CMD_WEAR_STATUS_CHANGE,&cywee_data);\r
     }\r
-    if(wear_status)\r
-      cywee_data = hrsresult.lastesthrs;\r
-    else\r
-      cywee_data = 0;\r
-    do_cywee_service_check_msg(CYWEE_SERVICE_CMD_HRS_CHANGE,&cywee_data);\r
 }\r
 \r
 #ifdef HRS_ALG_LIB\r
index bf2d8d5..d167171 100644 (file)
@@ -297,7 +297,7 @@ void agc_timeout_handler(void * p_context);
 void heart_rate_meas_timeout_handler(void * p_context);\r
 void wear_mode_timeout_handler(void * p_context);\r
 void Efuse_Mode_Check(void);\r
-void hx3695_hrs_wearstatus_update(void);\r
+void hx3695_wearstatus_update(void);\r
 #include "hx3695_hal.h"\r
 \r
 #endif\r
index b0d032c..1d16900 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-03-13 15:08:38
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2024-08-17 11:11:47
+ * @LastEditTime: 2024-08-21 11:07:20
  * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c
  * @Description: 
  * 
@@ -76,7 +76,7 @@ void ppg_send_cmd_to_driver(char* mode, uint8_t enable)
         {
 #ifdef HRS_ALG_LIB   
             hx3695_hrs_disable();
-            hx3695_hrs_wearstatus_update();
+            hx3695_wearstatus_update();
 #endif
         }else  if(md == HRV_MODE)
         {