platform:RK3399
OS:Android 7.1
概述
RK已经实现了关机充电图标动画显示的功能,在实际的使用过程中有一个问题:就算充满电了,充电动画图标仍然在,而没有一个满电图标显示.
满电图标显示
1.增加满电图标,目录如下
tools/resource_tool/resources/images/battery_fully.bmp
2.修改配置文件
tools/resource_tool/resources/images/battery_fully.bmp
#reserve.
bat_error=images/battery_fail.bmp
+#battery fully images
+bat_fully=images/battery_fully.bmp
+
#num of level configs.
levels=6
3.修改显示逻辑
diff --git a/common/cmd_charge.c b/common/cmd_charge.c
index 7d9acba..7e3599b 100755
--- a/common/cmd_charge.c
+++ b/common/cmd_charge.c
@@ -279,11 +279,13 @@ static anim_level_conf* level_confs = NULL;
static int level_conf_num = 0;
static int only_current_level = false;
static char bat_err_path[MAX_INDEX_ENTRY_PATH_LEN];
+static char bat_fully_path[MAX_INDEX_ENTRY_PATH_LEN];
#define OPT_CHARGE_ANIM_DELAY "delay="
#define OPT_CHARGE_ANIM_LOOP_CUR "only_current_level="
#define OPT_CHARGE_ANIM_LEVELS "levels="
#define OPT_CHARGE_ANIM_BAT_ERROR "bat_error="
+#define OPT_CHARGE_ANIM_BAT_FULLY "bat_fully="
#define OPT_CHARGE_ANIM_LEVEL_CONF "min_level="
#define OPT_CHARGE_ANIM_LEVEL_NUM "num="
#define OPT_CHARGE_ANIM_LEVEL_PFX "prefix="
@@ -435,6 +437,11 @@ static bool load_anim_desc(const char* desc_path, bool dump) {
snprintf(bat_err_path, sizeof(bat_err_path), "%s",
arg + strlen(OPT_CHARGE_ANIM_BAT_ERROR));
LOGD("Found battery error image:%s", bat_err_path);
+ } else if (!memcmp(arg, OPT_CHARGE_ANIM_BAT_FULLY,
+ strlen(OPT_CHARGE_ANIM_BAT_FULLY))) {
+ snprintf(bat_fully_path, sizeof(bat_fully_path), "%s",
+ arg + strlen(OPT_CHARGE_ANIM_BAT_FULLY));
+ LOGD("Found battery fully image:%s", bat_fully_path);
} else {
LOGE("Unknown arg:%s", arg);
continue;
@@ -543,8 +550,12 @@ static void update_image(void) {
int level = get_battery_capacity();
int actual_conf = get_index_for_level(level);
LOGD("level:%d, index:%d", level, actual_conf);
-
- //step forward.
+ //battery full image by hewy 2020/05/08
+ if(level >= 100) {
+ show_resource_image("images/battery_fully.bmp");
+ return;
+ }
+//step forward.
current_index++;
if (only_current_level) {
测试问题
修改过后测试发现,无论如何都无法显示满电图标.最后排查发现电量计cw2015是通过读取电压值判断是否满电的,实际上会有5%~10%的误差,导致一直检测到没有充满,但是实际上是充满了.可以改用电量来判断是否充满