Merge pull request #115 from TQMatvey/batter_percentage

Power: remove % sign from desktop and center numbers
This commit is contained in:
MX
2022-10-18 04:27:24 +03:00
committed by GitHub
@@ -12,10 +12,8 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
canvas_draw_icon(canvas, 0, 0, &I_Battery_26x8); canvas_draw_icon(canvas, 0, 0, &I_Battery_26x8);
if(power->info.gauge_is_ok) { if(power->info.gauge_is_ok) {
char batteryPercentile[5]; char batteryPercentile[4];
snprintf(batteryPercentile, sizeof(batteryPercentile), "%d", power->info.charge); snprintf(batteryPercentile, sizeof(batteryPercentile), "%d", power->info.charge);
strcat(batteryPercentile, "%");
if((power->displayBatteryPercentage == 1) && if((power->displayBatteryPercentage == 1) &&
(power->state != (power->state !=
PowerStateCharging)) { //if display battery percentage, black background white text PowerStateCharging)) { //if display battery percentage, black background white text
@@ -23,14 +21,14 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
canvas_set_color(canvas, ColorBlack); canvas_set_color(canvas, ColorBlack);
canvas_draw_box(canvas, 1, 1, 22, 6); canvas_draw_box(canvas, 1, 1, 22, 6);
canvas_set_color(canvas, ColorWhite); canvas_set_color(canvas, ColorWhite);
canvas_draw_str_aligned(canvas, 12, 4, AlignCenter, AlignCenter, batteryPercentile); canvas_draw_str_aligned(canvas, 11, 4, AlignCenter, AlignCenter, batteryPercentile);
} else if( } else if(
(power->displayBatteryPercentage == 2) && (power->displayBatteryPercentage == 2) &&
(power->state != (power->state !=
PowerStateCharging)) { //if display inverted percentage, white background black text PowerStateCharging)) { //if display inverted percentage, white background black text
canvas_set_font(canvas, FontBatteryPercent); canvas_set_font(canvas, FontBatteryPercent);
canvas_set_color(canvas, ColorBlack); canvas_set_color(canvas, ColorBlack);
canvas_draw_str_aligned(canvas, 12, 4, AlignCenter, AlignCenter, batteryPercentile); canvas_draw_str_aligned(canvas, 11, 4, AlignCenter, AlignCenter, batteryPercentile);
} else if( } else if(
(power->displayBatteryPercentage == 3) && (power->displayBatteryPercentage == 3) &&
(power->state != PowerStateCharging)) { //Retro style segmented display, 3 parts (power->state != PowerStateCharging)) { //Retro style segmented display, 3 parts