From: penglei <1624952103@qq.com> Date: Sat, 9 Nov 2024 08:49:27 +0000 (+0800) Subject: 修复手表重启跳电BUG X-Git-Tag: fd230_release_V1.3.102~86^2~15 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1379%2F1;p=mirrors%2FFD230.git 修复手表重启跳电BUG --- diff --git a/code/sdk/application/battery/service/battery_driver.cpp b/code/sdk/application/battery/service/battery_driver.cpp index c2b20aa6b..0ae388b84 100644 --- a/code/sdk/application/battery/service/battery_driver.cpp +++ b/code/sdk/application/battery/service/battery_driver.cpp @@ -475,8 +475,23 @@ static int battery_get_percent_by_voltage(float voltage) if (voltage <= batteryservice_VOLTAGE_MIN) percent = 0; - if (voltage >= batteryservice_VOLTAGE_MAX) - percent = 100; + if (voltage >= batteryservice_VOLTAGE_MAX) //电压大于4.3 + { + if(get_charge_stat() && history_percent < 100) //充电中则均匀增加 + { + history_percent++; + percent = history_percent; + } + else if(history_percent) //未充电且history_percent不为0 则保持不变 + { + percent = history_percent; + } + else + { + percent = 100; + } + } + return percent; } @@ -587,9 +602,18 @@ static bool adc_get_sample_result(float *voltage, uint8_t channel) get_avg_voltage(voltage); if(percernt_installized) { - cur_percent = battery_get_percent_by_voltage(*voltage); + //历史电量不为0 则开机第一个电量为历史电量 + if(history_percent && !cur_percent && *voltage > batteryservice_VOLTAGE_MIN) + { + cur_percent = history_percent; + } + else + { + cur_percent = battery_get_percent_by_voltage(*voltage); + } + } - // PRINT("cur_percent : %d , history_percent : %d \n",cur_percent,history_percent); + // PRINT("cur_percent : %d , history_percent : %d *voltage : %f\n",cur_percent,history_percent,*voltage); } else if (channel == 0){ *voltage = adc_trans_systick_to_battery_ntc(stick); diff --git a/code/sdk/application/battery/service/battery_service.cpp b/code/sdk/application/battery/service/battery_service.cpp index d169d10c5..47a43d010 100644 --- a/code/sdk/application/battery/service/battery_service.cpp +++ b/code/sdk/application/battery/service/battery_service.cpp @@ -394,7 +394,6 @@ static void battery_check_task(void *arg) charger_plug_event_ui_sendmsg_toUI(0); }else if(mail.comm.event == BATTERY_CMD_FIRST_CHECK) { - battery_check_voltage(); battery_check_chargement(); }else if(mail.comm.event == BATTERY_CMD_SAVE_PERCENT) @@ -561,6 +560,7 @@ void uapi_battery_create_queue(void) #define BATTERY_TASK_SIZE 0x1C00 errcode_t uapi_battery_init(void) { + battery_check_voltage(); battery_percent_init(battery_get_percent_onstart()); //先读历史电量 app_task_definition_t taskcfg={0};