Merge #1328 into sdk602patch0911 from refs/changes/1328/head
author彭磊 <1624952103@qq.com>
Sun, 3 Nov 2024 08:15:26 +0000 (08:15 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Sun, 3 Nov 2024 08:15:26 +0000 (08:15 +0000)
Code review from 彭磊

* refs/changes/1328/head: (5 commits squashed)

  - 恢复出厂设置添加死机文件路径

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

  - 优化电量获取,平滑增加或减少电量
    增加睡眠时间段心率检测无效数

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

Signed-off-by: aliyun6865282430 <1624952103@qq.com>
Reviewed-by: Caisking <3449750381@qq.com>
Reviewed-by: 罗正 <1732036298@qq.com>
Reviewed-by: aliyun8003852482 <1224667075@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Reviewed-by: aliyun6865282430 <1624952103@qq.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1328
code/sdk/application/battery/service/battery_driver.cpp
code/sdk/application/battery/service/battery_service.cpp
code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp

index 8f292c3..f846f6c 100644 (file)
@@ -276,6 +276,8 @@ static uint32_t sample_time = 0;
 
 static battery_info_t current_battery_info={0};
 
+static uint8_t cur_percent = 0;
+
 void battery_percent_init(uint8_t percent)
 {
     history_percent = percent;
@@ -392,12 +394,19 @@ static float adc_trans_systick_to_battery_ntc(int sticks)
     // osal_printk("battery ntc temp value1 %.4f value2 %.4f\r\n",ret,temp_value);
     return temp_value;
 }
+
+static uint8_t battery_get_power_percentage(void)
+{
+    uint8_t percent = cur_percent;
+    return percent;
+}
+
 /**
  * 输入电池电压值 
  * 根据 battery_percent_map 计算并返回 电池电量百分比
  * 返回值 0~100
 */
-static int battery_get_power_percentage(float voltage)
+static int battery_get_percent_by_voltage(float voltage)
 {
     uint32_t current_time = 0;
     int percent = 0;
@@ -423,6 +432,14 @@ static int battery_get_power_percentage(float voltage)
                     percent = history_percent;
                     break;
                 }
+                //电量均匀增加
+                else if(percent > history_percent)
+                {
+                    history_percent++;
+                    percent = history_percent;
+                    PRINT("charge percent[%d], history_percent[%d] \n",percent,history_percent);
+                    break;
+                }
             }
             else
             {
@@ -431,6 +448,14 @@ static int battery_get_power_percentage(float voltage)
                     percent = history_percent;
                     break;
                 }
+                //电量均匀减少
+                else if(history_percent > percent)
+                {
+                    history_percent--;
+                    percent = history_percent;
+                    PRINT("uncharge percent[%d], history_percent[%d] \n",percent,history_percent);
+                    break;
+                }
 
             }
 
@@ -557,6 +582,8 @@ static bool adc_get_sample_result(float *voltage, uint8_t channel)
     {
         *voltage = adc_trans_systick_to_battery_voltage(stick);
         get_avg_voltage(voltage);
+        cur_percent = battery_get_percent_by_voltage(*voltage);
+        PRINT("cur_percent : %d , history_percent : %d \n",cur_percent,history_percent);
     }
     else if (channel == 0){
         *voltage = adc_trans_systick_to_battery_ntc(stick);
@@ -695,7 +722,7 @@ uint8_t batteryservice_get_voltage(float *voltage)
     uint8_t percent = 0;
     battery_info_t *current_battery_info = get_current_battery_info();
 
-    percent = battery_get_power_percentage(current_battery_info->battery_voltage);
+    percent = battery_get_power_percentage();
     *voltage = current_battery_info->battery_voltage;
 
     return percent;
index cdfa549..2f0a9e3 100644 (file)
@@ -393,9 +393,10 @@ static void battery_check_task(void *arg)
             charger_plug_event_ui_sendmsg_toUI(0);
         }else if(mail.comm.event == BATTERY_CMD_FIRST_CHECK)
         {
+            battery_percent_init(battery_get_percent_onstart()); //先读历史电量
             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();
index 88566c4..557cf76 100644 (file)
@@ -679,7 +679,7 @@ void HeartModel::UpHeartdata(uint16_t heart) {
 \r
   // 检查无效计数器是否达标\r
   if (uapi_dev_runtime_get_sleep_monitoring_status()) //睡眠监测模式下,增加未佩戴个数最大值,避免误判\r
-    max_valid_count = MAX_DISVALID_HRS_COUNT * 2;\r
+    max_valid_count = MAX_DISVALID_HRS_COUNT * 3;\r
   else\r
     max_valid_count = MAX_DISVALID_HRS_COUNT;\r
 \r