Skip to content

Commit

Permalink
Merge pull request #166 from Legion2/dev
Browse files Browse the repository at this point in the history
Version 0.14.1
  • Loading branch information
Legion2 authored Aug 5, 2020
2 parents 6187d2e + 7ad904d commit bb45884
Show file tree
Hide file tree
Showing 11 changed files with 337 additions and 17 deletions.
34 changes: 34 additions & 0 deletions .github/CONTRIBUTING.md
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.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
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"
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Install doxygen
run: sudo apt install doxygen graphviz
- name: Fix Readme title
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Check src format
uses: DoozyX/clang-format-lint-action@v0.5
uses: DoozyX/clang-format-lint-action@v0.8
with:
source: './src'
extensions: 'h,cpp'
clangFormatVersion: 9
- name: Check examples format
uses: DoozyX/clang-format-lint-action@v0.5
uses: DoozyX/clang-format-lint-action@v0.8
with:
source: './examples'
extensions: 'h,cpp,ino'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ _This is not an official corsair project._
* Commander PRO
* Lighting Node CORE
* LS100 Smart Lighting Controller
* LT100 Smart Lighting Towers

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

Expand Down
268 changes: 268 additions & 0 deletions examples/UnitTests/UnitTests.ino
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();
}
2 changes: 1 addition & 1 deletion extra/doxygen.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "Corsair Lighting Protocol"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.14.0
PROJECT_NUMBER = 0.14.1

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
Binary file modified extra/images/OpenRGBBadge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Corsair Lighting Protocol
version=0.14.0
version=0.14.1
author=Leon Kiefer
maintainer=Leon Kiefer
sentence=Control LED strips via USB from a PC.
Expand Down
Loading

0 comments on commit bb45884

Please sign in to comment.