Skip to content

LED driver for RGB leds + device tree support #51858

@koffes

Description

@koffes

Zephyr has a LED driver https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/led/led_gpio.c which is suitable for single LEDs. There is however (IMHO) no good way to handle RGB leds.

Describe the solution you'd like
It would be great to have native support for RGB leds. That is, having a common API for both RGB and single LEDs.
Something on this form:

// Turns on a single color LED or turns on  R, G and B channel
int led_gpio_on(const struct device *dev, uint32_t led_group);
 
// Turns off single color LED or turns off R, G and B channel
int led_gpio_off(const struct device *dev, uint32_t led_group); 

// Vararg function. Takes a single uint8_t for single_leds or three uint8_t for RGB leds
int led_gpio_set_brightness(const struct device *dev, uint32_t led_group, ...) 

// Will return error if supplied with single-led-group. color_define can be e.g. COLOR_RED, COLOR_WHITE...
int led_gpio_set_color(const struct device *dev, uint32_t led_group, uint8_t color_define) 

This would also mean that the devicetree must have some mechanism to group three GPIOs to form an RGB LED group.

Metadata

Metadata

Labels

EnhancementChanges/Updates/Additions to existing featuresarea: LEDLabel to identify LED subsystem

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions