在RDA8810平台上添加关机充电百分比
old mode 100644
new mode 100755
index 21196f8..94761fc
--- a/charger/charger.c
+++ b/charger/charger.c
@@ -681,9 +681,25 @@ static int draw_text(const char *str, int x, int y)
y = (gr_fb_height() - char_height) / 2;
gr_text(x, y, str);
+ LOGI(" *****************y=%d char_height=%d str=%s ***************/n",y,char_height,str);
return y + char_height;
}
+/********************add****************/
+static int baifenbi_draw_text(const char *str, int x, int y)
+{
+ int str_len_px = gr_measure(str);
+
+ if (x < 0)
+ x = (gr_fb_width() - str_len_px) / 2;
+ if (y < 0)
+ y = (gr_fb_height() - char_height) / 2;
+ gr_text(x, y, str);
+
+ LOGI(" /n====x=%d=======y=%d char_height=%d str=%s ===========/n",x,y,char_height,str);
+ return y + char_height;
+}
+/*******************************************/
static void android_green(void)
{
gr_color(0xa4, 0xc6, 0x39, 255);
@@ -719,16 +735,52 @@ static void draw_unknown(struct charger *charger)
}
}
+/**************************add************************************/
+static int baifenbi_surface_centered(struct charger *charger, gr_surface surface)
+{
+ int w=250;
+ int h=360;
+ int x=35;
+ int y=60;
+
+ /* w = gr_get_width(surface);
+ h = gr_get_height(surface);
+ x = (gr_fb_width() - w) / 2 ;
+ y = (gr_fb_height() - h) / 2 ;
+*/
+ // LOGV("drawing surface %dx%d+%d+%d\n", w, h, x, y);
+ // gr_blit(surface, 0, 0, w, h, x, y);
+ gr_blit(surface, 0, 0, w, h, x, y);
+ return y + h;
+}
+/**************************************************************/
+
static void draw_battery(struct charger *charger)
{
+ int y;
+ int batt_cap;
+ char str[8];
struct animation *batt_anim = charger->batt_anim;
struct frame *frame = &batt_anim->frames[batt_anim->cur_frame];
if (batt_anim->num_frames != 0) {
draw_surface_centered(charger, frame->surface);
- LOGV("drawing frame #%d name=%s min_cap=%d time=%d\n",
+ LOGI("drawing frame #%d name=%s min_cap=%d time=%d\n",
batt_anim->cur_frame, frame->name, frame->min_capacity,
frame->disp_time);
+
+
+/******************add*********************/
+
+
+ batt_cap = get_battery_capacity(charger);
+ sprintf(str,"%d",batt_cap);
+ strcat(str,"%");
+ android_green();
+
+ y = draw_text(" ", -1, y-100);
+ baifenbi_draw_text(str, -1, y-80);
+/***************************************/
}
}