[Bugfix][R305][bug-view-1535/1537][led] Modification of power light effect issue when battery level is less than 5%
Change-Id: I3dbdb7919fa167d3670231f2e203b53d9c344131
diff --git a/lynq/R305/ap/app/zte_comm/zte_mmi/mmi_led.c b/lynq/R305/ap/app/zte_comm/zte_mmi/mmi_led.c
index 1ef5928..c292a1a 100755
--- a/lynq/R305/ap/app/zte_comm/zte_mmi/mmi_led.c
+++ b/lynq/R305/ap/app/zte_comm/zte_mmi/mmi_led.c
@@ -396,6 +396,31 @@
mmi_file_operate(LED_BATTERY_100_BLINKSWITCH, LED_BLINKOFF_STATE);
}
+static int mmi_read_battery_now()
+{
+ FILE *fd_voltage = NULL;
+ char buf_volt[8] = {0};
+ int voltagepower = 0;
+ int len = 0;
+
+ fd_voltage = fopen(CHARGE_VOLTAGE_PATH, "r");
+ if (fd_voltage == NULL)
+ {
+ slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_read_battery_now open voltage file fail!\n");
+ return -1;
+ }
+ len = fread(buf_volt, 1, 8, fd_voltage);
+ if (len > 0)
+ {
+ voltagepower = atoi(buf_volt);
+ fclose(fd_voltage);
+ slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI mmi_read_battery_now voltagepower=%d\n",voltagepower);
+ return voltagepower;
+ }
+
+ return -1;
+}
+
static SINT32 mmi_cnccBatteryLedState(T_zMMIBatteryInfo *pBatteryInfo)
{
mmi_Battery_led_opt_blink_off();
@@ -460,26 +485,32 @@
mmi_Battery_led_opt_off(LED_BATTERY_75_BRIGHTNESS);
mmi_Battery_led_opt_off(LED_BATTERY_100_BRIGHTNESS);
}
- else if ((pBatteryInfo->bat_pers >= 5) && (pBatteryInfo->bat_pers < 25))
+ else
{
- mmi_Battery_led_opt_on(LED_BATTERY_25_BRIGHTNESS);
- mmi_Battery_led_opt_off(LED_BATTERY_50_BRIGHTNESS);
- mmi_Battery_led_opt_off(LED_BATTERY_75_BRIGHTNESS);
- mmi_Battery_led_opt_off(LED_BATTERY_100_BRIGHTNESS);
- }
- else if ((pBatteryInfo->bat_pers > 0) && (pBatteryInfo->bat_pers < 5))
- {
- mmi_Battery_led_opt_blink(25);
- mmi_Battery_led_opt_off(LED_BATTERY_50_BRIGHTNESS);
- mmi_Battery_led_opt_off(LED_BATTERY_75_BRIGHTNESS);
- mmi_Battery_led_opt_off(LED_BATTERY_100_BRIGHTNESS);
- }
- else if (pBatteryInfo->bat_pers == 0)
- {
- mmi_Battery_led_opt_off(LED_BATTERY_25_BRIGHTNESS);
- mmi_Battery_led_opt_off(LED_BATTERY_50_BRIGHTNESS);
- mmi_Battery_led_opt_off(LED_BATTERY_75_BRIGHTNESS);
- mmi_Battery_led_opt_off(LED_BATTERY_100_BRIGHTNESS);
+ // 3090 <-> 0%|3132 <-> 1%|3174 <-> 2%|3216 <-> 3%|3258 <-> 4%|3300 <-> 5%
+ int bat_now = mmi_read_battery_now();
+ slog(MMI_PRINT, SLOG_NORMAL, "ZTE_MMI mmi_cnccBatteryLedState bat_now=%d\n", bat_now);
+ if (bat_now >= 3216) // 3 <= bat < 25
+ {
+ mmi_Battery_led_opt_on(LED_BATTERY_25_BRIGHTNESS);
+ mmi_Battery_led_opt_off(LED_BATTERY_50_BRIGHTNESS);
+ mmi_Battery_led_opt_off(LED_BATTERY_75_BRIGHTNESS);
+ mmi_Battery_led_opt_off(LED_BATTERY_100_BRIGHTNESS);
+ }
+ else if ((bat_now > 3090) && (bat_now < 3216)) // 0 < bat < 3
+ {
+ mmi_Battery_led_opt_blink(25);
+ mmi_Battery_led_opt_off(LED_BATTERY_50_BRIGHTNESS);
+ mmi_Battery_led_opt_off(LED_BATTERY_75_BRIGHTNESS);
+ mmi_Battery_led_opt_off(LED_BATTERY_100_BRIGHTNESS);
+ }
+ else
+ {
+ mmi_Battery_led_opt_off(LED_BATTERY_25_BRIGHTNESS);
+ mmi_Battery_led_opt_off(LED_BATTERY_50_BRIGHTNESS);
+ mmi_Battery_led_opt_off(LED_BATTERY_75_BRIGHTNESS);
+ mmi_Battery_led_opt_off(LED_BATTERY_100_BRIGHTNESS);
+ }
}
}