Skip to content

RGB

RoboBoard X3 RGB light

Control 4 individual RGB lights (A, B, C, D) located at the edge of RoboBoard. By default it shines "Totem" colors. Can be controlled from smartphone app to customize robot appearance or using API for different colors or animations.

Ways to access specific LED:

  • RGB.A - control LED A
  • RGB.B - control LED B
  • RGB.C - control LED C
  • RGB.D - control LED D
  • RGB[0] - control LED A [1-B, 2-C, 3-D] (invalid indexes will be ignored)
  • RGB - control all LEDs

Code snippets

// Set all LED
RGB.colorTotem();           // Set all LED to Totem colors
RGB.color(Color::Violet);   // Set all LED to violet color
RGB.color(0xFFFF00);        // Set all LED to yellow color
RGB.color(0, 255, 0);       // Set all LED to green color
RGB.color(Color::random()); // Set all LED to random generated color
// Set single LED
RGB.A.color(Color::White);  // Set RGB A to white color
RGB.B.color(Color::Red);    // Set RGB B to red color
RGB.C.color(0x00FFFF);      // Set RGB C to cyan color
RGB[3].color(0, 0, 255);    // Set RGB D to blue color
// Control functions
RGB.on();             // Turn LED on
RGB.off();            // Turn LED off
RGB.toggle();         // Toggle on/off
// Individual random color
for (int i=0; i<4; i++) {
  RGB[i].color(Color::random());
}

Functions

🚥 Control

Read Color formats for more details how color is represented with numbers.

RGB.colorTotem()

Lit up all LED with "Totem" colors (🟢 🟡 🟡 🔵).

RGB.color(red, green, blue)

RGB.color(hex)

Set LED color with RGB or HEX format.
Parameter:
🔴 red - amount of red color [0:255]
🟢 green - amount of green color [0:255]
🔵 blue - amount of blue color [0:255]
hex - hexadecimal color code [0x000000:0xFFFFFF]

RGB.on()

Turn LED on to last used color.

RGB.off()

Turn LED off.

RGB.toggle()

Toggle LED between on / off states.

state RGB.isOn()

Check if LED is currently lit on.
Returns:
state - true if lit on. false otherwise (off).

hex RGB.getColor()

Get current LED color.
Returns:
hex - hexadecimal color code [0x000000:0xFFFFFF]

RGB.setState(state)

Set LED to specific state (on / off).
Parameter:
state - state on / off [HIGH:LOW] or [true:false]

state RGB.getState()

Same as isOn().
Returns:
state - true if lit on. false otherwise (off).

Configure

RGB.setDim(dimming)

Limit maximum LED brightness. Default values: X3 - 128. X4 - 255.
Parameter:
dimming - [0:255] maximum brightness.

dimming RGB.getDim()

Get configured LED brightness.
Returns:
dimming - [0:255] maximum brightness.

RGB.setEnable(state)

Enable / disable RGB light. Disabled LED will not lit up.
Parameter:
state - LED is enabled / disabled [true:false].

state RGB.getEnable()

Check if RGB light is enabled.
Returns:
state - LED is enabled / disabled [true:false].

Color names

totem-color.h
namespace Color {
enum {
    IndianRed = 0xFFCD5C5C,
    LightCoral = 0xFFF08080,
    Salmon = 0xFFFA8072,
    Crimson = 0xFFDC143C,
    Red = 0xFFFF0000,
    FireBrick = 0xFFB22222,
    DarkRed = 0xFF8B0000,
    ...

Object Color contains a list of names with predefined HEX codes. A more convenient way to control LED color, compared to specifying exact RGB values. Full list can be found in totem-color.h file.

Color formats

Available color formats:

  • NAME: Color::Red, Color::Violet, ...
  • 🌈 RGB value: 8-bit amount [0:255] of Red, Green, Blue colors mix.
  • HEX code: hexadecimal color code 0xFFFFFF (similar to HTML code #FFFFFF).

HEX format encoding:

Conversion between HEX and RGB formats.

24-bit: 0xAABBCC0xAA (170 red), 0xBB (187 green), 0xCC (204 blue).

Use with RoboBoard color functions:

  • RGB.color(Color::Violet) - set color name
  • RGB.color(100, 150, 200) - set color mix of Red, Green, Blue [0:255] values
  • RGB.color(0xFFAABB) - set color HEX code [0x000000:0xFFFFFF]

Color mix functions

Functions for mixing color from RGB values and returning single HEX code. Useful if color has to be stored to int variable for later use with color() function.

hex Color::rgb(red,green,blue)

Mix color by provided parameters.
Returns: 24-bit color code.
Parameter:
🔴 red - amount of red color [0:255]
🟢 green - amount of green color [0:255]
🔵 blue - amount of blue color [0:255]
hex - hexadecimal color code [0x000000:0xFFFFFF]

hex Color::random()

Generate random color.
Returns: 24-bit color code.