Component Functions

Device Functions

These functions are to set up the device to be compatible with the Component System

device.SetLedLimit()

This function takes an int value and sets the upper LED limit for all component Channels on the device. It's used for safety checks in the backend and to prevent users from overloading their devices with more power draw than it can take. It should be set to the same max value that the manufacturing company limits the device to.

Parameter

Description

Type

Example

LedLimit

The desired LED limit for all channels on the device

Int

80

const DeviceMaxLedLimit = 233; device.SetLedLimit(DeviceMaxLedLimit);

device.getLedCount()

This function will return the current combined led count of all components on all channels of the device. The primary use for this will be to check if there are any components selected as 0 LED's is the same as 0 Components.

Return

Description

Type

Example

LedCount

The current led count of all channels

Int

64

let ColorData = [] if(LightingMode == "Forced"){ // do stuff }else if(device.getLedCount() == 0){ // do stuff }else{ // do stuff }

device.addChannel()

This function will add a new Component Channel to the device. When the first channel is added the Component Configuration UI will appear on the device page. This function takes an optional but recommended LedLimit to warn the user about going over the safe led limits of the device. This limit is used in multiple places so it is highly recommended to set it.

Parameter

Description

Type

Example

ChannelName

The ChannelName that will be used to reference this channel

String

"Channel 1"

LedLimit

The Channels Safe operating Led Limit.

Int

204

//Channel Name, Led Limit var ChannelArray = [ ["Channel 1", 204], ["Channel 2", 204], ] function SetupChannels(){ device.SetLedLimit(DeviceMaxLedLimit); for(let i = 0; i < ChannelArray.length; i++){ device.addChannel(ChannelArray[i][0],ChannelArray[i][1]); } }

device.removeChannel()

This function will remove a channel from the device. Under normal circumstances, this function should not be needed as channels will be cleaned up when SignalRGB shuts down. But as the channels persist between hot reloads of the plugin file you may want to clear them in the initialize function if your experiencing issues while developing the plugin.

Parameter

Description

Type

Example

ChannelName

The ChannelName to be removed

String

"Channel 1"

device.createChannel("Channel1") // Do stuff device.removeChannel("Channel1")

device.getChannelNames()

This function will return the names of all channels currently on the device. The primary use here will be for debug use as Channel Names should be stored within the plugin's logic with the index of the channel for the device's packets. It can however be used to iterate over all channels on the device if desired for a minor performance loss.

return

Description

Type

Example

Channel Names

A list of all Channel names on the device

1D Array

["Channel 1","Channel 2"]

let channels = device.getChannelNames();

device.channel()

This is your gateway into interacting with ComponentChannels. It will return a reference to the ComponentChannel itself if one matches the ChannelName given, if ones doesn't exist it will return null.

Do not store ComponentChannel references past the functions lifetime.

These references are not guaranteed to stay valid and you should instead fetch a new reference each render cycle.

Parameter

Description

Type

Example

ChannelName

The ChannelName to grab a reference to

String

"Channel 1"

return

Description

Type

ComponentChannel

ComponentChannel Object

ComponentChannel | Null

let components = device.channel("Channel 1").getComponentNames();

ComponentChannel

These functions are used to control and interact with a specific ComponentChannel reference.

channel.SetLedLimit()

Like the similar device.ledLimit() function this one will set the max safe led limit for this ComponentChannel.

Parameter

Description

Type

Example

LedLimit

The desired Led Limit for the Channel

Int

16

device.channel("Channel 1").SetLedLimit(204);

channel.LedCount()

This will return the number of Leds configured by the user on this ComponentChannel

Return

Description

Type

Example

LedCount

The current Led Count of the Channel

Int

16

let ChannelLedCount = device.channel("Channel 1").LedCount();

channel.getColors()

This function will return an array of RGB color data based on the devices led map and coordinates. The return value for this function depends greatly on setting the correct arguments.

Parameters

Description

Type

Example

Default

ArrayOrder

The desired array format

String

"Inline"

"Seperate"

ColorOrder

The desired Color order

String

"RGB"

"RGB"

Array Order

Description

Type

Example

Inline

Formats the color data into a flat array in order

1D Array

[R,G,B,R,G,B]

Seperate

Formats the color data into 3 distinct channels

2D Array

[[R,R], [G,G], [B,B]]

Note: ColorOrder only takes effect with the Inline ArrayOrder option.

ColorOrder is a 3 letter combination of "RGB". i,e "BGR", "GBR","RBG". And determines the order of colors when using the Inline ArrayOrder. Invalid values will default back to "RGB".

Return

Description

Type

Example

RGB Data

The returned RGB color data in the format desired

Array

See Array Order Table

RGBData = device.channel("Channel 1").getColors("Inline", "GRB");

channel.shouldPulseColors()

this function returns a boolean on if this device channel should be 'pulsing'. This can be requested due to no Components being selected, or if the onboarding Component Setup UI is being shown.

device.getChannelPulseColor() can be used to get the expected pulse color.

Return

Type

Description

ShouldPulse

boolean

Should this channel be pulsing

channel.getComponent()

channel.getComponentColors()

channel.getComponentNames()

channel.getComponentData()

channel.getComponentColors()

Util Functions

device.getChannelPulseColor()

device.createColorArray()