Skip to content

RGB Control ​

Overview ​

This section contains all components and utilities for RGB Control.

Components ​

ItemTypeDescription
rgbPropertyRGB controller for managing device lighting effects.
RGBControllerClassController for managing RGB lighting effects on the Decker device.

rgb ​

RGB controller for managing device lighting effects.

Control the 8 RGB LEDs on the Decker device with various effects, colors, brightness levels, and animation speeds.


RGBController ​

Controller for managing RGB lighting effects on the Decker device.

The Decker device features 8 RGB LEDs that can display various lighting effects. This controller provides methods to control the lighting effects, colors, brightness, and animation speed.

Example ​

typescript
import Plugin, { runPlugin } from '@dotmatrixlabs/dotx-plugin-sdk';

export default class RGBPlugin extends Plugin {
  async onLoad() {
    // Turn off RGB lights
    await this.rgb.turnOff();
    
    // Set static red color at 50% brightness
    await this.rgb.setEffect('static', 50, 50, '#FF0000');
    
    // Enable rainbow effect
    await this.rgb.setEffect('rainbow', 75, 100, '#FFFFFF');
    
    // Adjust brightness only
    await this.rgb.setBrightness(80);
    
    // Change color only
    await this.rgb.setColor('#00FF00');
  }
}

Properties ​

  • effects (any): Available RGB lighting effects.

Methods ​

MethodParametersDescription
getAvailableEffects()-Get the list of available RGB effects.
getCurrentState()-Get the current RGB state.
setBrightness()brightness: numberUpdate only the brightness of the current RGB effect.
setColor()color: stringUpdate only the color of the current RGB effect.
setEffect()effectName: RGBEffect, speed: number, brightness: number, color: stringSet a complete RGB lighting effect with all parameters.
setSpeed()speed: numberUpdate only the animation speed of the current RGB effect.
turnOff()-Turn off all RGB lighting.

getAvailableEffects() ​

typescript
getAvailableEffects(): any

Get the list of available RGB effects.

Returns an array of all supported RGB effect names that can be used with the setEffect() method.

Returns:

any - Array of available effect names

Example:

typescript
const effects = this.rgb.getAvailableEffects();
console.log('Available effects:', effects);
// Output: ['rainbow', 'static', 'off', 'lightningStorm', 'candle', 'perimeter', 'breathing']

// Use in a settings dropdown
settings.addSelect('rgbEffect')
  .setLabel('RGB Effect')
  .setOptions(
    this.rgb.getAvailableEffects().map(effect => ({
      value: effect,
      label: effect.charAt(0).toUpperCase() + effect.slice(1)
    }))
  );

getCurrentState() ​

typescript
getCurrentState(): any

Get the current RGB state.

Returns the current effect, speed, brightness, and color settings.

Returns:

any - Object containing current RGB settings

Example:

typescript
const state = this.rgb.getCurrentState();
console.log('Current effect:', state.effect);
console.log('Current brightness:', state.brightness);
console.log('Current color:', state.color);
console.log('Current speed:', state.speed);

setBrightness() ​

typescript
setBrightness(brightness: number): Promise

Update only the brightness of the current RGB effect.

This is a convenience method that updates brightness while keeping the current effect, speed, and color unchanged.

Parameters:

NameTypeRequiredDescription
brightnessnumberYesLED brightness from 0 (off) to 100 (maximum)

Returns:

Promise - Promise that resolves when the brightness is updated

Example:

typescript
// Dim the lights to 25%
await this.rgb.setBrightness(25);

// Set to full brightness
await this.rgb.setBrightness(100);

// Turn lights almost off but not completely
await this.rgb.setBrightness(5);

setColor() ​

typescript
setColor(color: string): Promise

Update only the color of the current RGB effect.

This is a convenience method that updates color while keeping the current effect, speed, and brightness unchanged.

Parameters:

NameTypeRequiredDescription
colorstringYesColor in hex format (e.g., '#FF0000' for red)

Returns:

Promise - Promise that resolves when the color is updated

Example:

typescript
// Change to red
await this.rgb.setColor('#FF0000');

// Change to blue
await this.rgb.setColor('#0000FF');

// Change to purple
await this.rgb.setColor('#FF00FF');

// Change to warm white
await this.rgb.setColor('#FFE4B5');

setEffect() ​

typescript
setEffect(effectName: RGBEffect, speed: number, brightness: number, color: string): Promise

Set a complete RGB lighting effect with all parameters.

Controls the device's 8 RGB LEDs with the specified effect, speed, brightness, and color.

Parameters:

NameTypeRequiredDescription
effectNameRGBEffectYesThe lighting effect to apply
speednumberYesAnimation speed from 1 (fastest) to 100 (slowest)
brightnessnumberYesLED brightness from 0 (off) to 100 (maximum)
colorstringYesColor in hex format (e.g., '#FF0000' for red, '#00FF00' for green)

Returns:

Promise - Promise that resolves when the effect is applied

Example:

typescript
// Set static blue color at medium brightness and speed
await this.rgb.setEffect('static', 50, 75, '#0000FF');

// Set rainbow effect at fast speed and full brightness
await this.rgb.setEffect('rainbow', 10, 100, '#FFFFFF');

// Set breathing effect with purple color (slow)
await this.rgb.setEffect('breathing', 80, 80, '#FF00FF');

// Set candle flicker effect (medium speed)
await this.rgb.setEffect('candle', 50, 70, '#FFA500');

setSpeed() ​

typescript
setSpeed(speed: number): Promise

Update only the animation speed of the current RGB effect.

This is a convenience method that updates speed while keeping the current effect, brightness, and color unchanged.

Parameters:

NameTypeRequiredDescription
speednumberYesAnimation speed from 1 (fastest) to 100 (slowest)

Returns:

Promise - Promise that resolves when the speed is updated

Example:

typescript
// Set to fast animation
await this.rgb.setSpeed(10);

// Set to slow animation
await this.rgb.setSpeed(90);

// Set to medium speed
await this.rgb.setSpeed(50);

turnOff() ​

typescript
turnOff(): Promise

Turn off all RGB lighting.

This is a convenience method that sets the effect to 'off'. Equivalent to calling setEffect('off', 0, 0, '#000000').

Returns:

Promise - Promise that resolves when the lights are turned off

Example:

typescript
// Turn off the RGB lights
await this.rgb.turnOff();

// In an onUnload handler
async onUnload() {
  await this.rgb.turnOff();
  console.log('Plugin unloading, RGB lights turned off');
}