summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kuo <tedkuo@ami.com.tw>2015-12-18 18:24:59 +0800
committerChromeOS bot <3su6n15k.default@developer.gserviceaccount.com>2015-12-25 02:04:59 +0000
commite33ed80387aa84057e47d3b7daded8a69a29b389 (patch)
tree8d8e5936c034ac3deda24bdbc3b5199f22cdc9a5
parent3c8016630129c43258f6b28698633afbe54cb940 (diff)
downloadchrome-ec-e33ed80387aa84057e47d3b7daded8a69a29b389.tar.gz
edgar: update battery led control algorithm
1.Change remaining percentage to UI display percentage for battery low and critical. 2.Battery LED turns to blue when battery is full. BUG=None TEST=make buildall -j, verified BRANCH=firmware-strago-7287.B Signed-off-by: Ted Kuo <tedkuo@ami.com.tw> Change-Id: I6fcfd68064b8b262c12c7843f9e09d1a2d25f61c Reviewed-on: https://chromium-review.googlesource.com/319272 Reviewed-by: Shawn N <shawnn@chromium.org> Commit-Queue: Ted Kuo <tedkuo@ami.com.tw> Tested-by: Ted Kuo <tedkuo@ami.com.tw>
-rw-r--r--board/edgar/led.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/board/edgar/led.c b/board/edgar/led.c
index 793454b7bf..a43ebefd4e 100644
--- a/board/edgar/led.c
+++ b/board/edgar/led.c
@@ -11,6 +11,7 @@
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
+#include "host_command.h"
#include "led_common.h"
#include "pwm.h"
#include "registers.h"
@@ -22,6 +23,9 @@
#define LED_TOTAL_SECS 4
#define LED_ON_SECS 1
+#define CRITICAL_LOW_BATTERY_PERMILLAGE 45
+#define LOW_BATTERY_PERMILLAGE 138
+
static int led_debug;
const enum ec_led_id supported_led_ids[] = {
@@ -133,28 +137,42 @@ static void edgar_led_set_power(void)
static void edgar_led_set_battery(void)
{
static int battery_secs;
+ int remaining_capacity;
+ int full_charge_capacity;
+ int permillage;
battery_secs++;
+ 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;
+
/* BAT LED behavior:
* Fully charged / idle: Blue
* Force idle (for factory): 2 secs of blue, 2 secs of orange
* Under charging: Orange
- * Battery low (10%): Orange in breeze mode (1 sec on, 3 sec off)
- * Battery critical low (less than 3%) or abnormal battery
+ * Battery low (10%[UI]): Orange in breeze mode (1 sec on, 3 sec off)
+ * Battery critical low (less than 0%[UI]) or abnormal battery
* situation: Orange in blinking mode (1 sec on, 1 sec off)
* Using battery or not connected to AC power: OFF
*/
switch (charge_get_state()) {
case PWR_STATE_CHARGE:
- bat_led_set_color(LED_ORANGE);
+ bat_led_set_color(
+ charge_get_percent() == 100
+ ? LED_BLUE : LED_ORANGE);
break;
case PWR_STATE_DISCHARGE:
- if (charge_get_percent() < 3)
+ /* Less than 0%[UI], blink one second every two seconds */
+ if (!chipset_in_state(CHIPSET_STATE_ANY_OFF) &&
+ permillage <= CRITICAL_LOW_BATTERY_PERMILLAGE)
bat_led_set_color(
(battery_secs % 2) < LED_ON_SECS
? LED_ORANGE : LED_OFF);
- else if (charge_get_percent() < 10)
+ /* Less than 10%[UI], blink one second every four seconds */
+ else if (!chipset_in_state(CHIPSET_STATE_ANY_OFF) &&
+ permillage <= LOW_BATTERY_PERMILLAGE)
bat_led_set_color(
(battery_secs % LED_TOTAL_SECS) < LED_ON_SECS
? LED_ORANGE : LED_OFF);
@@ -167,7 +185,9 @@ static void edgar_led_set_battery(void)
? LED_ORANGE : LED_OFF);
break;
case PWR_STATE_CHARGE_NEAR_FULL:
- bat_led_set_color(LED_BLUE);
+ bat_led_set_color(
+ charge_get_percent() == 100
+ ? LED_BLUE : LED_ORANGE);
break;
case PWR_STATE_IDLE: /* External power connected in IDLE. */
if (charge_get_flags() & CHARGE_FLAG_FORCE_IDLE)