Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7e1ef24 authored by Yulian Shandorov's avatar Yulian Shandorov Committed by Steve Kondik
Browse files

charger: Draw battery percentage over charger screen

Let user know the exact battery capacity.

Change-Id: Ie2abaeee0e443cd2a730780488287ad4d9ea1e9a
parent 851c4ad3
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -658,6 +658,20 @@ static void android_green(void)
    gr_color(0xa4, 0xc6, 0x39, 255);
}

static void draw_capacity(struct charger *charger)
{
    char cap_str[64];
    int x, y;
    int str_len_px;

    snprintf(cap_str, sizeof(cap_str), "%d%%", charger->batt_anim->capacity);
    str_len_px = gr_measure(cap_str);
    x = (gr_fb_width() - str_len_px) / 2;
    y = (gr_fb_height() + char_height) / 2;
    android_green();
    gr_text(x, y, cap_str, 0);
}

/* returns the last y-offset of where the surface ends */
static int draw_surface_centered(struct charger *charger, gr_surface surface)
{
@@ -710,8 +724,10 @@ static void redraw_screen(struct charger *charger)
    /* try to display *something* */
    if (batt_anim->capacity < 0 || batt_anim->num_frames == 0)
        draw_unknown(charger);
    else
    else {
        draw_battery(charger);
        draw_capacity(charger);
    }
    gr_flip();
}