Merge pull request #178 from TQMatvey/dev

Power: Show battery percentile while charging
This commit is contained in:
MX 2022-11-23 18:45:20 +03:00 committed by GitHub
commit 04761b12c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,11 +65,31 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
if(power->state == PowerStateCharging) { if(power->state == PowerStateCharging) {
canvas_set_bitmap_mode(canvas, 1); canvas_set_bitmap_mode(canvas, 1);
canvas_set_color(canvas, ColorWhite);
// TODO: replace -1 magic for uint8_t with re-framing // TODO: replace -1 magic for uint8_t with re-framing
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_draw_icon(canvas, 8, -1, &I_Charging_lightning_mask_9x10);
canvas_set_color(canvas, ColorBlack); canvas_set_color(canvas, ColorBlack);
canvas_draw_icon(canvas, 8, -1, &I_Charging_lightning_9x10); canvas_draw_icon(canvas, 8, -1, &I_Charging_lightning_9x10);
}
canvas_set_bitmap_mode(canvas, 0); canvas_set_bitmap_mode(canvas, 0);
} }
} else { } else {