Possible bug with RGB API

I have started using the RGB API to control the LED to prevent it from remaining lit during sleeping hours so that the pulsing LED does not bother my family. For the most part the behavior works as expected. The code I use can be found below. The problem I see is with this line: RGB.brightness(0); If I have this line in my code then the LED will not ever light again unless I power cycle the device. However if I remove this line then it works as expected. I believe that when the OS regains control of the LED it should re-set the brightness to whatever value it used before control of the LED was taken from it.

This code will first check if the device is connected to the cloud. If it is not then control of the RGB LED is granted to the OS. If the device is connected however then control of the RGB LED depends on the time of day. Specifically the hour. Within a certain hour range the LED is disabled and outside of that range the LED control is granted to the OS.

if (Particle.connected()) {
        int hour = Time.hour();
        // Turn off the LED from the hours of 9pm to 7am
        if (!RGB.controlled() && IsInControlledTimeRange(hour)) {
            // take control of the LED
            RGB.brightness(0);   // This is the line that causes the issue. 
        } else if (RGB.controlled() && !IsInControlledTimeRange(hour)) {
} else {
        // Give control back to the OS when the device is
        // not connected to the cloud.
        if (RGB.controlled()) {

That’s not a bug but the intended behaviour.

RGB.brightness() is meant to also dim the default RGB signals.

It’s even documented that way

Checking the facts beats any assumtion :wink:

1 Like

Ah, Thank you for pointing that out.