优化低电电压跳变
author1624952103 <pl@DESKTOP-EN9LKR5.localdomain>
Mon, 9 Feb 2026 02:01:27 +0000 (10:01 +0800)
committer1624952103 <pl@DESKTOP-EN9LKR5.localdomain>
Mon, 9 Feb 2026 02:01:27 +0000 (10:01 +0800)
code/sdk/zhihui/services/battery/service/battery_driver.cpp

index 7081bf7..88c350a 100644 (file)
@@ -565,8 +565,12 @@ void battery_restore_vol(void)
 
     batteryservice_get_voltage_by_channel(&cur_vol,ADC_CHANNEL_BAT_VOLTAGE);
 
-    if(bat_vol.percent > 0 && bat_vol.percent<=100 && (fabsf(cur_vol - bat_vol.avg_vol) < 0.25))
-        history_percent = bat_vol.percent;
+    if (bat_vol.percent > 0 && bat_vol.percent <= 100) {
+        float threshold = get_charge_stat() ? 0.4f : 0.25f;
+        if (fabsf(cur_vol - bat_vol.avg_vol) < threshold) {
+            history_percent = bat_vol.percent;
+        }
+    }
     // for(int i = 0; i < AVG_VOLTAGE_COUNT;i++)
     // {
     //     printf("history_data[%d]:%.3f\n",i,bat_vol.history_data[i]);