diff --git a/UI/UI_global.c b/UI/UI_global.c index b5e062c..175b743 100644 --- a/UI/UI_global.c +++ b/UI/UI_global.c @@ -323,8 +323,10 @@ void Draw_Status_Battery_Icon(uint8_t battery_percent) { uint8_t Info[8]; uint16_t fill_w; - uint16_t slot_w; uint16_t actual_w; + uint16_t max_w; + uint16_t group_w; + uint16_t clear_x; uint16_t bat_x; uint16_t text_x; uint16_t text_y; @@ -336,29 +338,31 @@ void Draw_Status_Battery_Icon(uint8_t battery_percent) sprintf((char *)Info, "%d%%", battery_percent); actual_w = (uint16_t)(strlen((char *)Info) * adv); - /* 固定按「100%」占位,右对齐,切换位数时图标不跳、% 不被切 */ - slot_w = (uint16_t)(4u * adv); - - bat_x = (uint16_t)(240 - UI0902_BATTERY_RIGHT_MARGIN - slot_w - - UI0902_BATTERY_TEXT_GAP - UI0902_BATTERY_W); - text_x = (uint16_t)(bat_x + UI0902_BATTERY_W + UI0902_BATTERY_TEXT_GAP - + (slot_w - actual_w)); + /* 图标与百分比紧贴;整组右对齐。「100%」变位数时图标左移,不拉开字距 */ + max_w = (uint16_t)(4u * adv); + group_w = (uint16_t)(UI0902_BATTERY_W + UI0902_BATTERY_TEXT_GAP + actual_w); + bat_x = (uint16_t)(240 - UI0902_BATTERY_RIGHT_MARGIN - group_w); + text_x = (uint16_t)(bat_x + UI0902_BATTERY_W + UI0902_BATTERY_TEXT_GAP); text_y = (uint16_t)(UI0902_BATTERY_Y + ((int16_t)UI0902_BATTERY_H - (int16_t)UI0902_BATTERY_TEXT_SIZE) / 2); if ((int16_t)text_y < 0) text_y = 0; - /* 只清分割线上方 */ - LCD_FillByColor(bat_x > 2 ? (uint16_t)(bat_x - 2) : 0, 0, 240, UI0902_STATUS_SEP_Y, - UI0902_BG_COLOR); + clear_x = (uint16_t)(240 - UI0902_BATTERY_RIGHT_MARGIN + - UI0902_BATTERY_W - UI0902_BATTERY_TEXT_GAP - max_w); + if (clear_x > 2) + clear_x = (uint16_t)(clear_x - 2); + else + clear_x = 0; + LCD_FillByColor(clear_x, 0, 240, UI0902_STATUS_SEP_Y, UI0902_BG_COLOR); - /* 实心电量条:内腔约 x+3..x+23(宽21),勿盖住右侧壳壁 */ - fill_w = (uint16_t)((21UL * battery_percent) / 100); + /* 内腔约 y+2..y+9 / x+3..x+23;上下左右各留 1px,电量不贴外壳 */ + fill_w = (uint16_t)((19UL * battery_percent) / 100); if (fill_w > 0) { - fill_x1 = (uint16_t)(bat_x + 3); - fill_y1 = (uint16_t)(UI0902_BATTERY_Y + 2); + fill_x1 = (uint16_t)(bat_x + 4); + fill_y1 = (uint16_t)(UI0902_BATTERY_Y + 3); fill_x2 = (uint16_t)(fill_x1 + fill_w); - fill_y2 = (uint16_t)(fill_y1 + 8); + fill_y2 = (uint16_t)(fill_y1 + 6); LCD_FillByColor(fill_x1, fill_y1, fill_x2, fill_y2, WHITE); } LCD_WR_PIC_Trans(bat_x, UI0902_BATTERY_Y, UI0902_BATTERY_W, UI0902_BATTERY_H, diff --git a/UI/UI_global.h b/UI/UI_global.h index bc1d14e..0a0a4da 100644 --- a/UI/UI_global.h +++ b/UI/UI_global.h @@ -127,7 +127,7 @@ void CallUI_RestoreSelect(void); /* 与音量(y3..20)/蓝牙(y5..21)视觉中心对齐:12px 高 → 顶 y7 */ #define UI0902_BATTERY_Y 7 #define UI0902_BATTERY_RIGHT_MARGIN 6 -#define UI0902_BATTERY_TEXT_GAP 4 +#define UI0902_BATTERY_TEXT_GAP 2 #define UI0902_BATTERY_TEXT_SIZE 9 /* mode.png 百分比字号 ≈9,完整显示 % */ /* 0904 / 0902-11 设置入口:两大卡片 + 底栏「设置」高亮 */ #define UI0902_HUB_CARD_X 10