diff --git a/UI/UI_Idle.c b/UI/UI_Idle.c index 2f28592..c89ea87 100644 --- a/UI/UI_Idle.c +++ b/UI/UI_Idle.c @@ -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: diff --git a/UI/UI_SongMode.c b/UI/UI_SongMode.c index 5134296..a57fd29 100644 --- a/UI/UI_SongMode.c +++ b/UI/UI_SongMode.c @@ -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: diff --git a/UI/UI_global.c b/UI/UI_global.c index 0e24f56..cacd622 100644 --- a/UI/UI_global.c +++ b/UI/UI_global.c @@ -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); } diff --git a/UI/UI_global.h b/UI/UI_global.h index f714295..c38f52d 100644 --- a/UI/UI_global.h +++ b/UI/UI_global.h @@ -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); diff --git a/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.c b/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.c index a67606c..2297dd9 100644 --- a/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.c +++ b/device/LCD_ILI9341/Drv_ILI9341_Lcd_App.c @@ -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); } /******************************************************************************