diff options
author | Leo Zhou <zhoubo@huaqin.corp-partner.google.com> | 2019-11-18 22:29:51 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-11-22 18:45:17 +0000 |
commit | b40bf39567066bc193adff1cf1025b20cc69a7c7 (patch) | |
tree | 32ec69e01ee2b2cb4eac12de13bbe4e870f2484f /board/kukui | |
parent | 3ef7e92840d8d80af097c4adf6b8b4c61e241c19 (diff) | |
download | chrome-ec-b40bf39567066bc193adff1cf1025b20cc69a7c7.tar.gz |
krane: Use the PWM mode to adjust brightness as lowest
Adjust current=4ma, pwm=1/32, and change the state as:
charging is blue
charged full is green
low battery is red
BUG=b:137618886
BRANCH=kukui
TEST=Do a full charging test, notice LED indicator status under
different charge state
Change-Id: Ic1b7a99ab3edaee5c92a5cae56bc6d9a321e9c23
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1918995
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
Tested-by: Kook Zhang <zhangbinbin@huaqin.corp-partner.google.com>
Commit-Queue: Leo Zhou <zhoubo@huaqin.corp-partner.google.com>
Diffstat (limited to 'board/kukui')
-rw-r--r-- | board/kukui/led.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/board/kukui/led.c b/board/kukui/led.c index 527568b83d..73fa23a8ab 100644 --- a/board/kukui/led.c +++ b/board/kukui/led.c @@ -43,16 +43,17 @@ static void kukui_led_set_battery(void) switch (chstate) { case PWR_STATE_CHARGE: - case PWR_STATE_CHARGE_NEAR_FULL: - br[EC_LED_COLOR_BLUE] = 2; - br[EC_LED_COLOR_GREEN] = 1; - br[EC_LED_COLOR_RED] = 1; + /* RGB(current, duty) = (4mA,1/32)*/ + br[EC_LED_COLOR_BLUE] = 1; break; case PWR_STATE_DISCHARGE: /* display SoC 10% = real battery SoC 13%*/ if (charge_get_percent() <= 13) br[EC_LED_COLOR_RED] = 1; break; + case PWR_STATE_CHARGE_NEAR_FULL: + br[EC_LED_COLOR_GREEN] = 1; + break; case PWR_STATE_ERROR: br[EC_LED_COLOR_RED] = 1; break; @@ -113,6 +114,23 @@ static void led_reset_auto_control(void) prv_chstate = PWR_STATE_INIT; } +static void krane_led_init(void) +{ + const enum mt6370_led_dim_mode dim = MT6370_LED_DIM_MODE_PWM; + const enum mt6370_led_pwm_freq freq = MT6370_LED_PWM_FREQ1000; + mt6370_led_set_color(LED_MASK_RED | LED_MASK_GREEN | LED_MASK_BLUE); + mt6370_led_set_dim_mode(LED_RED, dim); + mt6370_led_set_dim_mode(LED_GREEN, dim); + mt6370_led_set_dim_mode(LED_BLUE, dim); + mt6370_led_set_pwm_frequency(LED_RED, freq); + mt6370_led_set_pwm_frequency(LED_GREEN, freq); + mt6370_led_set_pwm_frequency(LED_BLUE, freq); + mt6370_led_set_pwm_dim_duty(LED_RED, 0); + mt6370_led_set_pwm_dim_duty(LED_GREEN, 0); + mt6370_led_set_pwm_dim_duty(LED_BLUE, 0); +} +DECLARE_HOOK(HOOK_INIT, krane_led_init, HOOK_PRIO_DEFAULT); + /* Called by hook task every 1 sec */ static void led_second(void) { |