优化了电量显示

This commit is contained in:
haped 2025-07-24 14:28:04 +08:00
parent d01fa7b208
commit d41761e257
238 changed files with 26595 additions and 19078 deletions

View File

@ -487,28 +487,39 @@ static void box_adc_detect_callback(int new_mv, void *user_data)
{
static int cnt = 0;
box_batt_adc.user_data = (void*)new_mv;
u32 kmah=0;
if(cnt++ >= 20){
cnt = 0;
rt_kprintf("adc channel%d voltage:%d,%x\r\n",box_batt_adc.channel,new_mv,box_batt_adc.user_data);
int bat_volt = new_mv*2;
//int batt_min = 3300; //3300
int batt_max = 4200;
int batt_max = 4151;
if(box_info.charge_state){
bat_volt -= 48 ;
}
rt_kprintf("battery_calc --> bat_volt:%d\n",bat_volt);
if(bat_volt >= batt_max)
box_battery_percent = 100;
else if(bat_volt >= 4100)
box_battery_percent = 90 + (bat_volt - 4100) * 10 / 100; // 4100~4200
else if(bat_volt >= 3900)
box_battery_percent = 60 + (bat_volt - 3900) * 30 / 200; // 3900~4100
else if(bat_volt >= 3700)
box_battery_percent = 30 + (bat_volt - 3700) * 30 / 200; // 3700~3900
else if(bat_volt >= 3500)
box_battery_percent = 10 + (bat_volt - 3500) * 20 / 200; // 3500~3700
else if(bat_volt >= 3300)
box_battery_percent = (bat_volt - 3300) * 10 / 200; // 3300~3500
else if(bat_volt <= batt_max && bat_volt >= 4000){
kmah = (-28880*bat_volt+120895600)/151;
box_battery_percent = (443570-kmah)*100/443570; // 4000~4150
}
else if(bat_volt <= 4000 && bat_volt >= 3800){
kmah = (-78560*bat_volt+321360000)/200;
box_battery_percent = (443570-kmah)*100/443570; // 3800~4000
}
else if(bat_volt <= 3800 && bat_volt >= 3600){
kmah = (-134960*bat_volt+535680000)/200;
box_battery_percent = (443570-kmah)*100/443570; // 3600~3800
}
else if(bat_volt <= 3600 && bat_volt >= 3400){
kmah = (-163110*bat_volt+637020000)/200;
box_battery_percent = (443570-kmah)*100/443570; // 3400~3600
}
else if(bat_volt <= 3600 && bat_volt >= 3400){
kmah = (-31340*bat_volt+271448000)/400;
box_battery_percent = (443570-kmah)*100/443570; // 3000~3400
}
else
box_battery_percent = 1;
@ -611,7 +622,7 @@ void app_show_temperature_device_info(){
OLED_ShowString(35,25,(u8 *)str_batt,16,1);
OLED_Refresh();
rt_thread_mdelay(2000);
if(temperature_info.batt_val < 365){ //电压值小于365显示“低电”
if(temperature_info.batt_val < 330){ //电压值小于365显示“低电”
app_enter_ui(UI_SHOW_LOW_BAT_INFO);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<key name="Software">
<key name="ConEmu">
<key name=".Vanilla" modified="2025-07-11 16:37:39" build="180206">
<key name=".Vanilla" modified="2025-07-14 18:34:34" build="180206">
<value name="StartType" type="hex" data="02"/>
<value name="CmdLine" type="string" data=""/>
<value name="StartTasksFile" type="string" data=""/>
@ -261,7 +261,7 @@
<value name="WindowMode" type="dword" data="0000051f"/>
<value name="ConWnd X" type="long" data="748"/>
<value name="ConWnd Y" type="long" data="71"/>
<value name="LastMonitor" type="string" data="0,0,1920,1030"/>
<value name="LastMonitor" type="string" data="0,0,2560,1368"/>
<value name="ConWnd Width" type="dword" data="00000075"/>
<value name="ConWnd Height" type="dword" data="0000001a"/>
<value name="16bit Height" type="ulong" data="0"/>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More