Colored status led not fully working #2630

Closed
opened 2025-08-17 09:55:34 -05:00 by tazounet · 5 comments
tazounet commented 2025-08-17 09:55:34 -05:00 (Migrated from github.com)

Hello,

I was using the code from "pio/ws2812" without problems and then I switch to the new "colored status led" library with the sdk 2.2.0.

  1. "colored_status_led_set_on_with_color" don't change the color if the LED is already ON. Why not but it's not describe in the documentation.
  2. I created a "colored_status_led_change_color" function to handle color change, but it was not working until I add a sleep between "colored_status_led_set_state" and "colored_status_led_set_on_with_color". This timing constraint is not in the documentation. Is it a bug ?
  3. Adding a "colored_status_led_change_color" directly in the library could be a good addition :)

The working code:

bool colored_status_led_change_color(uint32_t color)
{
    colored_status_led_set_state(false);
    sleep_us(100);
    return colored_status_led_set_on_with_color(color);
}

Thanks

Hello, I was using the code from "pio/ws2812" without problems and then I switch to the new "colored status led" library with the sdk 2.2.0. 1) "colored_status_led_set_on_with_color" don't change the color if the LED is already ON. Why not but it's not describe in the documentation. 2) I created a "colored_status_led_change_color" function to handle color change, but it was not working until I add a sleep between "colored_status_led_set_state" and "colored_status_led_set_on_with_color". This timing constraint is not in the documentation. Is it a bug ? 3) Adding a "colored_status_led_change_color" directly in the library could be a good addition :) The working code: ``` bool colored_status_led_change_color(uint32_t color) { colored_status_led_set_state(false); sleep_us(100); return colored_status_led_set_on_with_color(color); } ``` Thanks
lurch commented 2025-08-17 16:18:03 -05:00 (Migrated from github.com)

Rather than adding a new colored_status_led_change_color function, does the original code work as expected if you change https://github.com/raspberrypi/pico-sdk/blob/develop/src/rp2_common/pico_status_led/status_led.c#L83 from

        if (led_on && !colored_status_led_on) {

to

        if (led_on) {

?

Rather than adding a new `colored_status_led_change_color` function, does the original code work as expected if you change https://github.com/raspberrypi/pico-sdk/blob/develop/src/rp2_common/pico_status_led/status_led.c#L83 from ```c if (led_on && !colored_status_led_on) { ``` to ```c if (led_on) { ``` ?
peterharperuk commented 2025-08-18 04:40:00 -05:00 (Migrated from github.com)

I think you need a delay after setting a ws2812 led (50us?). I'm not sure I like the idea of the API doing this. So setting the led color while it's already on might not work. We could document this however.

I think you need a delay after setting a ws2812 led (50us?). I'm not sure I like the idea of the API doing this. So setting the led color while it's already on might not work. We could document this however.
tazounet commented 2025-08-18 09:00:15 -05:00 (Migrated from github.com)

@lurch yes with this modification we can change the color without the need to set the LED off.

@peterharperuk 50us was not working, 100us seems reliable.

@lurch yes with this modification we can change the color without the need to set the LED off. @peterharperuk 50us was not working, 100us seems reliable.
kilograham commented 2025-08-18 11:56:05 -05:00 (Migrated from github.com)

colored_status_led_set_on_with_color() should change the color; that is its intent; if it doesn't that is a bug.

it is also a requirement of the library to take care of this, as the way the LED behaves is its own problem.

Note that, a different PIO program or implementation could fix this (e.g. if the PIO program continually updated the color with the required delay)

`colored_status_led_set_on_with_color()` should change the color; that is its intent; if it doesn't that is a bug. it is also a requirement of the library to take care of this, as the way the LED behaves is its own problem. Note that, a different PIO program or implementation could fix this (e.g. if the PIO program continually updated the color with the required delay)
kilograham commented 2026-06-01 13:57:09 -05:00 (Migrated from github.com)

fix merged into develop

fix merged into develop
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#2630
No description provided.