-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from Legion2/dev
Version 0.14.1
- Loading branch information
Showing
11 changed files
with
337 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# How to contribute | ||
|
||
You can contribute in many different ways, for example report a bug or come up with an idea for improvement. | ||
If you are good at programming you could also provide a fix for bugs or Pull Requests with improvements. | ||
If you want to help others using CLP you are welcome to extend the [Wiki on GitHub](https://github.com/Legion2/CorsairLightingProtocol/wiki). | ||
|
||
## Finding information | ||
|
||
General information can be found in the [Readme](https://github.com/Legion2/CorsairLightingProtocol) file at the root of the project. | ||
Information about specific topics are written in the [Wiki](https://github.com/Legion2/CorsairLightingProtocol/wiki). | ||
For developer there is also an [API documentation](https://legion2.github.io/CorsairLightingProtocol/) for all the public methods and types. | ||
|
||
## Writing code | ||
|
||
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. | ||
For uploading to Arduino boards I use the ArduinoIDE. | ||
|
||
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. | ||
The main logic for processing commands and creating the LED colors is part of the library source code. | ||
The examples only show how to use the library and what can be configured. | ||
The library is modular so communication with iCUE and the processing of commands is decoupled and can be extended by other developers. | ||
Single parts of the library, such as the LEDController can also be used without iCUE, by just calling the public API of these classes. | ||
|
||
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. | ||
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. | ||
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. | ||
To verify that the library can be compiled on all supported platforms, all the examples are compiled in the CI pipeline for different boards. | ||
|
||
## Coding conventions | ||
|
||
Public methods must be documented with JavaDoc style comments. | ||
When introducing new methods you should think about if the method should be part of the public API or only used internally. | ||
Always use descriptive names for variables, only use acronyms if they are well known and frequently used. | ||
The coding style is defined using ClangFormat and automatically checked when you submit a Pull Request. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,9 @@ jobs: | |
"Legion2:avr:promicro3vclp", | ||
] | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/checkout@v2 | ||
- name: Build for ${{ matrix.board }} | ||
uses: ArminJo/arduino-test-compile@v2.0.0 | ||
uses: ArminJo/arduino-test-compile@v2.6.0 | ||
with: | ||
arduino-board-fqbn: ${{ matrix.board }} | ||
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: | |
matrix: | ||
board: ["arduino:avr:uno", "arduino:avr:mega:cpu=atmega2560"] | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/checkout@v2 | ||
- name: Build for ${{ matrix.board }} | ||
uses: ArminJo/arduino-test-compile@v2.0.0 | ||
uses: ArminJo/arduino-test-compile@v2.6.0 | ||
with: | ||
arduino-board-fqbn: ${{ matrix.board }} | ||
arduino-platform: arduino:[email protected] | ||
|
@@ -58,9 +58,9 @@ jobs: | |
matrix: | ||
board: ["Legion2:avr:HoodLoader2atmega16u2clp"] | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/checkout@v2 | ||
- name: Build for ${{ matrix.board }} | ||
uses: ArminJo/arduino-test-compile@v2.0.0 | ||
uses: ArminJo/arduino-test-compile@v2.6.0 | ||
with: | ||
arduino-board-fqbn: ${{ matrix.board }} | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,268 @@ | ||
/* | ||
Copyright 2020 Leon Kiefer | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
#line 17 "UnitTests.ino" | ||
|
||
#include <AUnit.h> | ||
|
||
#include "FastLEDControllerUtils.h" | ||
|
||
using namespace aunit; | ||
|
||
class FastLEDControllerTest : public TestOnce { | ||
protected: | ||
void assertCRGB(const CRGB& actual, const CRGB& expected) { | ||
assertEqual(actual.r, expected.r); | ||
assertEqual(actual.g, expected.g); | ||
assertEqual(actual.b, expected.b); | ||
} | ||
}; | ||
|
||
test(getLEDs) { | ||
CRGB leds[10]; | ||
FastLEDController ledController(false); | ||
ledController.addLEDs(0, leds, 10); | ||
assertEqual(ledController.getLEDs(0), leds); | ||
assertEqual(ledController.getLEDs(1), nullptr); | ||
} | ||
|
||
testF(FastLEDControllerTest, simpleScaleUp) { | ||
CRGB leds[20]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 20, CRGB::Black); | ||
ledController.addLEDs(0, leds, 10); | ||
|
||
fill_solid(leds, 10, CRGB::White); | ||
CLP::scale(&ledController, 0, 20); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
} | ||
|
||
testF(FastLEDControllerTest, simpleScaleDown) { | ||
CRGB leds[20]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 20, CRGB::Black); | ||
ledController.addLEDs(0, leds, 20); | ||
|
||
fill_solid(leds, 10, CRGB::White); | ||
CLP::scale(&ledController, 0, 10); | ||
|
||
for (int i = 0; i < 5; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
for (int i = 5; i < 10; i++) { | ||
assertCRGB(leds[i], CRGB::Black); | ||
} | ||
} | ||
|
||
testF(FastLEDControllerTest, simpleScaleIdentity) { | ||
CRGB leds[20]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 20, CRGB::Black); | ||
ledController.addLEDs(0, leds, 10); | ||
|
||
fill_solid(leds, 10, CRGB::White); | ||
CLP::scale(&ledController, 0, 10); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
for (int i = 10; i < 20; i++) { | ||
assertCRGB(leds[i], CRGB::Black); | ||
} | ||
} | ||
|
||
testF(FastLEDControllerTest, LT100) { | ||
CRGB leds[30]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 30, CRGB::Black); | ||
ledController.addLEDs(0, leds, 30); | ||
|
||
leds[0] = CRGB::White; | ||
fill_solid(leds + 1, 26, CRGB::Blue); | ||
CLP::SegmentScaling segments[2] = {{1, 4}, {26, 26}}; | ||
CLP::scaleSegments(&ledController, 0, segments, 2); | ||
|
||
for (int i = 0; i < 4; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
for (int i = 4; i < 30; i++) { | ||
assertCRGB(leds[i], CRGB::Blue); | ||
} | ||
} | ||
|
||
testF(FastLEDControllerTest, singleSegmentScaleUp) { | ||
CRGB leds[20]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 20, CRGB::Black); | ||
ledController.addLEDs(0, leds, 20); | ||
|
||
fill_solid(leds, 10, CRGB::White); | ||
CLP::SegmentScaling segments[] = {{10, 20}}; | ||
CLP::scaleSegments(&ledController, 0, segments, 1); | ||
|
||
for (int i = 0; i < 20; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
} | ||
|
||
testF(FastLEDControllerTest, multiScaleUp) { | ||
CRGB leds[30]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 30, CRGB::Black); | ||
ledController.addLEDs(0, leds, 10); | ||
|
||
fill_solid(leds + 5, 5, CRGB::White); | ||
CLP::SegmentScaling segments[] = {{5, 10}, {5, 20}}; | ||
CLP::scaleSegments(&ledController, 0, segments, 2); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
assertCRGB(leds[i], CRGB::Black); | ||
} | ||
for (int i = 10; i < 30; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
} | ||
|
||
testF(FastLEDControllerTest, multiScaleDown) { | ||
CRGB leds[30]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 30, CRGB::Black); | ||
ledController.addLEDs(0, leds, 30); | ||
|
||
fill_solid(leds + 10, 20, CRGB::White); | ||
CLP::SegmentScaling segments[] = {{10, 5}, {20, 5}}; | ||
CLP::scaleSegments(&ledController, 0, segments, 2); | ||
|
||
for (int i = 0; i < 5; i++) { | ||
assertCRGB(leds[i], CRGB::Black); | ||
} | ||
for (int i = 5; i < 10; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
} | ||
|
||
testF(FastLEDControllerTest, singleSegmentScaleDown) { | ||
CRGB leds[20]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 20, CRGB::Black); | ||
ledController.addLEDs(0, leds, 20); | ||
|
||
fill_solid(leds, 10, CRGB::White); | ||
CLP::SegmentScaling segments[] = {{20, 10}}; | ||
CLP::scaleSegments(&ledController, 0, segments, 1); | ||
|
||
for (int i = 0; i < 5; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
for (int i = 5; i < 10; i++) { | ||
assertCRGB(leds[i], CRGB::Black); | ||
} | ||
} | ||
|
||
testF(FastLEDControllerTest, SegmentScaleOverlap) { | ||
CRGB leds[15]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 15, CRGB::Black); | ||
ledController.addLEDs(0, leds, 15); | ||
|
||
fill_solid(leds, 5, CRGB::White); | ||
CLP::SegmentScaling segments[] = {{5, 10}, {10, 5}}; | ||
CLP::scaleSegments(&ledController, 0, segments, 2); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
for (int i = 10; i < 15; i++) { | ||
assertCRGB(leds[i], CRGB::Black); | ||
} | ||
} | ||
|
||
testF(FastLEDControllerTest, SegmentScaleOverlapInverted) { | ||
CRGB leds[15]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 15, CRGB::Black); | ||
ledController.addLEDs(0, leds, 15); | ||
|
||
fill_solid(leds, 10, CRGB::White); | ||
CLP::SegmentScaling segments[] = {{10, 5}, {5, 10}}; | ||
CLP::scaleSegments(&ledController, 0, segments, 2); | ||
|
||
for (int i = 0; i < 5; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
for (int i = 5; i < 15; i++) { | ||
assertCRGB(leds[i], CRGB::Black); | ||
} | ||
} | ||
|
||
testF(FastLEDControllerTest, SegmentScaleMix) { | ||
CRGB leds[30]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 30, CRGB::Black); | ||
ledController.addLEDs(0, leds, 30); | ||
|
||
fill_solid(leds, 5, CRGB::White); | ||
fill_solid(leds + 5, 20, CRGB::Red); | ||
fill_solid(leds + 25, 5, CRGB::Blue); | ||
CLP::SegmentScaling segments[] = {{5, 10}, {20, 5}, {5, 10}}; | ||
CLP::scaleSegments(&ledController, 0, segments, 3); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
for (int i = 10; i < 15; i++) { | ||
assertCRGB(leds[i], CRGB::Red); | ||
} | ||
for (int i = 15; i < 25; i++) { | ||
assertCRGB(leds[i], CRGB::Blue); | ||
} | ||
} | ||
|
||
testF(FastLEDControllerTest, SegmentScaleMixInverted) { | ||
CRGB leds[30]; | ||
FastLEDController ledController(false); | ||
fill_solid(leds, 30, CRGB::Black); | ||
ledController.addLEDs(0, leds, 25); | ||
|
||
fill_solid(leds, 10, CRGB::White); | ||
fill_solid(leds + 10, 5, CRGB::Red); | ||
fill_solid(leds + 15, 10, CRGB::Blue); | ||
CLP::SegmentScaling segments[] = {{10, 5}, {5, 20}, {10, 5}}; | ||
CLP::scaleSegments(&ledController, 0, segments, 3); | ||
|
||
for (int i = 0; i < 5; i++) { | ||
assertCRGB(leds[i], CRGB::White); | ||
} | ||
for (int i = 5; i < 25; i++) { | ||
assertCRGB(leds[i], CRGB::Red); | ||
} | ||
for (int i = 25; i < 30; i++) { | ||
assertCRGB(leds[i], CRGB::Blue); | ||
} | ||
} | ||
|
||
void setup() { | ||
delay(1000); | ||
Serial.begin(115200); | ||
while (!Serial) | ||
; | ||
} | ||
|
||
void loop() { | ||
TestRunner::run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.