Corsair Lighting Protocol
0.15.0
Control LEDs connected to an Arduino with iCUE
|
#include <FastLEDController.h>
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 LEDChannel & | getChannel (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 |
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.
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.
storage | specify the storage which should be used, e.g. EEPROM |
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
. 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.
temperatureController | used for temperature based lighting |
storage | specify the storage which should be used, e.g. EEPROM |
|
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.
channel | the index of the channel |
leds | the array to store the LED data in |
length | the length of the array used by iCUE to write LED data |
|
protected |
Calculates the index of the current step of the animation.
duration | the duration on the animation |
steps | the number of steps of the animation |
|
protected |
Calculates the number of steps of the animation, since the last update of the animation.
duration | the duration on the animation |
steps | the number of steps of the animation |
|
overrideprotectedvirtual |
Clear the LED color buffer for the given channel.
channel | the channel index |
Implements LEDController.
|
overrideprotectedvirtual |
Get the result of the LED number autodetection on the given channel. Potential values for LT100: 27, 54, 81, 108
channel | the channel index |
Implements LEDController.
uint8_t FastLEDController::getLEDCount | ( | uint8_t | channel | ) |
Get the length of the LED data array.
channel | the index of the channel |
CRGB * FastLEDController::getLEDs | ( | uint8_t | channel | ) |
Get the LED data array for a channel.
channel | the index of the channel |
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.
channel | the channel for which the hook is registered |
callback | the callback, which is executed after the update |
|
protected |
Generate a rainbow random color from predefined color palette.
|
overrideprotectedvirtual |
Set the LED color values for one color-channel (red, green or blue) of the given channel.
channel | the channel index |
color | the color index to set the values for red(0), green(1), blue(2) |
offset | the offset in the LED colors buffer to write to |
values | the array of values to write |
len | the length of the array of values to write |
Implements LEDController.
|
overrideprotectedvirtual |
Set the external temperature for a channel.
channel | the channel index |
temp | the temperature in hundredths of a degree Celsius. |
Implements LEDController.
|
protectedvirtual |
This function is called when a timeout occurs.
|
overrideprotectedvirtual |
Trigger update of the LEDs
Implements LEDController.
|
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
. This function must be called in loop.