Corsair Lighting Protocol  0.15.0
Control LEDs connected to an Arduino with iCUE
FastLEDController Class Reference

#include <FastLEDController.h>

+ Inheritance diagram for FastLEDController:
+ Collaboration diagram for FastLEDController:

Public Member Functions

 FastLEDController (FastLEDControllerStorage *storage)
 
 FastLEDController (TemperatureController *temperatureController, FastLEDControllerStorage *storage)
 
virtual void addLEDs (uint8_t channel, CRGB *leds, uint8_t length)
 
CRGB * getLEDs (uint8_t channel)
 
uint8_t getLEDCount (uint8_t channel)
 
virtual bool updateLEDs ()
 
void onUpdateHook (uint8_t channel, void(*callback)(void))
 
- Public Member Functions inherited from LEDController
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

int applySpeed (int duration, const GroupSpeed speed)
 
int animation_step (int duration, int steps)
 
int animation_step_count (int duration, int steps)
 
CRGB randomColor ()
 
bool renderRainbowWave (ChannelData &channelData, LEDGroup &group, int groupLedCount)
 
bool renderColorShift (ChannelData &channelData, LEDGroup &group, int groupLedCount)
 
bool renderColorPulse (ChannelData &channelData, LEDGroup &group, int groupLedCount)
 
bool renderColorWave (ChannelData &channelData, LEDGroup &group, int groupLedCount)
 
bool renderStatic (ChannelData &channelData, LEDGroup &group, int groupLedCount)
 
bool renderTemperature (ChannelData &channelData, LEDGroup &group, int groupLedCount)
 
bool renderVisor (ChannelData &channelData, LEDGroup &group, int groupLedCount)
 
bool renderMarquee (ChannelData &channelData, LEDGroup &group, int groupLedCount)
 
bool renderBlink (ChannelData &channelData, LEDGroup &group, int groupLedCount)
 
bool renderSequential (ChannelData &channelData, LEDGroup &group, int groupLedCount)
 
bool renderRainbow (ChannelData &channelData, LEDGroup &group, int groupLedCount)
 
bool load () override
 
bool save () override
 
virtual void triggerLEDUpdate () override
 
virtual void setLEDExternalTemperature (uint8_t channel, uint16_t temp) override
 
virtual void setLEDColorValues (uint8_t channel, uint8_t color, uint8_t offset, const uint8_t *values, size_t len) override
 
virtual void clearLEDColorValues (uint8_t channel) override
 
virtual uint8_t getLEDAutodetectionResult (uint8_t channel) override
 
virtual void timeoutAction ()
 
- Protected Member Functions inherited from LEDController
virtual uint8_t getLEDStripMask (uint8_t channel, uint8_t group)
 
virtual bool setLEDGroup (uint8_t channel, uint8_t groupIndex, LEDGroup &group)
 
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 bool clearLEDGroups (uint8_t channel)
 
virtual void startLEDAutodetection (uint8_t channel)
 
bool saveIfNeeded ()
 

Protected Attributes

TemperatureController *const temperatureController
 
FastLEDControllerStorage *const storage
 
bool trigger_update = false
 
ChannelData channelData [CHANNEL_NUM]
 
unsigned long lastUpdate = 0
 
unsigned long currentUpdate = 0
 
- Protected Attributes inherited from LEDController
LEDChannel channels [CHANNEL_NUM]
 
bool triggerSave = false
 
unsigned long lastCommand = 0
 

Detailed Description

The default LEDController. This controller uses the FastLED library to implement the Hardware Lighting effects. Also all RGB values of the LEDs are stored into CRGB arrays which can be used by the FastLED library to show them on the real LED strips. This controller can stores the internal state to EEPROM and support HW playback without USB connection.

See also
FastLED

Constructor & Destructor Documentation

◆ FastLEDController() [1/2]

FastLEDController::FastLEDController ( FastLEDControllerStorage storage)

Create a new FastLEDController and specify which storage should be used. The EEPROM of the Arduino can be used as Storage. See the other contructor for more details.

Parameters
storagespecify the storage which should be used, e.g. EEPROM

◆ FastLEDController() [2/2]

