优化心率被动检测runtime设置,优化读取睡眠数据,修复卡片滑动卡顿BUG,增加关机保存电量,开机读取电量操作
authorpenglei <1624952103@qq.com>
Mon, 14 Oct 2024 07:48:40 +0000 (15:48 +0800)
committerpenglei <1624952103@qq.com>
Mon, 14 Oct 2024 07:48:40 +0000 (15:48 +0800)
code/sdk/application/battery/hal/battery_hal.h
code/sdk/application/battery/service/battery_driver.cpp
code/sdk/application/battery/service/battery_service.cpp
code/sdk/application/battery/service/battery_service.h
code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp
code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp
code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp
code/sdk/drivers/peripheral/utils/custom_utils.c

index a0e88b0..749061a 100644 (file)
@@ -43,6 +43,8 @@ uint8_t battery_get_voltage(float *voltage);
 */
 uint8_t get_charge_stat(void);
 
+void battery_percent_init(uint8_t percent);
+
 #ifdef __cplusplus
 #if __cplusplus
 }
index 25b050a..8f292c3 100644 (file)
@@ -276,6 +276,11 @@ static uint32_t sample_time = 0;
 
 static battery_info_t current_battery_info={0};
 
+void battery_percent_init(uint8_t percent)
+{
+    history_percent = percent;
+}
+
 battery_info_t *get_current_battery_info(void)
 {
     return &current_battery_info;
@@ -398,6 +403,7 @@ static int battery_get_power_percentage(float voltage)
     int percent = 0;
     int map_len = sizeof(battery_percent_map)/sizeof(battery_percent_map[0]);
     float temp_value = 0.0f;
+
     for (int i =0;i<map_len -1;i++)
     {
         //电压在前后两个之间
index 6faf4cd..5858473 100644 (file)
@@ -95,6 +95,26 @@ static void battery_check_timer_callback(void* data);
 errcode_t charger_plug_event_notify(uint8_t plugged);
 errcode_t charger_plug_event_ui_sendmsg_toUI(uint8_t plugged);
 
+//保存电量到文件
+static void battery_save_percent(void)
+{
+    float voltage;
+    uint8_t percent = batteryservice_get_voltage(&voltage);
+    uapi_save_file_data("/user/userdata/battery.bin",&percent,1,"wb");
+    PRINT("battery_save_percent : %d",percent);
+}
+
+//从文件中读取电量
+uint8_t battery_get_percent_onstart(void)
+{
+    uint8_t percent = 0;
+    uint16_t len = 1;
+    uapi_get_file_data("/user/userdata/battery.bin",&percent,&len);
+    PRINT("battery_get_percent_onstart : %d",percent);
+    return percent;
+}
+
+
 static void battery_timer_start_check_released(uint32_t rtc_ms)
 {
     if (osTimerIsRunning(g_battery_timer))  osTimerStop(g_battery_timer);
@@ -373,7 +393,12 @@ static void battery_check_task(void *arg)
         {
             battery_check_voltage();
             battery_check_chargement();
+            battery_percent_init(battery_get_percent_onstart());
+        }else if(mail.comm.event == BATTERY_CMD_SAVE_PERCENT)
+        {
+            battery_save_percent();
         }
+
     }// while (1) 
 
 
@@ -568,10 +593,6 @@ void battery_service_suspend(void)
     PRINT("battery_service suspend!\r\n");
 }
 
-
-
-
-
 #ifdef __cplusplus
 #if __cplusplus
 }
