Corsair Lighting Protocol  0.15.0
Control LEDs connected to an Arduino with iCUE
LEDController Class Referenceabstract

#include <LEDController.h>

+ Inheritance diagram for LEDController:
+ Collaboration diagram for LEDController:

Public Member Functions

virtual void handleLEDControl (const Command &command, const CorsairLightingProtocolResponse *response) override
 
virtual bool isValidLEDChannel (const LEDChannel &ledChannel)
 
virtual bool isValidLEDGroup (const LEDGroup &ledGroup)
 
const LEDChannelgetChannel (uint8_t channelIndex)
 
virtual void reset ()
 

Protected Member Functions

virtual void triggerLEDUpdate ()=0
 
virtual uint8_t getLEDStripMask (uint8_t channel, uint8_t group)
 
virtual void setLEDExternalTemperature (uint8_t channel, uint16_t temp)=0
 
virtual bool setLEDGroup (uint8_t channel, uint8_t groupIndex, LEDGroup &group)
 
virtual void setLEDColorValues (uint8_t channel, uint8_t color, uint8_t offset, const uint8_t *values, size_t len)=0
 
virtual bool setLEDMode (uint8_t channel, ChannelMode mode)
 
virtual bool setLEDBrightness (uint8_t channel, uint8_t brightness)
 
virtual bool setLEDPortType (uint8_t channel, PortType ledPortType)
 
virtual void clearLEDColorValues (uint8_t channel)=0
 
virtual bool clearLEDGroups (uint8_t channel)
 
virtual void startLEDAutodetection (uint8_t channel)
 
virtual uint8_t getLEDAutodetectionResult (uint8_t channel)=0
 
virtual bool save ()=0
 
virtual bool load ()=0
 
bool saveIfNeeded ()
 

Protected Attributes

LEDChannel channels [CHANNEL_NUM]
 
bool triggerSave = false
 
unsigned long lastCommand = 0
 

Detailed Description

The abstract implemenation of an LEDController. This implementation handles the parsing and interpretation of incoming commands. It also defines the data model to store the all required data from the commands.

Member Function Documentation

◆ clearLEDColorValues()

virtual void LEDController::clearLEDColorValues ( uint8_t  channel)
protectedpure virtual

Clear the LED color buffer for the given channel.

Parameters
channelthe channel index
See also
setLEDColorValues()

Implemented in FastLEDController.

◆ getChannel()

const LEDChannel & LEDController::getChannel ( uint8_t  channelIndex)

Get the data of a Channel from this LEDController.

Parameters
channelIndexthe index of the channel
Returns
a reference to the LEDChannel

◆ getLEDAutodetectionResult()

virtual uint8_t LEDController::getLEDAutodetectionResult ( uint8_t  channel)
protectedpure virtual

Get the result of the LED number autodetection on the given channel. Potential values for LT100: 27, 54, 81, 108

Parameters
channelthe channel index
Returns
the number of LEDs currently connected to the channel
See also
startLEDAutodetection()

Implemented in FastLEDController.

◆ getLEDStripMask()

uint8_t LEDController::getLEDStripMask ( uint8_t  channel,
uint8_t  group 
)
protectedvirtual

Get the LED count of the group.

Parameters
channelthe channel index
groupthe group index
Returns
the number of LEDs in the group

◆ handleLEDControl()

void LEDController::handleLEDControl ( const Command command,
const CorsairLightingProtocolResponse response 
)
overridevirtual

Handle LED commands and send a response. This method is called for each received command.

Parameters
commandthe command which must be handled
responsethe callback for the response

Implements ILEDController.

◆ isValidLEDChannel()

bool LEDController::isValidLEDChannel ( const LEDChannel ledChannel)
virtual

Validates a LEDChannel by checking all constrains on the values. This function should be used after non type-safe operations on a LEDChannel.

Parameters
ledChannelthe LEDChannel to validate
Returns
true if the LEDChannel is valid, false otherwise

◆ isValidLEDGroup()

bool LEDController::isValidLEDGroup ( const LEDGroup ledGroup)
virtual

Validates a LEDGroup by checking all constrains on the values. This function should be used after non type-safe operations on a LEDGroup.

Parameters
ledGroupthe LEDGroup to validate
Returns
true if the LEDGroup is valid, false otherwise

◆ reset()

void LEDController::reset ( )
virtual

Reset all persistent data to default values of the LEDController.

◆ saveIfNeeded()

bool LEDController::saveIfNeeded ( )
protected

Save if triggerSave is true and then reset triggerSave.

◆ setLEDBrightness()

bool LEDController::setLEDBrightness ( uint8_t  channel,
uint8_t  brightness 
)
protectedvirtual

The brightness of the channel. This only applies to HW lighting.

Parameters
channelthe channel index
brightnessthe brightness in the range 0-255
Returns
true if the brightness was changed

◆ setLEDColorValues()

virtual void LEDController::setLEDColorValues ( uint8_t  channel,
uint8_t  color,
uint8_t  offset,
const uint8_t *  values,
size_t  len 
)
protectedpure virtual

Set the LED color values for one color-channel (red, green or blue) of the given channel.

Parameters
channelthe channel index
colorthe color index to set the values for red(0), green(1), blue(2)
offsetthe offset in the LED colors buffer to write to
valuesthe array of values to write
lenthe length of the array of values to write
See also
clearLEDColorValues()

Implemented in FastLEDController.

◆ setLEDExternalTemperature()

virtual void LEDController::setLEDExternalTemperature ( uint8_t  channel,
uint16_t  temp 
)
protectedpure virtual

Set the external temperature for a channel.

Parameters
channelthe channel index
tempthe temperature in hundredths of a degree Celsius.

Implemented in FastLEDController.

◆ setLEDMode()

bool LEDController::setLEDMode ( uint8_t  channel,
ChannelMode  mode 
)
protectedvirtual

Set the Channel mode.

Parameters
channelthe channel index
modethe new mode
Returns
true if the mode was changed, false otherwise

◆ setLEDPortType()

bool LEDController::setLEDPortType ( uint8_t  channel,
PortType  ledPortType 
)
protectedvirtual

Set the type of LED chipset: WS2812B or UCS1903

Parameters
channelthe channel index
ledPortTypethe port type
Returns
true if the port type was changed

◆ startLEDAutodetection()

void LEDController::startLEDAutodetection ( uint8_t  channel)
protectedvirtual

Start the potentially long running process to detect the current number of LEDs connected to given channel.

Parameters
channelthe channel index
See also
getLEDAutodetectionResult()

◆ triggerLEDUpdate()

virtual void LEDController::triggerLEDUpdate ( )
protectedpure virtual

Trigger update of the LEDs

Implemented in FastLEDController.

Member Data Documentation

◆ lastCommand

unsigned long LEDController::lastCommand = 0
protected

Stores the time at which the last command was received by the LEDController.

◆ triggerSave

bool LEDController::triggerSave = false
protected

Indicates that the configuration of the channels has been changed and should be saved.


The documentation for this class was generated from the following files: