Skip to content

Commit 445d5bc

Browse files
committed
added fixIcueBrightness util function close #142
1 parent 65c552b commit 445d5bc

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

examples/AdditionalFeatures/AdditionalFeatures.ino

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,35 @@
2222
CRGB ledsChannel1[60];
2323
CRGB ledsChannel2[60];
2424

25+
// Define a custom SerialNumber for the device
2526
const char mySerialNumber[] PROGMEM = "202B6949A967";
2627

2728
CorsairLightingFirmware firmware = corsairLightingNodePROFirmware();
2829
FastLEDController ledController(true);
2930
CorsairLightingProtocolController cLP(&ledController, &firmware);
31+
// Set the SerialNumber here
3032
CorsairLightingProtocolHID cHID(&cLP, mySerialNumber);
3133

3234
void setup() {
35+
// Disable the build in RX and TX LEDs of the Arduino
3336
CLP::disableBuildInLEDs();
37+
// enable reset on DeviceId (FF FF FF FF)
3438
if (CLP::shouldReset(&firmware)) {
39+
// reset DeviceId and generate new one
3540
CLP::reset(&firmware);
41+
// reset the LEDController Settings
3642
ledController.reset();
3743
}
3844
FastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 60);
3945
FastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 60);
4046
ledController.addLEDs(0, ledsChannel1, 60);
4147
ledController.addLEDs(1, ledsChannel2, 60);
48+
49+
// modify the RGB values before they are shown on the LED strip
50+
ledController.onUpdateHook(0, []() {
51+
// increase the brightness of channel 1 when using iCUE, because iCUE only set brightness to max 50%
52+
CLP::fixIcueBrightness(&ledController, 0);
53+
});
4254
}
4355

4456
void loop() {

src/FastLEDControllerUtils.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ void CLP::transformLLFanToStrip(FastLEDController* controller, uint8_t channelIn
2222
auto& channel = controller->getChannel(channelIndex);
2323
if (channel.mode == ChannelMode::SoftwarePlayback) {
2424
auto leds = controller->getLEDs(channelIndex);
25-
for (uint8_t fanIndex = 0; fanIndex < controller->getLEDCount(channelIndex) / 16; fanIndex++) {
25+
auto count = controller->getLEDCount(channelIndex);
26+
for (uint8_t fanIndex = 0; fanIndex < count / 16; fanIndex++) {
2627
for (uint8_t ledIndex = 0; ledIndex < 8; ledIndex++) {
2728
CRGB temp = leds[fanIndex * 16 + ledIndex];
2829
leds[fanIndex * 16 + ledIndex] = leds[fanIndex * 16 + 15 - ledIndex];
@@ -106,3 +107,16 @@ void CLP::gammaCorrection(FastLEDController* controller, uint8_t channelIndex) {
106107
leds[ledIndex].b = dim8_video(leds[ledIndex].b);
107108
}
108109
}
110+
111+
void CLP::fixIcueBrightness(FastLEDController* controller, uint8_t channelIndex) {
112+
auto& channel = controller->getChannel(channelIndex);
113+
if (channel.mode == ChannelMode::SoftwarePlayback) {
114+
auto leds = controller->getLEDs(channelIndex);
115+
auto count = controller->getLEDCount(channelIndex);
116+
for (int ledIndex = 0; ledIndex < count; ledIndex++) {
117+
leds[ledIndex].r = leds[ledIndex].r * 2;
118+
leds[ledIndex].g = leds[ledIndex].g * 2;
119+
leds[ledIndex].b = leds[ledIndex].b * 2;
120+
}
121+
}
122+
}

src/FastLEDControllerUtils.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,13 @@ void reverse(FastLEDController* controller, uint8_t channelIndex);
8989
* @param channelIndex the index of the channel
9090
*/
9191
void gammaCorrection(FastLEDController* controller, uint8_t channelIndex);
92+
93+
/**
94+
* Increase the brightness of a LED channel when using iCUE Software lighting, because iCUE only send the RGB value in
95+
* the range (0 - 127) which is only 50% of max possible brightness. This function doubles the received RGB value.
96+
*
97+
* @param controller the FastLEDController controlling the LEDs
98+
* @param channelIndex the index of the channel
99+
*/
100+
void fixIcueBrightness(FastLEDController* controller, uint8_t channelIndex);
92101
} // namespace CLP

0 commit comments

Comments
 (0)