修复恢复出厂电量异常显示bug
authorpenglei <1624952103@qq.com>
Tue, 12 Nov 2024 11:11:52 +0000 (19:11 +0800)
committerpenglei <1624952103@qq.com>
Tue, 12 Nov 2024 11:11:52 +0000 (19:11 +0800)
code/sdk/application/battery/service/battery_driver.cpp

index 0ae388b..fb24a4f 100644 (file)
@@ -477,12 +477,12 @@ static int battery_get_percent_by_voltage(float voltage)
 
     if (voltage >= batteryservice_VOLTAGE_MAX) //电压大于4.3
     {
-        if(get_charge_stat() && history_percent < 100) //充电中则均匀增加
+        if(get_charge_stat() && history_percent < 100 && history_percent) //充电中则均匀增加
         {
             history_percent++;
             percent = history_percent;
         }
-        else if(history_percent) //未充电且history_percent不为0 则保持不变 
+        else if(!get_charge_stat() && history_percent) //未充电且history_percent不为0 则保持不变 
         {
             percent = history_percent;
         }