mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-01 12:52:26 +00:00
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>
This commit is contained in:
committed by
chrome-bot
parent
35387474a1
commit
cdfce3bc83
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user