diff options
author | Duncan Laurie <dlaurie@google.com> | 2017-03-13 09:31:13 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-03-13 19:58:51 -0700 |
commit | cdfce3bc83271f1980f96d6b1d3d0567185ecf76 (patch) | |
tree | 44c54d275723988979ddfa538f54f1c9ca251b70 /board/eve | |
parent | 35387474a1a03209aee02463ad53e300b4d1d938 (diff) | |
download | chrome-ec-cdfce3bc83271f1980f96d6b1d3d0567185ecf76.tar.gz |
eve: Make ectool LED control interface more intuitive
The led_get_brightness_range and led_set_brightness functions are only
used by the led control host command and exercised via ectool for
factory testing.
Currently the ectool inputs must be inverted to get expected behavior:
ectool led power red=100 green=100 blue=20 << blue
Instead we can invert them in the EC to get more intuitive behavior for
the user input values, and use the led_id parameter to split the control
so they can be addressed individually for testing:
ectool led left red=0 green=0 blue=80 << blue
ectool led right red=100 green=13 blue=0 << amber
BUG=b:36150361
BRANCH=none
TEST=Tested manual control of indivual LEDs using ectool
Change-Id: I6551656f3faf26930749d1e9d45a176088c6646c
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/453303
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'board/eve')
-rw-r--r-- | board/eve/led.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/board/eve/led.c b/board/eve/led.c index 9c5a08b2bd..2b7c1cfd7f 100644 --- a/board/eve/led.c +++ b/board/eve/led.c @@ -26,7 +26,7 @@ static int led_debug; const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_POWER_LED, EC_LED_ID_BATTERY_LED}; + EC_LED_ID_LEFT_LED, EC_LED_ID_RIGHT_LED}; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); enum led_color { @@ -106,15 +106,28 @@ void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) { - /* Set brightness for left LED */ - pwm_set_duty(PWM_CH_LED_L_RED, brightness[EC_LED_COLOR_RED]); - pwm_set_duty(PWM_CH_LED_L_BLUE, brightness[EC_LED_COLOR_BLUE]); - pwm_set_duty(PWM_CH_LED_L_GREEN, brightness[EC_LED_COLOR_GREEN]); - - /* Set brightness for right LED */ - pwm_set_duty(PWM_CH_LED_R_RED, brightness[EC_LED_COLOR_RED]); - pwm_set_duty(PWM_CH_LED_R_BLUE, brightness[EC_LED_COLOR_BLUE]); - pwm_set_duty(PWM_CH_LED_R_GREEN, brightness[EC_LED_COLOR_GREEN]); + switch (led_id) { + case EC_LED_ID_LEFT_LED: + /* Set brightness for left LED */ + pwm_set_duty(PWM_CH_LED_L_RED, + 100 - brightness[EC_LED_COLOR_RED]); + pwm_set_duty(PWM_CH_LED_L_BLUE, + 100 - brightness[EC_LED_COLOR_BLUE]); + pwm_set_duty(PWM_CH_LED_L_GREEN, + 100 - brightness[EC_LED_COLOR_GREEN]); + break; + case EC_LED_ID_RIGHT_LED: + /* Set brightness for right LED */ + pwm_set_duty(PWM_CH_LED_R_RED, + 100 - brightness[EC_LED_COLOR_RED]); + pwm_set_duty(PWM_CH_LED_R_BLUE, + 100 - brightness[EC_LED_COLOR_BLUE]); + pwm_set_duty(PWM_CH_LED_R_GREEN, + 100 - brightness[EC_LED_COLOR_GREEN]); + break; + default: + return EC_ERROR_UNKNOWN; + } return EC_SUCCESS; } |