From 15dcf7308382f2750682c09b61cf3724aa336c91 Mon Sep 17 00:00:00 2001 From: TQMatvey Date: Tue, 22 Nov 2022 12:51:47 +0700 Subject: [PATCH] Power: Show battery percentile while charging --- .../services/power/power_service/power.c | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/applications/services/power/power_service/power.c b/applications/services/power/power_service/power.c index 2b3023da5..443ef0520 100644 --- a/applications/services/power/power_service/power.c +++ b/applications/services/power/power_service/power.c @@ -65,11 +65,31 @@ void power_draw_battery_callback(Canvas* canvas, void* context) { if(power->state == PowerStateCharging) { canvas_set_bitmap_mode(canvas, 1); - canvas_set_color(canvas, ColorWhite); // TODO: replace -1 magic for uint8_t with re-framing - canvas_draw_icon(canvas, 8, -1, &I_Charging_lightning_mask_9x10); - canvas_set_color(canvas, ColorBlack); - canvas_draw_icon(canvas, 8, -1, &I_Charging_lightning_9x10); + if(power->displayBatteryPercentage == 1) { + canvas_set_color(canvas, ColorBlack); + canvas_draw_box(canvas, 1, 1, 22, 6); + canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_9x10); + canvas_set_color(canvas, ColorWhite); + canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_mask_9x10); + canvas_set_font(canvas, FontBatteryPercent); + canvas_draw_str_aligned( + canvas, 16, 4, AlignCenter, AlignCenter, batteryPercentile); + } else if(power->displayBatteryPercentage == 2) { + canvas_set_color(canvas, ColorWhite); + canvas_draw_box(canvas, 1, 1, 22, 6); + canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_9x10); + canvas_set_color(canvas, ColorBlack); + canvas_draw_icon(canvas, 2, -1, &I_Charging_lightning_mask_9x10); + canvas_set_font(canvas, FontBatteryPercent); + canvas_draw_str_aligned( + canvas, 16, 4, AlignCenter, AlignCenter, batteryPercentile); + } else { + canvas_set_color(canvas, ColorWhite); + canvas_draw_icon(canvas, 8, -1, &I_Charging_lightning_mask_9x10); + canvas_set_color(canvas, ColorBlack); + canvas_draw_icon(canvas, 8, -1, &I_Charging_lightning_9x10); + } canvas_set_bitmap_mode(canvas, 0); } } else {