CTRL library / LEDs

RGB LED methods

To instantiate an RGB LED (4-pin, all three signal pins PWM-capable):

  • CtrlRGBLed(sigR, sigG, sigB, maxBrightness): Creates a common cathode RGB LED.
  • CtrlRGBLed(sigR, sigG, sigB, maxBrightness, COMMON_ANODE): Creates a common anode RGB LED.

Core

  • turnOn(): Turns on the LED.
  • turnOff(): Turns off the LED.
  • set(true): Turns the LED on (true) or off (false).
  • toggle(): Toggles the LED's off/on status.

Colour

  • setColor(255, 0, 0): Sets the colour as red, green & blue values (0 - 255). Does not turn the LED on.
  • setColor(CtrlColor::Red): Sets one of the ready-made colours: Off, White, Red, Green, Blue, Yellow, Cyan & Magenta. You can also define your own colour as a CtrlRGB, e.g. const CtrlRGB pink = {255, 51, 153};
  • getColor(): Returns the colour (CtrlRGB, with .r, .g & .b), regardless of brightness.
  • getOutputColor(): Returns the colour the LED actually outputs (scaled by brightness, off when the LED is off).

Brightness

  • setMaxBrightness(255): Sets the maximum brightness.
  • setBrightness(100): Sets the brightness in percentages.
  • getMaxBrightness(): Returns the maximum brightness set for the LED.
  • getBrightness(): Returns the brightness of the LED.

State

  • isOn(): Checks if the LED is turned on.
  • isOff(): Checks if the LED is turned off.
  • isCommonAnode(): Checks if the LED is a common anode LED.
  • isEnabled(): Checks if the LED is enabled.
  • isDisabled(): Checks if the LED is disabled.
  • enable(): Enables the LED.
  • disable(): Disables the LED.