Merge #1536 into sdk602patch0911 from refs/changes/1536/head
author彭磊 <1624952103@qq.com>
Thu, 19 Dec 2024 10:58:06 +0000 (10:58 +0000)
committer袁清梦 <3449750381@qq.com>
Thu, 19 Dec 2024 10:58:06 +0000 (10:58 +0000)
  - 添加功耗记录:电量变化,运动测量心率,马达,佩戴检测; 优化debug界面电量信息显示

code/sdk/application/battery/service/battery_driver.cpp
code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp
code/sdk/drivers/peripheral/cywee/src/main_dml.c
code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp
code/sdk/drivers/peripheral/rotary_encoder/hx3507/hx3507.c
code/sdk/drivers/peripheral/utils/custom_save_runtime.h
code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp

index 8b64247..7125b66 100644 (file)
@@ -70,6 +70,7 @@ typedef enum {
 #include "debug_print.h"
 #include "custom_utils.h"
 #include <math.h>
+#include "custom_save_runtime.h"
 
 #define HAL_ADC_SAMPLE_NUMBER_CONFIG_0 10  /* Channel with buffer manual sample average number. */
 #define HAL_ADC_SAMPLE_NUMBER_CONFIG_1 10  /* Channel without buffer manual sample average number. */
@@ -445,6 +446,7 @@ static int battery_get_percent_by_voltage(float voltage)
                 // else if(percent > history_percent && history_percent && abs(history_percent - percent) < 10)
                 else if(percent > history_percent && history_percent)
                 {
+                    uapi_save_runtime_log(RUNTIME_LOG_BATTERY_MIN_UP);
                     // PRINT("2222 charge percent[%d], history_percent[%d] \n",percent,history_percent);
                     history_percent++;
                     percent = history_percent;
@@ -466,6 +468,7 @@ static int battery_get_percent_by_voltage(float voltage)
                 // else if(history_percent > percent && abs(history_percent - percent) < 10)
                 else if(history_percent > percent)
                 {
+                    uapi_save_runtime_log(RUNTIME_LOG_BATTERY_MIN_DOWN);
                     // PRINT("2222 uncharge percent[%d], history_percent[%d] \n",percent,history_percent);
                     history_percent--;
                     percent = history_percent;
@@ -492,6 +495,7 @@ static int battery_get_percent_by_voltage(float voltage)
     {
         if(get_charge_stat() && history_percent < 100 && history_percent) //充电中则均匀增加
         {
+            uapi_save_runtime_log(RUNTIME_LOG_BATTERY_MIN_UP);
             history_percent++;
             percent = history_percent;
         }
index d1ce828..81bee57 100644 (file)
@@ -500,32 +500,66 @@ namespace OHOS
 
         if(get_battery_percent_flag == 1)
         {
-            if(len >= 120)
+            if(len >= 60)
+            {
+                index = 30;
+                len = 60;
+            }
+            else if(len >= 30 && len < 60)
+                index = 30;
+            else
+                return result;
+        }
+        else if(get_battery_percent_flag == 2)
+        {
+            if(len >= 90)
             {
                 index = 60;
-                len = 120;
+                len = 90;
             }
-            else if(len >= 60 && len < 120)
+            else if(len >= 60 && len < 90)
                 index = 60;
             else
                 return result;
+        }else if(get_battery_percent_flag == 3)
+        {
+            if(len >= 120)
+            {
+                index = 90;
+                len = 120;
+            }
+            else if(len >= 90 && len < 120)
+                index = 90;
+            else
+                return result;
+        }else if(get_battery_percent_flag == 4)
+        {
+            if(len >= 150)
+            {
+                index = 120;
+                len = 150;
+            }
+            else if(len >= 120 && len < 150)
+                index = 120;
+            else
+                return result;
         }
-        else if(get_battery_percent_flag == 2)
+        else if(get_battery_percent_flag == 5)
         {
             if(len >= 180)
             {
-                index = 120;
+                index = 150;
                 len = 180;
             }
-            else if(len >= 120 && len < 180)
-                index = 120;
+            else if(len >= 150 && len < 180)
+                index = 150;
             else
                 return result;
         }
         else
         {
-            if(len >= 60)
-                len = 60;
+            if(len >= 30)
+                len = 30;
         }
         for(int i = index; i < len; i++)
         {
@@ -542,7 +576,7 @@ namespace OHOS
             } 
 
             std::ostringstream oss;
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "data[%d].voltage : %f , data[%d].percent : %d",i,data[i].voltage,i,data[i].percent);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data[%d].voltage : %f , data[%d].percent : %d",i,data[i].voltage,i,data[i].percent);
 
             if(data[i].stat)
                 // charge_stat = static_cast<int>(i) + ":充电中";
@@ -855,9 +889,24 @@ namespace OHOS
             }
             else if(get_battery_percent_flag == 2)
             {
-                nextorprepageLabelButton->SetText("第一页");
+                nextorprepageLabelButton->SetText("第四页");
                 get_battery_percent_flag = 3;
             }
+            else if(get_battery_percent_flag == 3)
+            {
+                nextorprepageLabelButton->SetText("第五页");
+                get_battery_percent_flag = 4;
+            }
+            else if(get_battery_percent_flag == 4)
+            {
+                nextorprepageLabelButton->SetText("第六页");
+                get_battery_percent_flag = 5;
+            }
+            else if(get_battery_percent_flag == 5)
+            {
+                nextorprepageLabelButton->SetText("第一页");
+                get_battery_percent_flag = 6;
+            }
             else
             {
                 nextorprepageLabelButton->SetText("第二页");
index a6e9e03..693826b 100644 (file)
@@ -19,6 +19,7 @@
 #include "ConfigModelC.h"
 #include "battery_hal.h"
 #include "sleep/include/SleepModelC.h"
+#include "custom_save_runtime.h"
 
 #define AP_ENABLE_DML_SDO_LISTEN
 
@@ -36,6 +37,7 @@
 
 #define WEAR_FILE_COUNT 50
 
+
 static gsenson_t gxyz_t;
 static uint8_t gsenson_falg=0;
 
@@ -885,11 +887,13 @@ void activity_mode_setstatus(int cmd)
     {
         send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_TEST);
         hrs_mode_state = 1;
+        uapi_save_runtime_log(RUNTIME_LOG_HEART_SPORT_MEASURE);
     }
     else
     {
         send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST);
         hrs_mode_state = 0;
+        uapi_save_runtime_log(RUNTIME_LOG_OXYGEN_SPORT_MEASURE_END);
     }
 }
 
