优化gsensor超时重启机制
authorpenglei <1624952103@qq.com>
Tue, 29 Oct 2024 09:59:57 +0000 (17:59 +0800)
committerpenglei <1624952103@qq.com>
Tue, 29 Oct 2024 09:59:57 +0000 (17:59 +0800)
优化抬腕亮屏灵敏度
调整佩戴检测红外值
通话使用receiver参数

code/sdk/application/audio/vendor/aw88166/aw88166.c
code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp
code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h
code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h
code/sdk/drivers/peripheral/cywee/service/cywee_service.c
code/sdk/drivers/peripheral/cywee/src/main_dml.c
code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c

index 8a01b71..70b48af 100755 (executable)
@@ -263,8 +263,8 @@ td_s32 audio_aw88166_set_aef_profile(uapi_snd_aef_profile aef_profile)
     /* awinic:set mode "Receiver"/"Music", "aw_params.h" contains id information */
     if (aef_profile == UAPI_SND_AEF_PROFILE_VOIP) {
         /* awinic:set mode "Receiver" */
-        // ret = aw883xx_set_profile_byname(AW_DEV_0, "Receiver");
-        ret = aw883xx_set_profile_byname(AW_DEV_0, "Music"); //所有通路用同一套参数。解决打电话音量小的问题。
+        ret = aw883xx_set_profile_byname(AW_DEV_0, "Receiver");
+        // ret = aw883xx_set_profile_byname(AW_DEV_0, "Music"); //所有通路用同一套参数。解决打电话音量小的问题。
     } else {
         /* awinic:set mode "Music" */
         ret = aw883xx_set_profile_byname(AW_DEV_0, "Music");
index 586048e..74607af 100644 (file)
@@ -358,6 +358,7 @@ extern "C"
 \r
         if (curTime.tm_sec % 3 == 0) {\r
              do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BLE_ADV_CHECK, nullptr, 0);\r
+             do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CHECK_ACC,NULL); //检查gsensor是否停止\r
           }\r
 \r
         if (g_alarmCtrA.state == ALARM_STATUS_RUNNING)\r
index 94baddf..38c05a0 100644 (file)
@@ -578,7 +578,7 @@ void cywee_save_sleep_stat_data(void);
 void cywee_custom_save_sleep_data(void);
 void cywee_custom_save_nap_data(void);
 void cywee_reset_history_daily_data(void);
-
+void cywee_check_acc(void);
 #pragma pack()
 
 
index e686ec3..4f78419 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-03-26 20:29:58
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2024-08-16 15:46:30
+ * @LastEditTime: 2024-10-28 20:02:18
  * @FilePath: /FD230/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h
  * @Description: 
  * 
