summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBian Jin chen <kenjc.bian@rock-chips.com>2019-03-23 15:13:21 +0800
committer卞金晨 <kenjc.bian@rock-chips.com>2019-03-23 15:25:43 +0800
commitd0a255502f9bd49ecad891d7e47283835ae9b760 (patch)
treef2e4974e0dc8e51338e69df72edbeb4516069d3a
parent585c4330398b82645af4a4eca17ac1a0f0536c06 (diff)
healthd: supports charger percentage animation.
Change-Id: I1be377b7d60fc4260fe88dc01760cc5ac3373bbd Signed-off-by: Bian Jin chen <kenjc.bian@rock-chips.com> Signed-off-by: wlq <wlq@rock-chips.com>
-rw-r--r--healthd/healthd_draw.cpp11
-rw-r--r--healthd/healthd_draw.h2
-rw-r--r--healthd/healthd_mode_charger.cpp19
-rw-r--r--healthd/images/font.pngbin0 -> 156971 bytes
4 files changed, 17 insertions, 15 deletions
diff --git a/healthd/healthd_draw.cpp b/healthd/healthd_draw.cpp
index ea3d991c0..4e16a6c28 100644
--- a/healthd/healthd_draw.cpp
+++ b/healthd/healthd_draw.cpp
@@ -147,13 +147,13 @@ void HealthdDraw::draw_clock(const animation* anim) {
draw_text(field.font, x, y, clock_str);
}
-void HealthdDraw::draw_percent(const animation* anim) {
+void HealthdDraw::draw_percent(const animation* anim, int y_start) {
int cur_level = anim->cur_level;
if (anim->cur_status == BATTERY_STATUS_FULL) {
cur_level = 100;
}
- if (cur_level <= 0) return;
+ if (cur_level < 0) return;
const animation::text_field& field = anim->text_percent;
if (field.font == nullptr || field.font->char_width == 0 ||
@@ -168,19 +168,20 @@ void HealthdDraw::draw_percent(const animation* anim) {
LOGV("drawing percent %s %d %d\n", str.c_str(), x, y);
gr_color(field.color_r, field.color_g, field.color_b, field.color_a);
- draw_text(field.font, x, y, str.c_str());
+ gr_text(field.font, x, y_start, str.c_str(), false);
}
void HealthdDraw::draw_battery(const animation* anim) {
const animation::frame& frame = anim->frames[anim->cur_frame];
+ int y_start = 0;
if (anim->num_frames != 0) {
- draw_surface_centered(frame.surface);
+ y_start = draw_surface_centered(frame.surface);
LOGV("drawing frame #%d min_cap=%d time=%d\n", anim->cur_frame,
frame.min_level, frame.disp_time);
}
draw_clock(anim);
- draw_percent(anim);
+ draw_percent(anim,y_start);
}
void HealthdDraw::draw_unknown(GRSurface* surf_unknown) {
diff --git a/healthd/healthd_draw.h b/healthd/healthd_draw.h
index 6a6ba7655..5d9281f73 100644
--- a/healthd/healthd_draw.h
+++ b/healthd/healthd_draw.h
@@ -54,7 +54,7 @@ class HealthdDraw {
// Draws clock text, if animation contains text_field data.
virtual void draw_clock(const animation* anim);
// Draws battery percentage text if animation contains text_field data.
- virtual void draw_percent(const animation* anim);
+ virtual void draw_percent(const animation* anim, int y_start);
// Draws charger->surf_unknown or basic text.
virtual void draw_unknown(GRSurface* surf_unknown);
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp
index 56a9f8691..436de46cd 100644
--- a/healthd/healthd_mode_charger.cpp
+++ b/healthd/healthd_mode_charger.cpp
@@ -105,24 +105,24 @@ struct charger {
static const animation BASE_ANIMATION = {
.text_clock =
{
- .pos_x = 0,
- .pos_y = 0,
+ .pos_x = CENTER_VAL,
+ .pos_y = 100,
- .color_r = 255,
+ .color_r = 0,
.color_g = 255,
- .color_b = 255,
+ .color_b = 0,
.color_a = 255,
.font = nullptr,
},
.text_percent =
{
- .pos_x = 0,
- .pos_y = 0,
+ .pos_x = CENTER_VAL,
+ .pos_y = 100,
- .color_r = 255,
+ .color_r = 0,
.color_g = 255,
- .color_b = 255,
+ .color_b = 0,
.color_a = 255,
},
@@ -590,7 +590,8 @@ animation* init_animation() {
if (battery_animation.fail_file.empty()) {
battery_animation.fail_file.assign("charger/battery_fail");
}
-
+ if(battery_animation.text_percent.font_file.empty())
+ battery_animation.text_percent.font_file.assign("charger/font");
LOGV("Animation Description:\n");
LOGV(" animation: %d %d '%s' (%d)\n", battery_animation.num_cycles,
battery_animation.first_frame_repeats, battery_animation.animation_file.c_str(),
diff --git a/healthd/images/font.png b/healthd/images/font.png
new file mode 100644
index 000000000..d0eca726c
--- /dev/null
+++ b/healthd/images/font.png
Binary files differ