From a0d411c6f7ee110e5fa3c0db1a9d34f696967b70 Mon Sep 17 00:00:00 2001 From: 1624952103 Date: Thu, 26 Mar 2026 18:40:58 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E7=94=B5=E6=B1=A0=E4=BF=A1?= =?utf8?q?=E6=81=AF=E7=94=B5=E5=8E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../battery/service/battery_driver.cpp | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/code/sdk/zhihui/services/battery/service/battery_driver.cpp b/code/sdk/zhihui/services/battery/service/battery_driver.cpp index cbd01b580..fb9010be6 100644 --- a/code/sdk/zhihui/services/battery/service/battery_driver.cpp +++ b/code/sdk/zhihui/services/battery/service/battery_driver.cpp @@ -774,6 +774,32 @@ static int battery_get_percent_by_voltage(float voltage) // ====================================================================== float temp_value = 0.0f; + // // ===================== 只打印当前使用的数组 ===================== + static bool print_flag = false; + if(!print_flag) + { + print_flag = true; + printf("==== 当前使用的电池电压映射表 ====\n"); + if(get_charge_stat()) + { + printf("==== 充电模式 battery_charge_percent_map ====\n"); + } + else + { + printf("==== 非充电模式 battery_percent_map ====\n"); + } + + for(int i=0; i percent && abs(history_percent - percent) < 10) @@ -848,16 +884,15 @@ static int battery_get_percent_by_voltage(float voltage) if (voltage <= batteryservice_VOLTAGE_MIN) percent = 0; - if (voltage >= batteryservice_VOLTAGE_MAX) //电压大于4.3 + if (voltage >= batteryservice_VOLTAGE_MAX) { - if(get_charge_stat() && history_percent < 100 && history_percent) //充电中则均匀增加 + if(get_charge_stat() && history_percent < 100 && history_percent) { printf("111 history_percent:%d ,percent : %d ,voltage:%.3f \n",history_percent,percent,voltage); - // uapi_save_runtime_log(RUNTIME_LOG_BATTERY_MIN_UP); history_percent++; percent = history_percent; } - else if(!get_charge_stat() && history_percent) //未充电且history_percent不为0 则保持不变 + else if(!get_charge_stat() && history_percent) { printf("222 history_percent:%d ,percent : %d ,voltage:%.3f \n",history_percent,percent,voltage); percent = history_percent; @@ -870,11 +905,9 @@ static int battery_get_percent_by_voltage(float voltage) } } - return percent; } - static uint32_t get_current_timestamp(void) { uint32_t timestamp = 0; -- 2.17.1