index d30d190..340fdb8 100644 (file)
@@ -19,6 +19,9 @@ extern "C" {
 #include "stdint.h"
 #include "errcode.h"
 
+
+#define BATTERY_CMD_SAVE_PERCENT 0x16
+
 uint8_t batteryservice_get_battery_temp(float *temp);
 uint8_t batteryservice_get_pcb_temp(float *temp);
 uint8_t batteryservice_get_voltage(float *voltage);
@@ -32,7 +35,7 @@ void disable_02c(void);
 void enable_charge(void);
 void disable_charge(void);
 void set_lowpower_show( uint8_t type,uint8_t data);
-
+uint8_t battery_get_percent_onstart(void);
 //0 停止充电 , 1 低电流充电, 2 正常电流充电
 int get_charge_current_status(void);
 uint8_t get_02c_value(void);
index 73d443a..d5b9146 100644 (file)
@@ -399,10 +399,6 @@ void HeartModel::Heart_Control(HeartState state, HeartCheck check) {
     heartstate = false;\r
     // 复原检测状态\r
     checkstate = HeartCheck::RESTSTSTE;\r
-    LOS_Msleep(500);\r
-    uapi_dev_runtime_set_hrs_passivity(0);\r
-    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,\r
-                  "uapi_dev_runtime_set_hrs_passivity(0)");\r
   } else if (state == HeartState::Start && heartstate == false) {\r
     /*充电状态下不进行检测*/\r
     bool isCharging = get_charge_stat(); // 获取充电状态\r
index 77b706f..9938232 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * @Author: penglei 1624952103@qq.com
  * @Date: SLEPPNOTIFY24-06-26 19:36:48
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-10-14 09:58:35
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-10-14 15:41:13
  * @FilePath:
  * /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp
  * @Description:
@@ -665,12 +665,14 @@ namespace OHOS
     do_cywee_service_check_msg(CYWEE_SERVICE_CMD_GET_SLEEP_DATA,
                                &cmd); // 获取睡眠数据 但不中止睡眠
     LOS_Msleep(200);
-    do_custom_fileoperate_service_check_msg(
-        CUSTOM_FILEOPERATE_MSG_TYPE_SLEEPDATA_READ, nullptr, 0);
-    LOS_Msleep(200);
-    do_custom_fileoperate_service_check_msg(
-        CUSTOM_FILEOPERATE_MSG_TYPE_NAPDATA_READ, nullptr, 0);
-    LOS_Msleep(200);
+    // do_custom_fileoperate_service_check_msg(
+    //     CUSTOM_FILEOPERATE_MSG_TYPE_SLEEPDATA_READ, nullptr, 0);
+    // LOS_Msleep(200);
+    // do_custom_fileoperate_service_check_msg(
+    //     CUSTOM_FILEOPERATE_MSG_TYPE_NAPDATA_READ, nullptr, 0);
+    // LOS_Msleep(200);
+    custom_read_sleep_data();
+    custom_read_nap_data();
     {
       WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
                     "ReadSleepData sleepStr %u  wakeStr %u sleep_total_time %d",
index 85a947f..ec63f48 100644 (file)
@@ -324,7 +324,8 @@ static void ppg_service_check_task(void  *arg)
             //PRINT("uapi_dev_runtime_get_hrs_passivity_flag : %d \n",uapi_dev_runtime_get_hrs_passivity_flag());
             if(uapi_dev_runtime_get_sleep_monitoring_status() && uapi_dev_runtime_get_hrs_passivity_flag())//处于睡眠监测 且在心率周期检测期间 上报活体佩戴 
             {
-                hx3695_wearstatus_update();            
+                hx3695_wearstatus_update();   
+                uapi_dev_runtime_set_hrs_passivity(0);//清除被动检测runtime     
             }
             cmd = "hrs";
             enable = 0;
index 8793797..bc0e0f7 100644 (file)
@@ -67,6 +67,7 @@
 #include "input_app.h"
 #endif
 #include "broadcast_feature.h"
+#include "battery_service.h"
 
 errcode_t uapi_create_osThread_custom(app_task_definition_t *task_cfg)
 {
@@ -224,6 +225,9 @@ void shutdown_reboot_prejobs_task(void)
     //保存config文件到磁盘
     // cm_sync_all_config_to_disk();
 
+    //保存电量
+    send_battery_svr_cmd_msg(BATTERY_CMD_SAVE_PERCENT);
+
     //重启前要保存时间
     uapi_calendar_store_date();
     
@@ -1746,7 +1750,6 @@ void charge_getstate(void)
         PRINT("uncharged\r\n");
 }
 
-#include "battery_service.h"
 
 void battery_getvolpower(uint8_t *power)
 {