Open koffes opened 1 year ago
FYI @alexsven @erikrobstad. I discovered this https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/drivers/led.h which I need to investigate.
There is LED strip already, which can be used (with a size of 1) https://docs.zephyrproject.org/latest/hardware/peripherals/led.html#led-strip
I have had a look at this one, as well as others, but it seems to me that in order to use them you need an external driver IC? In the use case we want to solve, the LED channels are connected directly to host GPIOs.
Hi @mbolivar-ampere, @simonguinot, @Mani-Sadhasivam,
This issue, marked as an Enhancement, was opened a while ago and did not get any traction. It was just assigned to you based on the labels. If you don't consider yourself the right person to address this issue, please re-assing it to the right person.
Please take a moment to review if the issue is still relevant to the project. If it is, please provide feedback and direction on how to move forward. If it is not, has already been addressed, is a duplicate, or is no longer relevant, please close it with a short comment explaining the reason.
@koffes you are also encouraged to help moving this issue forward by providing additional information and confirming this request/issue is still relevant to you.
Thanks!
The LED DT API already allows to define multi-color (i.e. multi-channel) LEDs. Here is an example:
leds {
compatible = "gpio-leds";
/* Multi channel GPIO LED */
led_0 {
label = "RGB LED";
gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>,
<&gpio0 2 GPIO_ACTIVE_LOW>,
<&gpio0 3 GPIO_ACTIVE_HIGH>;
color-mapping =
<LED_COLOR_ID_RED>,
<LED_COLOR_ID_GREEN>,
<LED_COLOR_ID_BLUE>;
};
/* Single channel GPIO LED */
led_1 {
label = "Green LED";
gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
color-mapping = <LED_COLOR_ID_GREEN>,
};
};
On the led_gpio
driver side, we simply need to implement support for the color-mapping
and gpios
array properties through the ->set_color()
method of the LED API. And probably we will need to disable the ->set_brightness()
method for a multi-color LED. And that's it.
Note that the same comment applies to PWM LEDs.
Grouping LEDs is an interesting idea. Some LED controllers provides this feature and it would be nice for the LED API to support it. But I don't think it is the right way to support RGB GPIO LEDs.
Related with #63387
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:
This would also mean that the devicetree must have some mechanism to group three GPIOs to form an RGB LED group.