Skip to content

Commit

Permalink
charger: Draw battery percentage over charger screen
Browse files Browse the repository at this point in the history
Let user know the exact battery capacity.

Change-Id: Ie2abaeee0e443cd2a730780488287ad4d9ea1e9a
  • Loading branch information
Yulian Shandorov authored and hyperb1iss committed Oct 7, 2013
1 parent 851c4ad commit f7e1ef2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion charger/charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit f7e1ef2

Please sign in to comment.