diff options
author | Hsu Henry <Henry.Hsu@quantatw.com> | 2014-10-29 21:59:29 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-11-14 15:32:02 +0000 |
commit | 89b5b7feff80229ae90b3d6e7b75a4fffa8d1c07 (patch) | |
tree | c25efa2de298ddc271b244fb44dc414ac025e98a | |
parent | 4af2679f664b01a456840997ca56e8d32bf009e3 (diff) | |
download | chrome-ec-89b5b7feff80229ae90b3d6e7b75a4fffa8d1c07.tar.gz |
Paine, Yuna: Make the blink point same as UI.
Implement the led behavior based on customer SPEC.
Also change some point based on UI.
The UI use
percentage = remaining capacity / full charge capacity.
display percentage = (percentage - shutdown factor) / (full factor -
shutdown factor)
where shutdown factor = 0.04 and full factor = 0.97 .
If AC plug in, the UI percentage will be 100% when display
percnetage large than 97%.
The approximate value is calculated below.
UI 100% => the percnetage 0.965*0.93+0.04 = 0.93745. Use 937‰.
UI 10% => the percentage 0.104*0.93+0.04 = 0.13672. Use 137‰.
UI 3% => the percentage 0.034*.93+0.04 = 0.07016. Use 71‰.
BUG=chrome-os-partner:32802
BRANCH=paine, yuna
TEST=See below.
UI % AC battery led note
100 in blue
<=10 out amber 1s on/3s off low battery
<=3 out amber 1s on/1s off critical low battery
Change-Id: Ieff72771dbe7f8e21950be1fbfd2392129dd1ed2
Signed-off-by: Henry Hsu <Henry.Hsu@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/227416
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Mohammed Habibulla <moch@chromium.org>
-rw-r--r-- | board/paine/led.c | 22 | ||||
-rw-r--r-- | board/yuna/led.c | 22 |
2 files changed, 38 insertions, 6 deletions
diff --git a/board/paine/led.c b/board/paine/led.c index 5cd9818731..dd424e6086 100644 --- a/board/paine/led.c +++ b/board/paine/led.c @@ -15,6 +15,10 @@ #include "led_common.h" #include "util.h" +#define CRITICAL_LOW_BATTERY_PERMILLAGE 71 +#define LOW_BATTERY_PERMILLAGE 137 +#define FULL_BATTERY_PERMILLAGE 937 + #define LED_TOTAL_4SECS_TICKS 16 #define LED_TOTAL_2SECS_TICKS 8 #define LED_ON_1SEC_TICKS 4 @@ -145,24 +149,36 @@ static void paine_led_set_battery(void) { static int battery_ticks; uint32_t chflags = charge_get_flags(); + int remaining_capacity; + int full_charge_capacity; + int permillage; battery_ticks++; + remaining_capacity = *(int *)host_get_memmap(EC_MEMMAP_BATT_CAP); + full_charge_capacity = *(int *)host_get_memmap(EC_MEMMAP_BATT_LFCC); + permillage = !full_charge_capacity ? 0 : + (1000 * remaining_capacity) / full_charge_capacity; + switch (charge_get_state()) { case PWR_STATE_CHARGE: - paine_led_set_color_battery(LED_AMBER); + /* Make the percentage approximate to UI shown */ + paine_led_set_color_battery(permillage < + FULL_BATTERY_PERMILLAGE ? LED_AMBER : LED_BLUE); break; case PWR_STATE_CHARGE_NEAR_FULL: paine_led_set_color_battery(LED_BLUE); break; case PWR_STATE_DISCHARGE: /* Less than 3%, blink one second every two seconds */ - if (charge_get_percent() < BATTERY_LEVEL_SHUTDOWN) + if (!chipset_in_state(CHIPSET_STATE_ANY_OFF) && + permillage <= CRITICAL_LOW_BATTERY_PERMILLAGE) paine_led_set_color_battery( (battery_ticks % LED_TOTAL_2SECS_TICKS < LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); /* Less than 10%, blink one second every four seconds */ - else if (charge_get_percent() < BATTERY_LEVEL_LOW) + else if (!chipset_in_state(CHIPSET_STATE_ANY_OFF) && + permillage <= LOW_BATTERY_PERMILLAGE) paine_led_set_color_battery( (battery_ticks % LED_TOTAL_4SECS_TICKS < LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); diff --git a/board/yuna/led.c b/board/yuna/led.c index 8e736c2d5d..47e7bae4ac 100644 --- a/board/yuna/led.c +++ b/board/yuna/led.c @@ -15,6 +15,10 @@ #include "led_common.h" #include "util.h" +#define CRITICAL_LOW_BATTERY_PERMILLAGE 71 +#define LOW_BATTERY_PERMILLAGE 137 +#define FULL_BATTERY_PERMILLAGE 937 + #define LED_TOTAL_4SECS_TICKS 16 #define LED_TOTAL_2SECS_TICKS 8 #define LED_ON_1SEC_TICKS 4 @@ -145,24 +149,36 @@ static void yuna_led_set_battery(void) { static int battery_ticks; uint32_t chflags = charge_get_flags(); + int remaining_capacity; + int full_charge_capacity; + int permillage; battery_ticks++; + remaining_capacity = *(int *)host_get_memmap(EC_MEMMAP_BATT_CAP); + full_charge_capacity = *(int *)host_get_memmap(EC_MEMMAP_BATT_LFCC); + permillage = !full_charge_capacity ? 0 : + (1000 * remaining_capacity) / full_charge_capacity; + switch (charge_get_state()) { case PWR_STATE_CHARGE: - yuna_led_set_color_battery(LED_AMBER); + /* Make the percentage approximate to UI shown */ + yuna_led_set_color_battery(permillage < + FULL_BATTERY_PERMILLAGE ? LED_AMBER : LED_BLUE); break; case PWR_STATE_CHARGE_NEAR_FULL: yuna_led_set_color_battery(LED_BLUE); break; case PWR_STATE_DISCHARGE: /* Less than 3%, blink one second every two seconds */ - if (charge_get_percent() < BATTERY_LEVEL_SHUTDOWN) + if (!chipset_in_state(CHIPSET_STATE_ANY_OFF) && + permillage <= CRITICAL_LOW_BATTERY_PERMILLAGE) yuna_led_set_color_battery( (battery_ticks % LED_TOTAL_2SECS_TICKS < LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); /* Less than 10%, blink one second every four seconds */ - else if (charge_get_percent() < BATTERY_LEVEL_LOW) + else if (!chipset_in_state(CHIPSET_STATE_ANY_OFF) && + permillage <= LOW_BATTERY_PERMILLAGE) yuna_led_set_color_battery( (battery_ticks % LED_TOTAL_4SECS_TICKS < LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); |