优化误判小睡情况 2904/target/2 2906/1 2906/head
authorpenglei <1624952103@qq.com>
Wed, 10 Dec 2025 08:10:20 +0000 (16:10 +0800)
committerpenglei <1624952103@qq.com>
Wed, 10 Dec 2025 08:10:20 +0000 (16:10 +0800)
code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c

index 8df6b1c..e20c5c5 100644 (file)
@@ -77,6 +77,8 @@ static uint8_t is_free_trainning_mode = 0;
 
 static uint8_t acc_check_cnt = 0;
 
+static uint8_t abs_solute_time = 90;
+
 /**
  * @brief 更新燃脂时间
  * @param current_mhr_zone 当前心率区间 (2表示燃脂区间)
@@ -798,13 +800,15 @@ void cywee_custom_save_wear_data(void)
 }
 
 
-
-static void cywee_set_abs_static(void)
+//param:分钟
+static void cywee_set_abs_static(int min)
 {
     //int time = get_config_heart_from_config_model();
+    abs_solute_time = min;
+    // printf("abs_solute_time : %d\n",abs_solute_time);
     memset(&scl, 0, sizeof(scl));
     scl.iData[0] = 1;
-    scl.iData[1] = 90 * 60;
+    scl.iData[1] = abs_solute_time * 60;
     CWM_SettingControl(SCL_ABS_STATIC_CONFIG, &scl);
 }
 
@@ -1123,6 +1127,26 @@ void cywee_oncharging_update(int oncharging_status)
 void cywee_wearstatus_update(int wearstatus)
 {
 #if 1
+    if(wearstatus == 2)
+    {
+        if(uapi_dev_runtime_get_nap_monitoring_status())
+        {
+            if(uapi_dev_runtime_get_nap_status())
+            {
+                uapi_dev_runtime_set_absolute_static_status(1);
+                cywee_get_sleep_data(1);
+            }
+            else
+            {
+                cywee_inactivity_mode_change(INACTIVITY_MODE_NOTHING);
+                cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY_AND_NAP);
+            }
+        }
+
+        wearstatus = 0;
+    }
+
+
     uapi_dev_runtime_set_wear_status(wearstatus);
     memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT));
     csd.sensorType = CUSTOM_OFFBODY_DETECT;
@@ -1205,6 +1229,8 @@ void cywee_inactivity_mode_change(int mode)
             CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
             uapi_dev_runtime_set_sleep_monitoring_status(1);
             uapi_dev_runtime_set_nap_monitoring_status(0);
+
+            cywee_set_abs_static(90); //设置睡眠 绝对禁止判断为90min
             break;
 
         //久坐、有效站立和小睡
@@ -1216,6 +1242,8 @@ void cywee_inactivity_mode_change(int mode)
             CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
             uapi_dev_runtime_set_sleep_monitoring_status(0);
             uapi_dev_runtime_set_nap_monitoring_status(1);
+
+            cywee_set_abs_static(30); //设置小睡 绝对禁止佩戴为30min
             break;
 
         //小睡
@@ -1764,10 +1792,26 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
                 else
                 {
                     cywee_inactivity_mode_change(INACTIVITY_MODE_NOTHING);
-                    LOS_Msleep(50);
                     cywee_inactivity_mode_change(INACTIVITY_MODE_SLEEPING);
                 }
             }
+            else if(uapi_dev_runtime_get_nap_status())
+            {
+                // uapi_get_timestampe_ss(&abs_static_timestampe);
+                // if((abs_static_timestampe - asleep_timestampe) >= 60 * 90)
+                // {
+                    // sleep_flag_t.stat = 15;
+                    // sleep_flag_t.timestamp = abs_static_timestampe;
+                    // uapi_save_sleep_flag(&sleep_flag_t,sizeof(SLEEP_FLAG_T));
+                    uapi_dev_runtime_set_absolute_static_status(1);
+                    cywee_get_sleep_data(1);
+                // }  
+                // else
+                // {
+                    cywee_inactivity_mode_change(INACTIVITY_MODE_NOTHING);
+                    cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY_AND_NAP);
+                // }
+            }
 
             break;
         case IDX_ALGO_SPV:
@@ -2148,7 +2192,7 @@ int cywee_start(void)
     cywee_ar_alert_switch(get_motion_recognition_from_config_model());
 
     //设置绝对静止
-    cywee_set_abs_static();
+    cywee_set_abs_static(90);
 
     //呼叫任一個CWM_Sensor_Enable 前呼叫此指令 设置手动或自动模式
     memset(&scl, 0, sizeof(scl));