@@ -1148,13 +1152,15 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
             {   
                 // CWM_OS_dbgPrintf("[cwyee] turn_off_screen \n");
                 mmi_screen_on_off_by_flip_wrist(false);
+                uapi_save_runtime_log(RUNTIME_LOG_RAISE_MIN_DOWN);
             }
             #endif
             }else if ((int)sensorEVT->fData[1] == 1)
             {
             #if defined(SUPPORT_POWER_MANAGER)
                 // CWM_OS_dbgPrintf("[cwyee] turn_on_screen \n");
-                mmi_screen_on_off_by_flip_wrist(true);  
+                mmi_screen_on_off_by_flip_wrist(true);
+                uapi_save_runtime_log(RUNTIME_LOG_RAISE_MIN_UP);  
             #endif
             }
             break;
@@ -1191,12 +1197,14 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
                 {
                     send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_TEST);
                     hrs_mode_state = 1;
+                    uapi_save_runtime_log(RUNTIME_LOG_HEART_SPORT_MEASURE);
                     // hrs = 0;//运动开始,清零心率
                 }
                 else
                 {
                     send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST);
                     hrs_mode_state = 0;
+                    uapi_save_runtime_log(RUNTIME_LOG_OXYGEN_SPORT_MEASURE_END);
                 }
             }
              break;
