summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-07-03 14:59:15 +0800
committerChromeBot <chrome-bot@google.com>2013-07-10 11:16:37 -0700
commita8e15b27bf171a542cfdeaa6eb6b45d93c38aed1 (patch)
treefdff4b9135a6f86a12a6e3fb98d4aff9fcf03cd4
parent56bd316488584f80ca8d6cc67d73f76ed66af1e7 (diff)
downloadchrome-ec-a8e15b27bf171a542cfdeaa6eb6b45d93c38aed1.tar.gz
spring: Update battery LED less frequently when charging
When the user uses about the same amount of power the charger provides and the battery level is around 94%, the user might see the LED hop between green and yellow. We should update LED color less frequently in this case. BUG=chrome-os-partner:20677 TEST=Hack a console command to fake battery charge level. Change battery level between 93 and 94, and see LED color only change every 15 seconds. BRANCH=Spring Original-Change-Id: I55cda9aee5f79465e9094355a1f66666d018cddd Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/60851 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Signed-off-by: Vic Yang <victoryang@chromium.org> (cherry picked from commit d03e35c42835e4b52779499d0a4b8ebdcb1074f2) Change-Id: I51090418cdbb7a6fea0163e04d9a962b46268f34 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/61397 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/led_lp5562.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/common/led_lp5562.c b/common/led_lp5562.c
index fe33b7e7fb..420f391ce5 100644
--- a/common/led_lp5562.c
+++ b/common/led_lp5562.c
@@ -13,10 +13,14 @@
#include "lp5562.h"
#include "pmu_tpschrome.h"
#include "smart_battery.h"
+#include "timer.h"
#include "util.h"
#define GREEN_LED_THRESHOLD 94
+/* Minimal interval between changing LED color to green and yellow. */
+#define LED_WAIT_INTERVAL (15 * SECOND)
+
/* We use yellow LED instead of blue LED. Re-map colors here. */
#define LED_COLOR_NONE LP5562_COLOR_NONE
#define LED_COLOR_GREEN LP5562_COLOR_GREEN
@@ -121,6 +125,12 @@ static void battery_led_update(void)
static int led_power = -1;
int new_led_power;
+ /*
+ * The time before which we should not change LED
+ * color between green and yellow.
+ */
+ static timestamp_t led_update_deadline = {.val = 0};
+
/* Determine LED power */
new_led_power = extpower_is_present();
if (new_led_power != led_power) {
@@ -129,6 +139,7 @@ static void battery_led_update(void)
} else {
rv = lp5562_poweroff();
set_led_color(LED_STATE_OFF);
+ led_update_deadline.val = 0;
}
if (!rv)
led_power = new_led_power;
@@ -178,6 +189,16 @@ static void battery_led_update(void)
break;
}
+ if (state == LED_STATE_SOLID_GREEN ||
+ state == LED_STATE_SOLID_YELLOW) {
+ if (!timestamp_expired(led_update_deadline, NULL))
+ return;
+ led_update_deadline.val =
+ get_time().val + LED_WAIT_INTERVAL;
+ } else {
+ led_update_deadline.val = 0;
+ }
+
set_led_color(state);
}
DECLARE_HOOK(HOOK_SECOND, battery_led_update, HOOK_PRIO_DEFAULT);