Fix status bar battery icon display and percent text.
Keep the battery white in the status bar, center it vertically, and use 16px ASCII font so the percentage renders correctly instead of garbled characters. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
aabef28918
commit
745d097178
|
|
@ -234,13 +234,7 @@ void IdleProcess(DisplayTaskMessage_Type msg)
|
|||
break;
|
||||
|
||||
case MSG_ID_BATTERY_VALUE:
|
||||
if(usb_charging_state)
|
||||
{
|
||||
Draw_Battery_Icon(180, 5, msg.ID, 1, GREEN, BLACK, GREEN);
|
||||
}else
|
||||
{
|
||||
Draw_Battery_Icon(180, 5, msg.ID, 1, WHITE, BLACK, WHITE);
|
||||
}
|
||||
Draw_Status_Battery_Icon(msg.ID);
|
||||
break;
|
||||
|
||||
case MSG_ID_POWOFF_CHARG:
|
||||
|
|
|
|||
|
|
@ -386,13 +386,7 @@ void UI_SongMode_Process(DisplayTaskMessage_Type msg)
|
|||
break;
|
||||
|
||||
case MSG_ID_BATTERY_VALUE:
|
||||
if(usb_charging_state)
|
||||
{
|
||||
Draw_Battery_Icon(180, 5,percentage, 1, GREEN, BLACK, GREEN);
|
||||
}else
|
||||
{
|
||||
Draw_Battery_Icon(180, 5, percentage, 1, WHITE, BLACK, WHITE);
|
||||
}
|
||||
Draw_Status_Battery_Icon(percentage);
|
||||
break;
|
||||
|
||||
case MSG_ID_EC_VOL:
|
||||
|
|
|
|||
|
|
@ -124,15 +124,17 @@ void Show_BL_Icon(uint8_t value)
|
|||
BSP_BlueToothPowerEnable (value);
|
||||
}
|
||||
|
||||
void Draw_Status_Battery_Icon(uint8_t battery_percent)
|
||||
{
|
||||
/* 需求图:状态栏电池始终为白色(含 USB 充电连接时) */
|
||||
Draw_Battery_Icon(UI_STATUS_BATTERY_X, UI_STATUS_BATTERY_Y,
|
||||
battery_percent, 1, WHITE, BLACK, WHITE);
|
||||
}
|
||||
|
||||
void Show_Battery_Icon(uint8_t flag)
|
||||
{
|
||||
if(flag)
|
||||
{
|
||||
Draw_Battery_Icon(180, 5, percentage, 1, GREEN, BLACK, GREEN);
|
||||
}else
|
||||
{
|
||||
Draw_Battery_Icon(180, 5, percentage, 1, WHITE, BLACK, WHITE);
|
||||
}
|
||||
(void)flag;
|
||||
Draw_Status_Battery_Icon(percentage);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,12 @@ void CallUI_RestoreSelect(void);
|
|||
|
||||
|
||||
|
||||
#define UI_STATUS_BAR_H 26
|
||||
#define UI_STATUS_BATTERY_X 180
|
||||
#define UI_STATUS_BATTERY_H 11
|
||||
#define UI_STATUS_BATTERY_Y ((UI_STATUS_BAR_H - UI_STATUS_BATTERY_H) / 2)
|
||||
|
||||
void Draw_Status_Battery_Icon(uint8_t battery_percent);
|
||||
void Show_Battery_Icon(uint8_t flag);
|
||||
|
||||
void Show_BL_Icon(uint8_t value);
|
||||
|
|
|
|||
|
|
@ -1844,7 +1844,8 @@ void Draw_Battery_Icon(uint16_t x, uint16_t y, uint8_t battery_percent,uint8_t s
|
|||
uint8_t round_r = 2 * scale;
|
||||
uint8_t stroke = 1 * scale;
|
||||
uint16_t fill_gap = 2 * scale;
|
||||
uint8_t text_size = 12 * scale;
|
||||
uint8_t text_size = 16 * scale; /* 16px ASCII 字体渲染可靠;13px 位图与驱动不匹配会乱码 */
|
||||
uint8_t status_bar_h = 26 * scale;
|
||||
uint8_t Info[40];
|
||||
uint16_t pole_w = 2 * scale;
|
||||
uint16_t pole_h = 5 * scale;
|
||||
|
|
@ -1863,7 +1864,11 @@ void Draw_Battery_Icon(uint16_t x, uint16_t y, uint8_t battery_percent,uint8_t s
|
|||
}
|
||||
|
||||
clear_h = (bat_h > text_size) ? bat_h : text_size;
|
||||
LCD_FillByColor(x, y, 240, y + clear_h + 2 * scale, BLACK);
|
||||
if(status_bar_h > clear_h)
|
||||
{
|
||||
clear_h = status_bar_h;
|
||||
}
|
||||
LCD_FillByColor(x, 0, 240, clear_h, BLACK);
|
||||
|
||||
/* 圆角外壳:外框 + 内挖空 */
|
||||
LCD_FillRoundRect(x, y, bat_w, bat_h, round_r, border_color);
|
||||
|
|
@ -1898,8 +1903,8 @@ void Draw_Battery_Icon(uint16_t x, uint16_t y, uint8_t battery_percent,uint8_t s
|
|||
|
||||
sprintf((char*)Info, "%d%%", battery_percent);
|
||||
text_x = pole_x + pole_w + 2 * scale;
|
||||
text_y = y + (bat_h - text_size) / 2;
|
||||
LCD_ShowString(text_x, text_y, Info, WHITE, bg_color, text_size, 0);
|
||||
text_y = (status_bar_h - text_size) / 2;
|
||||
LCD_ShowString(text_x, text_y, Info, WHITE, BLACK, text_size, 0);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
|
|||
Loading…
Reference in New Issue