Skip to content

Commit 7070558

Browse files
authored
Merge pull request #148 from Legion2/dev
Version 0.13.0
2 parents a0e5455 + c29c21e commit 7070558

8 files changed

+76
-6
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ Then the third argument of the `scale` function is `144`.
139139
For both functions it's **important**, that the CRGB arrays have at least the length of the physical LED strip.
140140
This means if your LED channel from iCUE has 50 LEDs and you use the `repeat` function to control 100 physical LEDs you MUST declare the CRGB array at least with a length of 100.
141141

142+
## Increase the Brightness of the LEDs
143+
By default iCUE only uses 50% of the LEDs brightness even if you set the brightness to max in the iCUE Device Settings.
144+
But there are good news, we can increase the brightness with the Arduino so we can use the full brightness of our LEDs.
145+
Add the `CLP::fixIcueBrightness` function to the `onUpdateHook` in the setup function as shown in the [example](examples/AdditionalFeatures/AdditionalFeatures.ino).
146+
If there are multiple functions called in `onUpdateHook`, `fixIcueBrightness` should be the first.
147+
```C++
148+
ledController.onUpdateHook(0, []() {
149+
CLP::fixIcueBrightness(&ledController, 0);
150+
});
151+
```
152+
142153
# License
143154
This project is licensed under the Apache 2.0 License.
144155

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

extra/doxygen.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "Corsair Lighting Protocol"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 0.12.0
41+
PROJECT_NUMBER = 0.13.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Corsair Lighting Protocol
2-
version=0.12.0
2+
version=0.13.0
33
author=Leon Kiefer
44
maintainer=Leon Kiefer
55
sentence=Control LED strips via USB from a PC.

src/FastLEDController.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@ void FastLEDController::setLEDColorValues(uint8_t channel, uint8_t color, uint8_
498498
}
499499

500500
void FastLEDController::clearLEDColorValues(uint8_t channel) {
501-
memset(channelData[channel].valuesBuffer[0], 0, channelData[channel].ledCount);
501+
for (uint8_t*& buffer : channelData[channel].valuesBuffer) {
502+
memset(buffer, 0, channelData[channel].ledCount);
503+
}
502504
}
503505

504506
void FastLEDController::timeoutAction() {

src/FastLEDControllerUtils.cpp

Lines changed: 23 additions & 3 deletions
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];
@@ -35,8 +36,14 @@ void CLP::transformLLFanToStrip(FastLEDController* controller, uint8_t channelIn
3536
void CLP::scale(FastLEDController* controller, uint8_t channelIndex, int scaleToSize) {
3637
auto leds = controller->getLEDs(channelIndex);
3738
const float scaleFactor = (float)controller->getLEDCount(channelIndex) / scaleToSize;
38-
for (int ledIndex = scaleToSize - 1; ledIndex >= 0; ledIndex--) {
39-
leds[ledIndex] = leds[lround(ledIndex * scaleFactor)];
39+
if (scaleFactor < 1.0f) {
40+
for (int ledIndex = scaleToSize - 1; ledIndex >= 0; ledIndex--) {
41+
leds[ledIndex] = leds[lround(ledIndex * scaleFactor)];
42+
}
43+
} else {
44+
for (int ledIndex = 0; ledIndex < scaleToSize; ledIndex++) {
45+
leds[ledIndex] = leds[lround(ledIndex * scaleFactor)];
46+
}
4047
}
4148
}
4249

@@ -106,3 +113,16 @@ void CLP::gammaCorrection(FastLEDController* controller, uint8_t channelIndex) {
106113
leds[ledIndex].b = dim8_video(leds[ledIndex].b);
107114
}
108115
}
116+
117+
void CLP::fixIcueBrightness(FastLEDController* controller, uint8_t channelIndex) {
118+
auto& channel = controller->getChannel(channelIndex);
119+
if (channel.mode == ChannelMode::SoftwarePlayback) {
120+
auto leds = controller->getLEDs(channelIndex);
121+
auto count = controller->getLEDCount(channelIndex);
122+
for (int ledIndex = 0; ledIndex < count; ledIndex++) {
123+
leds[ledIndex].r = leds[ledIndex].r * 2;
124+
leds[ledIndex].g = leds[ledIndex].g * 2;
125+
leds[ledIndex].b = leds[ledIndex].b * 2;
126+
}
127+
}
128+
}

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

src/LEDController.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,16 @@ class LEDController : public ILEDController {
220220
*/
221221
virtual void setLEDExternalTemperature(uint8_t channel, uint16_t temp) = 0;
222222
virtual bool setLEDGroup(uint8_t channel, uint8_t groupIndex, LEDGroup& group);
223+
/**
224+
* Set the LED color values for one color-channel (red, green or blue) of the given channel.
225+
*
226+
* @param channel the channel index
227+
* @param color the color index to set the values for red(0), green(1), blue(2)
228+
* @param offset the offset in the LED colors buffer to write to
229+
* @param values the array of values to write
230+
* @param len the length of the array of values to write
231+
* @see clearLEDColorValues()
232+
*/
223233
virtual void setLEDColorValues(uint8_t channel, uint8_t color, uint8_t offset, const uint8_t* values,
224234
size_t len) = 0;
225235
/**
@@ -246,6 +256,12 @@ class LEDController : public ILEDController {
246256
* @return true if the port type was changed
247257
*/
248258
virtual bool setLEDPortType(uint8_t channel, PortType ledPortType);
259+
/**
260+
* Clear the LED color buffer for the given channel.
261+
*
262+
* @param channel the channel index
263+
* @see setLEDColorValues()
264+
*/
249265
virtual void clearLEDColorValues(uint8_t channel) = 0;
250266
virtual bool clearLEDGroups(uint8_t channel);
251267
virtual bool save() = 0;

0 commit comments

Comments
 (0)