Skip to content

Commit bb45884

Browse files
authored
Merge pull request #166 from Legion2/dev
Version 0.14.1
2 parents 6187d2e + 7ad904d commit bb45884

File tree

11 files changed

+337
-17
lines changed

11 files changed

+337
-17
lines changed

.github/CONTRIBUTING.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# How to contribute
2+
3+
You can contribute in many different ways, for example report a bug or come up with an idea for improvement.
4+
If you are good at programming you could also provide a fix for bugs or Pull Requests with improvements.
5+
If you want to help others using CLP you are welcome to extend the [Wiki on GitHub](https://github.com/Legion2/CorsairLightingProtocol/wiki).
6+
7+
## Finding information
8+
9+
General information can be found in the [Readme](https://github.com/Legion2/CorsairLightingProtocol) file at the root of the project.
10+
Information about specific topics are written in the [Wiki](https://github.com/Legion2/CorsairLightingProtocol/wiki).
11+
For developer there is also an [API documentation](https://legion2.github.io/CorsairLightingProtocol/) for all the public methods and types.
12+
13+
## Writing code
14+
15+
For writing code I recommend [VS Code](https://code.visualstudio.com/) with the [Clang-Format](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format) and [C/C++](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) extensions.
16+
For uploading to Arduino boards I use the ArduinoIDE.
17+
18+
This project consists of two major parts, the CLP library itself, for which the source code can be found in `src/` directory and the example sketches in the `examples/` subdirectories.
19+
The main logic for processing commands and creating the LED colors is part of the library source code.
20+
The examples only show how to use the library and what can be configured.
21+
The library is modular so communication with iCUE and the processing of commands is decoupled and can be extended by other developers.
22+
Single parts of the library, such as the LEDController can also be used without iCUE, by just calling the public API of these classes.
23+
24+
The examples are used by most users as a template which they only modified slightly, so the basic examples should be simple and explicitly show the main configuration options.
25+
Not all users are developers and may not understand the syntax or semantics of the code, they just alter some values and upload the sketches.
26+
Examples can also be used to show how some additional or special features can be used, these sketches are not meant to be used by the users directly.
27+
To verify that the library can be compiled on all supported platforms, all the examples are compiled in the CI pipeline for different boards.
28+
29+
## Coding conventions
30+
31+
Public methods must be documented with JavaDoc style comments.
32+
When introducing new methods you should think about if the method should be part of the public API or only used internally.
33+
Always use descriptive names for variables, only use acronyms if they are well known and frequently used.
34+
The coding style is defined using ClangFormat and automatically checked when you submit a Pull Request.

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/documentation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v1
13+
- uses: actions/checkout@v2
1414
- name: Install doxygen
1515
run: sudo apt install doxygen graphviz
1616
- name: Fix Readme title

.github/workflows/lint.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v1
10+
- uses: actions/checkout@v2
1111
- name: Check src format
12-
uses: DoozyX/clang-format-lint-action@v0.5
12+
uses: DoozyX/clang-format-lint-action@v0.8
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.5
18+
uses: DoozyX/clang-format-lint-action@v0.8
1919
with:
2020
source: './examples'
2121
extensions: 'h,cpp,ino'

.github/workflows/push.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
"Legion2:avr:promicro3vclp",
1414
]
1515
steps:
16-
- uses: actions/checkout@master
16+
- uses: actions/checkout@v2
1717
- name: Build for ${{ matrix.board }}
18-
uses: ArminJo/arduino-test-compile@v2.0.0
18+
uses: ArminJo/arduino-test-compile@v2.6.0
1919
with:
2020
arduino-board-fqbn: ${{ matrix.board }}
2121
platform-url: https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json,https://raw.githubusercontent.com/Legion2/CorsairLightingProtocolBoards/master/package_Legion2_CorsairLightingProtocolBoards_index.json
@@ -43,9 +43,9 @@ jobs:
4343
matrix:
4444
board: ["arduino:avr:uno", "arduino:avr:mega:cpu=atmega2560"]
4545
steps:
46-
- uses: actions/checkout@master
46+
- uses: actions/checkout@v2
4747
- name: Build for ${{ matrix.board }}
48-
uses: ArminJo/arduino-test-compile@v2.0.0
48+
uses: ArminJo/arduino-test-compile@v2.6.0
4949
with:
5050
arduino-board-fqbn: ${{ matrix.board }}
5151
arduino-platform: arduino:[email protected]
@@ -58,9 +58,9 @@ jobs:
5858
matrix:
5959
board: ["Legion2:avr:HoodLoader2atmega16u2clp"]
6060
steps:
61-
- uses: actions/checkout@master
61+
- uses: actions/checkout@v2
6262
- name: Build for ${{ matrix.board }}
63-
uses: ArminJo/arduino-test-compile@v2.0.0
63+
uses: ArminJo/arduino-test-compile@v2.6.0
6464
with:
6565
arduino-board-fqbn: ${{ matrix.board }}
6666
platform-url: https://raw.githubusercontent.com/NicoHood/HoodLoader2/master/package_NicoHood_HoodLoader2_index.json,https://raw.githubusercontent.com/Legion2/CorsairLightingProtocolBoards/master/package_Legion2_CorsairLightingProtocolBoards_index.json

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ _This is not an official corsair project._
2222
* Commander PRO
2323
* Lighting Node CORE
2424
* LS100 Smart Lighting Controller
25+
* LT100 Smart Lighting Towers
2526

2627
![Overview](extra/images/overview.png)
2728

examples/UnitTests/UnitTests.ino

+268
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
/*
2+
Copyright 2020 Leon Kiefer
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
#line 17 "UnitTests.ino"
17+
18+
#include <AUnit.h>
19+
20+
#include "FastLEDControllerUtils.h"
21+
22+
using namespace aunit;
23+
24+
class FastLEDControllerTest : public TestOnce {
25+
protected:
26+
void assertCRGB(const CRGB& actual, const CRGB& expected) {
27+
assertEqual(actual.r, expected.r);
28+
assertEqual(actual.g, expected.g);
29+
assertEqual(actual.b, expected.b);
30+
}
31+
};
32+
33+
test(getLEDs) {
34+
CRGB leds[10];
35+
FastLEDController ledController(false);
36+
ledController.addLEDs(0, leds, 10);
37+
assertEqual(ledController.getLEDs(0), leds);
38+
assertEqual(ledController.getLEDs(1), nullptr);
39+
}
40+
41+
testF(FastLEDControllerTest, simpleScaleUp) {
42+
CRGB leds[20];
43+
FastLEDController ledController(false);
44+
fill_solid(leds, 20, CRGB::Black);
45+
ledController.addLEDs(0, leds, 10);
46+
47+
fill_solid(leds, 10, CRGB::White);
48+
CLP::scale(&ledController, 0, 20);
49+
50+
for (int i = 0; i < 10; i++) {
51+
assertCRGB(leds[i], CRGB::White);
52+
}
53+
}
54+
55+
testF(FastLEDControllerTest, simpleScaleDown) {
56+
CRGB leds[20];
57+
FastLEDController ledController(false);
58+
fill_solid(leds, 20, CRGB::Black);
59+
ledController.addLEDs(0, leds, 20);
60+
61+
fill_solid(leds, 10, CRGB::White);
62+
CLP::scale(&ledController, 0, 10);
63+
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+
}
70+
}
71+
72+
testF(FastLEDControllerTest, simpleScaleIdentity) {
73+
CRGB leds[20];
74+
FastLEDController ledController(false);
75+
fill_solid(leds, 20, CRGB::Black);
76+
ledController.addLEDs(0, leds, 10);
77+
78+
fill_solid(leds, 10, CRGB::White);
79+
CLP::scale(&ledController, 0, 10);
80+
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+
}
87+
}
88+
89+
testF(FastLEDControllerTest, LT100) {
90+
CRGB leds[30];
91+
FastLEDController ledController(false);
92+
fill_solid(leds, 30, CRGB::Black);
93+
ledController.addLEDs(0, leds, 30);
94+
95+
leds[0] = CRGB::White;
96+
fill_solid(leds + 1, 26, CRGB::Blue);
97+
CLP::SegmentScaling segments[2] = {{1, 4}, {26, 26}};
98+
CLP::scaleSegments(&ledController, 0, segments, 2);
99+
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+
}
106+
}
107+
108+
testF(FastLEDControllerTest, singleSegmentScaleUp) {
109+
CRGB leds[20];
110+
FastLEDController ledController(false);
111+
fill_solid(leds, 20, CRGB::Black);
112+
ledController.addLEDs(0, leds, 20);
113+
114+
fill_solid(leds, 10, CRGB::White);
115+
CLP::SegmentScaling segments[] = {{10, 20}};
116+
CLP::scaleSegments(&ledController, 0, segments, 1);
117+
118+
for (int i = 0; i < 20; i++) {
119+
assertCRGB(leds[i], CRGB::White);
120+
}
121+
}
122+
123+
testF(FastLEDControllerTest, multiScaleUp) {
124+
CRGB leds[30];
125+
FastLEDController ledController(false);
126+
fill_solid(leds, 30, CRGB::Black);
127+
ledController.addLEDs(0, leds, 10);
128+
129+
fill_solid(leds + 5, 5, CRGB::White);
130+
CLP::SegmentScaling segments[] = {{5, 10}, {5, 20}};
131+
CLP::scaleSegments(&ledController, 0, segments, 2);
132+
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+
}
139+
}
140+
141+
testF(FastLEDControllerTest, multiScaleDown) {
142+
CRGB leds[30];
143+
FastLEDController ledController(false);
144+
fill_solid(leds, 30, CRGB::Black);
145+
ledController.addLEDs(0, leds, 30);
146+
147+
fill_solid(leds + 10, 20, CRGB::White);
148+
CLP::SegmentScaling segments[] = {{10, 5}, {20, 5}};
149+
CLP::scaleSegments(&ledController, 0, segments, 2);
150+
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+
}
157+
}
158+
159+
testF(FastLEDControllerTest, singleSegmentScaleDown) {
160+
CRGB leds[20];
161+
FastLEDController ledController(false);
162+
fill_solid(leds, 20, CRGB::Black);
163+
ledController.addLEDs(0, leds, 20);
164+
165+
fill_solid(leds, 10, CRGB::White);
166+
CLP::SegmentScaling segments[] = {{20, 10}};
167+
CLP::scaleSegments(&ledController, 0, segments, 1);
168+
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+
}
175+
}
176+
177+
testF(FastLEDControllerTest, SegmentScaleOverlap) {
178+
CRGB leds[15];
179+
FastLEDController ledController(false);
180+
fill_solid(leds, 15, CRGB::Black);
181+
ledController.addLEDs(0, leds, 15);
182+
183+
fill_solid(leds, 5, CRGB::White);
184+
CLP::SegmentScaling segments[] = {{5, 10}, {10, 5}};
185+
CLP::scaleSegments(&ledController, 0, segments, 2);
186+
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+
}
193+
}
194+
195+
testF(FastLEDControllerTest, SegmentScaleOverlapInverted) {
196+
CRGB leds[15];
197+
FastLEDController ledController(false);
198+
fill_solid(leds, 15, CRGB::Black);
199+
ledController.addLEDs(0, leds, 15);
200+
201+
fill_solid(leds, 10, CRGB::White);
202+
CLP::SegmentScaling segments[] = {{10, 5}, {5, 10}};
203+
CLP::scaleSegments(&ledController, 0, segments, 2);
204+
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+
}
211+
}
212+
213+
testF(FastLEDControllerTest, SegmentScaleMix) {
214+
CRGB leds[30];
215+
FastLEDController ledController(false);
216+
fill_solid(leds, 30, CRGB::Black);
217+
ledController.addLEDs(0, leds, 30);
218+
219+
fill_solid(leds, 5, CRGB::White);
220+
fill_solid(leds + 5, 20, CRGB::Red);
221+
fill_solid(leds + 25, 5, CRGB::Blue);
222+
CLP::SegmentScaling segments[] = {{5, 10}, {20, 5}, {5, 10}};
223+
CLP::scaleSegments(&ledController, 0, segments, 3);
224+
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+
}
234+
}
235+
236+
testF(FastLEDControllerTest, SegmentScaleMixInverted) {
237+
CRGB leds[30];
238+
FastLEDController ledController(false);
239+
fill_solid(leds, 30, CRGB::Black);
240+
ledController.addLEDs(0, leds, 25);
241+
242+
fill_solid(leds, 10, CRGB::White);
243+
fill_solid(leds + 10, 5, CRGB::Red);
244+
fill_solid(leds + 15, 10, CRGB::Blue);
245+
CLP::SegmentScaling segments[] = {{10, 5}, {5, 20}, {10, 5}};
246+
CLP::scaleSegments(&ledController, 0, segments, 3);
247+
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+
}
257+
}
258+
259+
void setup() {
260+
delay(1000);
261+
Serial.begin(115200);
262+
while (!Serial)
263+
;
264+
}
265+
266+
void loop() {
267+
TestRunner::run();
268+
}

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.0
41+
PROJECT_NUMBER = 0.14.1
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

extra/images/OpenRGBBadge.png

15.5 KB
Loading

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.0
2+
version=0.14.1
33
author=Leon Kiefer
44
maintainer=Leon Kiefer
55
sentence=Control LED strips via USB from a PC.

0 commit comments

Comments
 (0)