@@ -95,6 +95,8 @@ extern "C" {
 
 #define CYWEE_SERVICE_CMD_RESTART_ACC 0x35
 
+#define CYWEE_SERVICE_CMD_CHECK_ACC 0x36
+
 errcode_t uapi_cywee_service_init(void);
 void uapi_cywee_service_deinit(void);
 
index 0416eef..d506a65 100644 (file)
@@ -409,6 +409,10 @@ static void cywee_service_check_task(void const *arg)
             case CYWEE_SERVICE_CMD_RESTART_ACC:
                 cywee_restart_acc();
             break;
+
+            case CYWEE_SERVICE_CMD_CHECK_ACC:
+                cywee_check_acc();
+            break;
             default:
                 PRINT("unkonw cmd \r\n");
                 break;
index 3bb51a2..7093d5f 100644 (file)
@@ -120,6 +120,8 @@ static uint8_t ephemeral_flag = 0; //临时数据
 
 static uint8_t wear_status = 0;//佩戴状态
 
+static uint8_t timeout = 0;
+
 #ifdef CYWEE_MAC_ACTIVE
 int cm__hs1__mac_c1_init(void);
 int cm__hs1__deinit(void);
@@ -129,6 +131,17 @@ int cm__hs1__init(void);
 int cm__hs1__deinit(void);
 #endif
 
+void cywee_check_acc(void)
+{
+    if(!timeout)
+    {
+        cywee_restart_acc();
+    }
+    else
+    {
+        timeout = 0;
+    }
+}
 
 void clean_sleep_data(void)
 {
@@ -354,6 +367,9 @@ void cywee_set_sleep_stat_data(cywee_inactivity_result_t c_inactivity_result_t)
         }
         else if(sleep_stat[stat_num].stat == 4)
         {
+            //目前cywee出睡时间戳有bug 暂时先用系统时间戳
+            uapi_get_timestampe_ss(&timestamp);
+            sleep_stat[stat_num].timestamp = timestamp;
             wake_up_timestamp = sleep_stat[stat_num].timestamp;
             sleep_update_timestamp = wake_up_timestamp;
         }
@@ -394,6 +410,9 @@ void cywee_log_switch(int cmd)
 
 void cywee_restart_acc(void)
 {
+    uint32_t tm = 0;
+    uapi_get_timestampe_ss(&tm);
+    CWM_OS_dbgPrintf("cywee_restart_acc :  %d \n",tm);
     memset(&scl, 0, sizeof(scl));
     scl.iData[0] = 1;
     scl.iData[1] = 1;
@@ -1015,7 +1034,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
     cywee_inactivity_result_t c_inactivity_result_t;
     cywee_inactivity_accumulate_time_t c_inactivity_accumulate_time_t;
     cywee_activity_result_extre_info_t c_activity_result_extre_info_t;
-
+    uint32_t tm = 0;
     switch (sensorEVT->sensorType) {
         case IDX_ACCEL:
         gxyz_t.x = sensorEVT->fData[0];
@@ -1319,7 +1338,8 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
 
             }else if((int)sensorEVT->fData[0] == 102)
             {
-                CWM_OS_dbgPrintf("ar alert type : %d\n",(int)sensorEVT->fData[1]);
+                uapi_get_timestampe_ss(&tm);
+                CWM_OS_dbgPrintf("ar alert type : %d  tm :%d \n",(int)sensorEVT->fData[1],tm);
                 int ar_alert_type = (int)sensorEVT->fData[1];
                 CustomEventPublish(TOPIC_EVENT_AR_ALERT_TYPE_UPDATE,&ar_alert_type,sizeof(int)); 
                 
@@ -1718,10 +1738,10 @@ int cywee_main_dml(void)
     //设置抬腕功能
     memset(&scl, 0, sizeof(scl));
     scl.iData[0] = 1;
-    // scl.iData[1] = 5;
-    // scl.iData[2] = 5;
-    // scl.iData[3] = 5;
-    // scl.iData[4] = 5;
+    scl.iData[1] = 6;
+    scl.iData[2] = 5;
+    scl.iData[3] = 5;
+    scl.iData[4] = 4;
     CWM_SettingControl(SCL_HAND_UPDOWN_CONFIG, &scl);
 
     //配置跑步机模式相关参数(进入跑步机模式自动生效)
@@ -1826,6 +1846,7 @@ int cwm_lib_process(void)   //运行算法
 
 void cywee_int_handler(void)
 {
+    timeout = 1;
     // if(cywee_switch == 1)
     {
 #ifdef AP_ENABLE_DML_SDO_LISTEN
index 152079c..a15c054 100644 (file)
@@ -117,8 +117,8 @@ const int32_t  spo2_ir_unwear_thres = 8000;     //demo143b  25000   30000
 const int32_t  spo2_ir_wear_thres = 10000;\r
 const uint8_t  spo2_ir_wear_offset = 15;\r
 //CHECK_WEAR_MODE_THRES\r
-const int32_t  check_mode_unwear_thre = 8000;\r
-const int32_t  check_mode_wear_thre = 10000;\r
+const int32_t  check_mode_unwear_thre = 25000;\r
+const int32_t  check_mode_wear_thre = 30000;\r
 \r
 \r
 uint8_t alg_ram[11 * 1024] __attribute__((aligned(4)));\r
@@ -131,7 +131,7 @@ static int cywee_wear_status = 0;
 \r
 static uint8_t hx3695_chip_id = 0;\r
 \r
-static int timeout = 0;\r
+// static int timeout = 0;\r
 \r
 //////// spo2 para and switches\r
 const  uint8_t   COUNT_BLOCK_NUM = 25;            //delay the block of some single good signal after a series of bad signal\r
@@ -2755,7 +2755,7 @@ hrs_sensor_data_t   hrs_s_dat;
 \r
 static uint8_t his_wear = 2;\r
 static uint8_t wear_cnt = 0;\r
-static uint8_t acc_restart_flag = 0;\r
+// static uint8_t acc_restart_flag = 0;\r
 \r
 void hx3695_hrs_ppg_Int_handle(void)\r
 {\r
@@ -2836,20 +2836,20 @@ void hx3695_hrs_ppg_Int_handle(void)
 \r
     for(ii=0; ii<*count; ii++)\r
     {\r
-      if(gsensordata[ii].x == 0.0f && gsensordata[ii].y == 0.0f && gsensordata[ii].z == 0.0f)\r
-      {\r
-          timeout++;\r
-          if(timeout > 20 && !acc_restart_flag) //避免重复开关gsensor\r
-          {\r
-              do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESTART_ACC,NULL);\r
-              acc_restart_flag = 1;\r
-          }\r
-      }\r
-      else\r
-      {\r
-          timeout = 0;\r
-          acc_restart_flag = 0;\r
-      }\r
+      // if(gsensordata[ii].x == 0.0f && gsensordata[ii].y == 0.0f && gsensordata[ii].z == 0.0f)\r
+      // {\r
+      //     timeout++;\r
+      //     if(timeout > 20 && !acc_restart_flag) //避免重复开关gsensor\r
+      //     {\r
+      //         do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESTART_ACC,NULL);\r
+      //         acc_restart_flag = 1;\r
+      //     }\r
+      // }\r
+      // else\r
+      // {\r
+      //     timeout = 0;\r
+      //     acc_restart_flag = 0;\r
+      // }\r
       if(ii == 8)\r
       {\r
           gsen_fifo_x_send[ii] = gsen_fifo_x_send[ii - 1];\r