index 0e4634f..2c801e8 100644 (file)
@@ -48,6 +48,7 @@ extern "C" {
 #include "cywee_hal.h"
 #include "cywee_service.h"
 #include "custom_runtime.h"
+#include "custom_save_runtime.h"
 
 static bool g_ppg_service_initialled = false;
 
@@ -265,6 +266,7 @@ static void ppg_service_check_task(void  *arg)
         }
         if((wear_mode_state == 1) && (mail > 0x10) && mail != PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST)
         {
+            uapi_save_runtime_log(RUNTIME_LOG_WEAR_MIN_STOP);
             wear_mode_state = 0;
             ppg_send_cmd_to_driver("wear",0);
             ppg_service_running_stat = false;
@@ -304,6 +306,7 @@ static void ppg_service_check_task(void  *arg)
             enable = 1;
         }else if (mail == PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST){
             if (keep_in_wear_det_mod == 0) continue;;
+            uapi_save_runtime_log(RUNTIME_LOG_WEAR_MIN_START);
             cmd = "wear";
             enable = 1;
             wear_mode_state = 1;
@@ -360,6 +363,7 @@ static void ppg_service_check_task(void  *arg)
     {
         if (keep_in_wear_det_mod == 1)
         {
+            uapi_save_runtime_log(RUNTIME_LOG_WEAR_MIN_START);
             ppg_send_cmd_to_driver("wear",1);
             wear_mode_state = 1;
             ppg_service_running_stat = true;
index 7ca2fdf..4096463 100644 (file)
@@ -329,7 +329,7 @@ void crown_data_handler(void *p_event_data, uint16_t event_size)
 
         uint8_t imagqa = crown_read_reg(Img_Qa);
         uint8_t pdsat = crown_read_reg(PD_SAT);
-        if (imagqa<100 || imagqa > 180 || pdsat <240){
+        if (imagqa<100 || imagqa > 180 || pdsat >=240){
             // TYHX_LOG("crown still not pass! pic qulity =%d (should img_qa>=100 && img_qa<=180) , pd saturation=%d (should pd_sat >=240)\r\n",imagqa,pdsat);
         }
 
index b5537c3..fbc817f 100644 (file)
@@ -1,8 +1,8 @@
 /*
  *@Author:luozheng 1732036298@qq.com
  *@Date:2024-12-18 10:27:52
- *@LastEditors:luozheng 1732036298@qq.com
- *@LastEditTime:2024-12-18 16:53:11
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-12-19 18:17:33
  *@FilePath:/FD230/code/sdk/drivers/peripheral/utils/custom_save_runtime.h
  */
 /**
@@ -126,10 +126,16 @@ typedef enum {
   RUNTIME_LOG_HEART_PASSIVE_MEASURE,
   //被动测量心率结束
   RUNTIME_LOG_OXYGEN_PASSIVE_MEASURE_END,
+  //运动测量心率开始或继续
+  RUNTIME_LOG_HEART_SPORT_MEASURE,
+  //运动测量心率暂停或结束
+  RUNTIME_LOG_OXYGEN_SPORT_MEASURE_END,
   /*******************************/
 
   //佩戴
   RUNTIME_LOG_WEAR_MIN = 0x0600,
+   RUNTIME_LOG_WEAR_MIN_START = 0x0601,
+    RUNTIME_LOG_WEAR_MIN_STOP = 0x0602,
 
   /*******************************/
   //血氧
@@ -146,6 +152,8 @@ typedef enum {
   RUNTIME_LOG_LCD_OFF, // 0x0802 屏幕灭
   //抬腕
   RUNTIME_LOG_RAISE_MIN = 0x0900,
+  RUNTIME_LOG_RAISE_MIN_UP = 0x0901,
+  RUNTIME_LOG_RAISE_MIN_DOWN = 0x0902,
 
   //充电
   RUNTIME_LOG_CHARGE_MIN = 0x0A00,
@@ -154,6 +162,8 @@ typedef enum {
 
   //电池电量变化
   RUNTIME_LOG_BATTERY_MIN = 0x0B00,
+  RUNTIME_LOG_BATTERY_MIN_UP = 0x0B01,
+  RUNTIME_LOG_BATTERY_MIN_DOWN = 0x0B02,
 
   //马达
   RUNTIME_LOG_MOTOR_MIN = 0x0C00,
index 85e911c..d165483 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-08-08 16:33:23
- * @LastEditors: SnickerSun snickersun@163.com
- * @LastEditTime: 2024-11-20 16:45:27
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-12-19 18:04:22
  * @FilePath: /FD230/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp
  * @Description: 
  * 
@@ -60,10 +60,12 @@ static bool g_batter_service_initialled = false;
 #include "custom_utils.h"
 #include "custom_runtime.h"
 #include "../../../../../drivers/peripheral/config/include/ConfigModelC.h"
+#include "custom_save_runtime.h"
 
 void custom_VibratorFunc_int(int vibratorType)
 {
-
+    uapi_save_runtime_log(RUNTIME_LOG_MOTOR_START);
+    
     //忽略系统调用参数,只按照configmodel里保存的值来震动
     uint8_t vibmod=uapi_dev_runtime_get_vibmod();
     vibrator_cmd_t mail = {0};