FastLEDController::FastLEDController ( TemperatureController temperatureController,
FastLEDControllerStorage storage 
)

Create a new FastLEDController and specify which storage should be used. If the EEPROM of the Arduino should be used to store persistent information like the Hardware Lighting use

Definition: FastLEDControllerStorageEEPROM.h:26

. If enabled, the hardware lighting configured in iCUE works without a USB connection and even after a restart of the Arduino. Also the the TemperatureController used for temperature related lighting can be passed here.

Parameters
temperatureControllerused for temperature based lighting
storagespecify the storage which should be used, e.g. EEPROM

Member Function Documentation

◆ addLEDs()

void FastLEDController::addLEDs ( uint8_t  channel,
CRGB *  leds,
uint8_t  length 
)
virtual

Add a LED array on a channel with a given length. The length define how many LEDs iCUE can control. The actual length of the array can be longer, but iCUE only writes up to the specified length.

Parameters
channelthe index of the channel
ledsthe array to store the LED data in
lengththe length of the array used by iCUE to write LED data

◆ animation_step()

int FastLEDController::animation_step ( int  duration,
int  steps 
)
protected

Calculates the index of the current step of the animation.

Parameters
durationthe duration on the animation
stepsthe number of steps of the animation
Returns
the current step of the animation

◆ animation_step_count()

int FastLEDController::animation_step_count ( int  duration,
int  steps 
)
protected

Calculates the number of steps of the animation, since the last update of the animation.

Parameters
durationthe duration on the animation
stepsthe number of steps of the animation
Returns
the number of steps since the last update

◆ clearLEDColorValues()

void FastLEDController::clearLEDColorValues ( uint8_t  channel)
overrideprotectedvirtual

Clear the LED color buffer for the given channel.

Parameters
channelthe channel index
See also
setLEDColorValues()

Implements LEDController.

◆ getLEDAutodetectionResult()

uint8_t FastLEDController::getLEDAutodetectionResult ( uint8_t  channel)
overrideprotectedvirtual

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()

Implements LEDController.

◆ getLEDCount()

uint8_t FastLEDController::getLEDCount ( uint8_t  channel)

Get the length of the LED data array.

Parameters
channelthe index of the channel
Returns
the length of the array
See also
getLEDs()

◆ getLEDs()

CRGB * FastLEDController::getLEDs ( uint8_t  channel)

Get the LED data array for a channel.

Parameters
channelthe index of the channel
Returns
the pointer to the LED array or nullptr if there is no array
See also
getLEDCount()

◆ onUpdateHook()

void FastLEDController::onUpdateHook ( uint8_t  channel,
void(*)(void)  callback 
)

Register an update hook, which is executed after a channel has been updated. This can be used to apply transforamtions to the channel before the data is displayed by FastLED.

Parameters
channelthe channel for which the hook is registered
callbackthe callback, which is executed after the update

◆ randomColor()

CRGB FastLEDController::randomColor ( )
protected

Generate a rainbow random color from predefined color palette.

Returns
a random color

◆ setLEDColorValues()

void FastLEDController::setLEDColorValues ( uint8_t  channel,
uint8_t  color,
uint8_t  offset,
const uint8_t *  values,
size_t  len 
)
overrideprotectedvirtual

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()

Implements LEDController.

◆ setLEDExternalTemperature()

void FastLEDController::setLEDExternalTemperature ( uint8_t  channel,
uint16_t  temp 
)
overrideprotectedvirtual

Set the external temperature for a channel.

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

Implements LEDController.

◆ timeoutAction()

void FastLEDController::timeoutAction ( )
protectedvirtual

This function is called when a timeout occurs.

◆ triggerLEDUpdate()

void FastLEDController::triggerLEDUpdate ( )
overrideprotectedvirtual

Trigger update of the LEDs

Implements LEDController.

◆ updateLEDs()

bool FastLEDController::updateLEDs ( )
virtual

Update the displayed RGB values for the LEDs. This will write to the LED data array of each Channel. This method does not call

FastLED.show()

. This function must be called in loop.

Returns
true if the LED data of a channel was updated, false otherwise

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