Skip to content

Commit ca41ced

Browse files
authored
Merge pull request #183 from Legion2/dev
Version 0.14.2
2 parents bb45884 + 46d70a9 commit ca41ced

File tree

12 files changed

+155
-106
lines changed

12 files changed

+155
-106
lines changed

.github/workflows/lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v2
1111
- name: Check src format
12-
uses: DoozyX/clang-format-lint-action@v0.8
12+
uses: DoozyX/clang-format-lint-action@v0.9
1313
with:
1414
source: './src'
1515
extensions: 'h,cpp'
1616
clangFormatVersion: 9
1717
- name: Check examples format
18-
uses: DoozyX/clang-format-lint-action@v0.8
18+
uses: DoozyX/clang-format-lint-action@v0.9
1919
with:
2020
source: './examples'
2121
extensions: 'h,cpp,ino'

README.md

+18-9
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ _This is not an official corsair project._
1010
## Features
1111
* Add support of Corsair DIY device protocol to Arduino.
1212
* Control LEDs with the [Corsair iCUE software](https://www.corsair.com/icue).
13-
* Easy to use with [FastLED](http://fastled.io/).
14-
* [Supported LED chipsets](https://github.com/FastLED/FastLED/wiki/Overview#chipsets). (e.g. WS2812B, WS2801)
13+
* [Support common LED chipsets](https://github.com/FastLED/FastLED/wiki/Overview#chipsets). (e.g. WS2812B, WS2801)
14+
* Support [FastLED](http://fastled.io/).
1515
* Supported platform: Arduino AVR
16-
* Persistent settings for use without a USB connection.
16+
* Hardware Lighting mode.
1717
* Use multiple devices at the same time.
1818
* Repeat or scale LED channels to arbitrary size.
1919

@@ -91,7 +91,9 @@ Now you can create lighting effects in the "Lighting Channel #" tabs.
9191
- [API Documentation](https://legion2.github.io/CorsairLightingProtocol/)
9292
- [How it works](#how-it-works)
9393
- [Use of multiple devices](#use-of-multiple-devices)
94-
- [Repeat or scale LED channel](#repeat-or-scale-led-channel)
94+
- [Repeat or scale LED channels](#repeat-or-scale-led-channels)
95+
- [Increase the Brightness of the LEDs](#increase-the-brightness-of-the-leds)
96+
- [Hardware Lighting mode](#hardware-lighting-mode)
9597

9698
## How it works
9799
This library uses the USB HID interface of the ATmega32U4.
@@ -128,10 +130,9 @@ Upload the DeviceIDTool sketch and then open the Serial monitor with baudrate 11
128130
The tool displays the current DeviceID, you can type in a new DeviceID that is saved on the Arduino.
129131
After that, you can upload another sketch.
130132

131-
## Repeat or scale LED channel
133+
## Repeat or scale LED channels
132134
You can repeat or scale LED channel controlled by iCUE onto physical LED strips.
133-
This is very useful if you have very long LED strips that are longer than 60/96/135 LEDs.
134-
This is the maximum number iCUE supports.
135+
This is very useful if you have very long LED strips that are longer than 60/96/135 LEDs, which is the maximum number iCUE supports.
135136

136137
To repeat or scale a LED channel you must apply the `CLP::repeat` or the `CLP:scale` function in the update hook of the FastLEDController.
137138
See the [RepeatAndScale](examples/RepeatAndScale/RepeatAndScale.ino) example for the complete code.
@@ -146,16 +147,24 @@ For both functions it's **important**, that the CRGB arrays have at least the le
146147
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.
147148

148149
## Increase the Brightness of the LEDs
149-
By default iCUE only uses 50% of the LEDs brightness even if you set the brightness to max in the iCUE Device Settings.
150+
When using LS100 or LT100 iCUE only uses 50% of the LEDs brightness even if you set the brightness to max in the iCUE Device Settings.
150151
But there are good news, we can increase the brightness with the Arduino so we can use the full brightness of our LEDs.
151-
Add the `CLP::fixIcueBrightness` function to the `onUpdateHook` in the setup function as shown in the [example](examples/AdditionalFeatures/AdditionalFeatures.ino).
152+
Add the `CLP::fixIcueBrightness` function to the `onUpdateHook` in the setup function as shown in the [example](examples/AmbientBacklight/AmbientBacklight.ino).
152153
If there are multiple functions called in `onUpdateHook`, `fixIcueBrightness` should be the first.
154+
Only use this function with LS100 and LT100 devices!
153155
```C++
154156
ledController.onUpdateHook(0, []() {
155157
CLP::fixIcueBrightness(&ledController, 0);
156158
});
157159
```
158160

161+
## Hardware Lighting mode
162+
The [Hardware Lighting mode](https://forum.corsair.com/v3/showthread.php?t=182874) can be configured in iCUE.
163+
It allows you the set lighting effects that will be active when iCUE **is not** running.
164+
This is the case when the PC is off, in sleep mode, booting or the user is logged out.
165+
So if you want to have lighing effects in all these situations, use the Hardware Lighting mode.
166+
If you don't want it, configure a static black color.
167+
159168
# License
160169
This project is licensed under the Apache 2.0 License.
161170

examples/AdditionalFeatures/AdditionalFeatures.ino

+1-6
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,13 @@ void setup() {
4545
FastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 60);
4646
ledController.addLEDs(0, ledsChannel1, 60);
4747
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-
});
5448
}
5549

5650
void loop() {
5751
cHID.update();
5852

5953
if (ledController.updateLEDs()) {
6054
FastLED.show();
55+
CLP::printFps(5000);
6156
}
6257
}

examples/AmbientBacklight/AmbientBacklight.ino

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ void setup() {
3434
ledController.addLEDs(0, ledsChannel1, 84);
3535
ledController.addLEDs(1, ledsChannel2, 105);
3636
ledController.onUpdateHook(0, []() {
37+
// increase the brightness of channel 1 when using iCUE, because iCUE only set brightness to max 50%
38+
CLP::fixIcueBrightness(&ledController, 0);
3739
// gamma correction with gamma value 2.0. Use napplyGamma_video for other gamma values.
3840
CLP::gammaCorrection(&ledController, 0);
3941
// napplyGamma_video(ledsChannel1, 84, 2.2);

examples/DebugSketch/DebugSketch.ino

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ void loop() {
4848
if (ledController.updateLEDs()) {
4949
if (printUpdate) Serial.println(F("updateLEDs"));
5050
FastLED.show();
51+
CLP::printFps(5000);
5152
}
5253

5354
if (Serial.available()) {

examples/UnitTests/UnitTests.ino

+89-73
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ protected:
2828
assertEqual(actual.g, expected.g);
2929
assertEqual(actual.b, expected.b);
3030
}
31+
void assertCRGBArray(const CRGB* const leds, int from, int to, const CRGB& expected) {
32+
for (int i = from; i <= to; i++) {
33+
assertCRGB(leds[i], expected);
34+
}
35+
}
3136
};
3237

3338
test(getLEDs) {
@@ -47,9 +52,7 @@ testF(FastLEDControllerTest, simpleScaleUp) {
4752
fill_solid(leds, 10, CRGB::White);
4853
CLP::scale(&ledController, 0, 20);
4954

50-
for (int i = 0; i < 10; i++) {
51-
assertCRGB(leds[i], CRGB::White);
52-
}
55+
assertCRGBArray(leds, 0, 9, CRGB::White);
5356
}
5457

5558
testF(FastLEDControllerTest, simpleScaleDown) {
@@ -61,12 +64,23 @@ testF(FastLEDControllerTest, simpleScaleDown) {
6164
fill_solid(leds, 10, CRGB::White);
6265
CLP::scale(&ledController, 0, 10);
6366

64-
for (int i = 0; i < 5; i++) {
65-
assertCRGB(leds[i], CRGB::White);
66-
}
67-
for (int i = 5; i < 10; i++) {
68-
assertCRGB(leds[i], CRGB::Black);
69-
}
67+
assertCRGBArray(leds, 0, 4, CRGB::White);
68+
assertCRGBArray(leds, 5, 9, CRGB::Black);
69+
}
70+
71+
testF(FastLEDControllerTest, simpleScaleDownBoundaries) {
72+
CRGB leds[20];
73+
FastLEDController ledController(false);
74+
fill_solid(leds, 20, CRGB::Black);
75+
ledController.addLEDs(0, leds, 20);
76+
77+
leds[0] = CRGB::White;
78+
leds[19] = CRGB::Red;
79+
CLP::scale(&ledController, 0, 5);
80+
81+
assertCRGBArray(leds, 0, 0, CRGB::White);
82+
assertCRGBArray(leds, 1, 3, CRGB::Black);
83+
assertCRGBArray(leds, 4, 4, CRGB::Red);
7084
}
7185

7286
testF(FastLEDControllerTest, simpleScaleIdentity) {
@@ -78,12 +92,20 @@ testF(FastLEDControllerTest, simpleScaleIdentity) {
7892
fill_solid(leds, 10, CRGB::White);
7993
CLP::scale(&ledController, 0, 10);
8094

81-
for (int i = 0; i < 10; i++) {
82-
assertCRGB(leds[i], CRGB::White);
83-
}
84-
for (int i = 10; i < 20; i++) {
85-
assertCRGB(leds[i], CRGB::Black);
86-
}
95+
assertCRGBArray(leds, 0, 9, CRGB::White);
96+
assertCRGBArray(leds, 10, 19, CRGB::Black);
97+
}
98+
99+
testF(FastLEDControllerTest, scaleLongStrip) {
100+
CRGB leds[41];
101+
FastLEDController ledController(false);
102+
fill_solid(leds, 41, CRGB::Black);
103+
ledController.addLEDs(0, leds, 27);
104+
105+
fill_solid(leds, 27, CRGB::White);
106+
CLP::scale(&ledController, 0, 41);
107+
108+
assertCRGBArray(leds, 0, 40, CRGB::White);
87109
}
88110

89111
testF(FastLEDControllerTest, LT100) {
@@ -97,27 +119,21 @@ testF(FastLEDControllerTest, LT100) {
97119
CLP::SegmentScaling segments[2] = {{1, 4}, {26, 26}};
98120
CLP::scaleSegments(&ledController, 0, segments, 2);
99121

100-
for (int i = 0; i < 4; i++) {
101-
assertCRGB(leds[i], CRGB::White);
102-
}
103-
for (int i = 4; i < 30; i++) {
104-
assertCRGB(leds[i], CRGB::Blue);
105-
}
122+
assertCRGBArray(leds, 0, 3, CRGB::White);
123+
assertCRGBArray(leds, 4, 29, CRGB::Blue);
106124
}
107125

108126
testF(FastLEDControllerTest, singleSegmentScaleUp) {
109127
CRGB leds[20];
110128
FastLEDController ledController(false);
111129
fill_solid(leds, 20, CRGB::Black);
112-
ledController.addLEDs(0, leds, 20);
130+
ledController.addLEDs(0, leds, 10);
113131

114132
fill_solid(leds, 10, CRGB::White);
115133
CLP::SegmentScaling segments[] = {{10, 20}};
116134
CLP::scaleSegments(&ledController, 0, segments, 1);
117135

118-
for (int i = 0; i < 20; i++) {
119-
assertCRGB(leds[i], CRGB::White);
120-
}
136+
assertCRGBArray(leds, 0, 19, CRGB::White);
121137
}
122138

123139
testF(FastLEDControllerTest, multiScaleUp) {
@@ -130,12 +146,8 @@ testF(FastLEDControllerTest, multiScaleUp) {
130146
CLP::SegmentScaling segments[] = {{5, 10}, {5, 20}};
131147
CLP::scaleSegments(&ledController, 0, segments, 2);
132148

133-
for (int i = 0; i < 10; i++) {
134-
assertCRGB(leds[i], CRGB::Black);
135-
}
136-
for (int i = 10; i < 30; i++) {
137-
assertCRGB(leds[i], CRGB::White);
138-
}
149+
assertCRGBArray(leds, 0, 9, CRGB::Black);
150+
assertCRGBArray(leds, 10, 29, CRGB::White);
139151
}
140152

141153
testF(FastLEDControllerTest, multiScaleDown) {
@@ -148,12 +160,8 @@ testF(FastLEDControllerTest, multiScaleDown) {
148160
CLP::SegmentScaling segments[] = {{10, 5}, {20, 5}};
149161
CLP::scaleSegments(&ledController, 0, segments, 2);
150162

151-
for (int i = 0; i < 5; i++) {
152-
assertCRGB(leds[i], CRGB::Black);
153-
}
154-
for (int i = 5; i < 10; i++) {
155-
assertCRGB(leds[i], CRGB::White);
156-
}
163+
assertCRGBArray(leds, 0, 4, CRGB::Black);
164+
assertCRGBArray(leds, 5, 9, CRGB::White);
157165
}
158166

159167
testF(FastLEDControllerTest, singleSegmentScaleDown) {
@@ -166,12 +174,8 @@ testF(FastLEDControllerTest, singleSegmentScaleDown) {
166174
CLP::SegmentScaling segments[] = {{20, 10}};
167175
CLP::scaleSegments(&ledController, 0, segments, 1);
168176

169-
for (int i = 0; i < 5; i++) {
170-
assertCRGB(leds[i], CRGB::White);
171-
}
172-
for (int i = 5; i < 10; i++) {
173-
assertCRGB(leds[i], CRGB::Black);
174-
}
177+
assertCRGBArray(leds, 0, 4, CRGB::White);
178+
assertCRGBArray(leds, 5, 9, CRGB::Black);
175179
}
176180

177181
testF(FastLEDControllerTest, SegmentScaleOverlap) {
@@ -184,12 +188,8 @@ testF(FastLEDControllerTest, SegmentScaleOverlap) {
184188
CLP::SegmentScaling segments[] = {{5, 10}, {10, 5}};
185189
CLP::scaleSegments(&ledController, 0, segments, 2);
186190

187-
for (int i = 0; i < 10; i++) {
188-
assertCRGB(leds[i], CRGB::White);
189-
}
190-
for (int i = 10; i < 15; i++) {
191-
assertCRGB(leds[i], CRGB::Black);
192-
}
191+
assertCRGBArray(leds, 0, 9, CRGB::White);
192+
assertCRGBArray(leds, 10, 14, CRGB::Black);
193193
}
194194

195195
testF(FastLEDControllerTest, SegmentScaleOverlapInverted) {
@@ -202,12 +202,8 @@ testF(FastLEDControllerTest, SegmentScaleOverlapInverted) {
202202
CLP::SegmentScaling segments[] = {{10, 5}, {5, 10}};
203203
CLP::scaleSegments(&ledController, 0, segments, 2);
204204

205-
for (int i = 0; i < 5; i++) {
206-
assertCRGB(leds[i], CRGB::White);
207-
}
208-
for (int i = 5; i < 15; i++) {
209-
assertCRGB(leds[i], CRGB::Black);
210-
}
205+
assertCRGBArray(leds, 0, 4, CRGB::White);
206+
assertCRGBArray(leds, 5, 14, CRGB::Black);
211207
}
212208

213209
testF(FastLEDControllerTest, SegmentScaleMix) {
@@ -222,15 +218,9 @@ testF(FastLEDControllerTest, SegmentScaleMix) {
222218
CLP::SegmentScaling segments[] = {{5, 10}, {20, 5}, {5, 10}};
223219
CLP::scaleSegments(&ledController, 0, segments, 3);
224220

225-
for (int i = 0; i < 10; i++) {
226-
assertCRGB(leds[i], CRGB::White);
227-
}
228-
for (int i = 10; i < 15; i++) {
229-
assertCRGB(leds[i], CRGB::Red);
230-
}
231-
for (int i = 15; i < 25; i++) {
232-
assertCRGB(leds[i], CRGB::Blue);
233-
}
221+
assertCRGBArray(leds, 0, 9, CRGB::White);
222+
assertCRGBArray(leds, 10, 14, CRGB::Red);
223+
assertCRGBArray(leds, 15, 24, CRGB::Blue);
234224
}
235225

236226
testF(FastLEDControllerTest, SegmentScaleMixInverted) {
@@ -245,15 +235,41 @@ testF(FastLEDControllerTest, SegmentScaleMixInverted) {
245235
CLP::SegmentScaling segments[] = {{10, 5}, {5, 20}, {10, 5}};
246236
CLP::scaleSegments(&ledController, 0, segments, 3);
247237

248-
for (int i = 0; i < 5; i++) {
249-
assertCRGB(leds[i], CRGB::White);
250-
}
251-
for (int i = 5; i < 25; i++) {
252-
assertCRGB(leds[i], CRGB::Red);
253-
}
254-
for (int i = 25; i < 30; i++) {
255-
assertCRGB(leds[i], CRGB::Blue);
256-
}
238+
assertCRGBArray(leds, 0, 4, CRGB::White);
239+
assertCRGBArray(leds, 5, 24, CRGB::Red);
240+
assertCRGBArray(leds, 25, 29, CRGB::Blue);
241+
}
242+
243+
testF(FastLEDControllerTest, SegmentScaleMonitor) {
244+
CRGB leds[130];
245+
FastLEDController ledController(false);
246+
fill_solid(leds, 130, CRGB::Black);
247+
ledController.addLEDs(0, leds, 84);
248+
249+
fill_solid(leds, 15, CRGB::White);
250+
fill_solid(leds + 15, 27, CRGB::Red);
251+
fill_solid(leds + 42, 15, CRGB::Blue);
252+
fill_solid(leds + 57, 27, CRGB::Green);
253+
CLP::SegmentScaling segments[] = {{15, 24}, {27, 41}, {15, 24}, {27, 41}};
254+
CLP::scaleSegments(&ledController, 0, segments, 4);
255+
256+
assertCRGBArray(leds, 0, 23, CRGB::White);
257+
assertCRGBArray(leds, 24, 64, CRGB::Red);
258+
assertCRGBArray(leds, 65, 88, CRGB::Blue);
259+
assertCRGBArray(leds, 89, 129, CRGB::Green);
260+
}
261+
262+
testF(FastLEDControllerTest, SegmentScaleLongStrip) {
263+
CRGB leds[41];
264+
FastLEDController ledController(false);
265+
fill_solid(leds, 41, CRGB::Black);
266+
ledController.addLEDs(0, leds, 27);
267+
268+
fill_solid(leds, 27, CRGB::White);
269+
CLP::SegmentScaling segments[] = {{27, 41}};
270+
CLP::scaleSegments(&ledController, 0, segments, 1);
271+
272+
assertCRGBArray(leds, 0, 40, CRGB::White);
257273
}
258274

259275
void setup() {

extra/doxygen.conf

+1-1
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.14.1
41+
PROJECT_NUMBER = 0.14.2
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Corsair Lighting Protocol
2-
version=0.14.1
2+
version=0.14.2
33
author=Leon Kiefer
44
maintainer=Leon Kiefer
55
sentence=Control LED strips via USB from a PC.

0 commit comments

Comments
 (0)