Skip to content

Commit

Permalink
Merge pull request #43 from Legion2/dev
Browse files Browse the repository at this point in the history
Version 0.6.0
  • Loading branch information
Legion2 authored Oct 7, 2019
2 parents 6615ffd + 31c58c1 commit 283c118
Show file tree
Hide file tree
Showing 16 changed files with 271 additions and 102 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
name: Tech-support
about: Have a problem using this project
name: Support
about: You have a problem using this project and need help?
title: ''
labels: ''
labels: support
assignees: ''

---
Expand Down
53 changes: 0 additions & 53 deletions .github/main.workflow

This file was deleted.

17 changes: 17 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 40
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- bug
- enhancement
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
86 changes: 86 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
on: [push, pull_request]
name: Test
jobs:
test:
name: Test ${{ matrix.sketch }} for ${{ matrix.board }}
runs-on: ubuntu-latest
strategy:
matrix:
sketch: [LightingNodePRO, SingleStripLightingNodePRO, CommanderPRO, DeviceIDTool]
board: ["arduino:avr:leonardo", "arduino:avr:micro", "SparkFun:avr:promicro:cpu=16MHzatmega32U4"]
steps:
- uses: actions/checkout@master
- name: Install FastLED
uses: Legion2/download-release-action@master
with:
repository: FastLED/FastLED
tag: '3.2.0'
path: libraries
- name: Install SparkFun boards
if: contains(matrix.board, 'SparkFun')
run: |
mkdir -p hardware/SparkFun
cd hardware/SparkFun
wget https://github.com/sparkfun/Arduino_Boards/raw/master/IDE_Board_Manager/sparkfunboards.1.1.5.tar.bz2
tar -xvjf sparkfunboards.1.1.5.tar.bz2
rm sparkfunboards.1.1.5.tar.bz2
mv avr-1.1.5 avr
- name: Build ${{ matrix.sketch }} for ${{ matrix.board }}
uses: Legion2/arduino-builder-action@v2.0.0
with:
board: ${{ matrix.board }}
sketch: ./examples/${{ matrix.sketch }}/${{ matrix.sketch }}.ino
testUnoMega:
name: Test UnoMega ${{ matrix.sketch }} for ${{ matrix.board }}
runs-on: ubuntu-latest
strategy:
matrix:
sketch: [HoodLoader2UnoMegaController]
board: ["arduino:avr:uno", "arduino:avr:mega:cpu=atmega2560"]
steps:
- uses: actions/checkout@master
- name: Install FastLED
uses: Legion2/download-release-action@master
with:
repository: FastLED/FastLED
tag: '3.2.0'
path: libraries
- name: Build ${{ matrix.sketch }} for ${{ matrix.board }}
uses: Legion2/arduino-builder-action@v2.0.0
with:
board: ${{ matrix.board }}
sketch: ./examples/${{ matrix.sketch }}/${{ matrix.sketch }}.ino
test16u2:
name: Test 16u2 ${{ matrix.sketch }} for ${{ matrix.board }}
runs-on: ubuntu-latest
strategy:
matrix:
sketch: [HoodLoader2CLPBridge]
board: ["HoodLoader2:avr:HoodLoader2atmega16u2:board=uno", "HoodLoader2:avr:HoodLoader2atmega16u2:board=mega2560"]
steps:
- uses: actions/checkout@master
- name: Install FastLED
uses: Legion2/download-release-action@master
with:
repository: FastLED/FastLED
tag: '3.2.0'
path: libraries
- name: Download HoodLoader2
uses: Legion2/download-release-action@master
with:
repository: NicoHood/HoodLoader2
tag: '2.0.5'
path: hardware/HoodLoader2
file: '2.0.5-boards_manager.zip'
- name: Install HoodLoader2
run: |
cd hardware/HoodLoader2
sudo mv 2.0.5-boards_manager.zip some.zip
sudo unzip some.zip
sudo rm some.zip
sudo mv * avr
- name: Build ${{ matrix.sketch }} for ${{ matrix.board }}
uses: Legion2/arduino-builder-action@v2.0.0
with:
board: ${{ matrix.board }}
sketch: ./examples/${{ matrix.sketch }}/${{ matrix.sketch }}.ino
45 changes: 24 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

[![arduino-library-badge](https://www.ardu-badge.com/badge/Corsair%20Lighting%20Protocol.svg?)](https://www.ardu-badge.com/Corsair%20Lighting%20Protocol)
![Actions Status](https://wdp9fww0r9.execute-api.us-west-2.amazonaws.com/production/badge/Legion2/CorsairLightingProtocol)
![Test Status](https://github.com/Legion2/CorsairLightingProtocol/workflows/Test/badge.svg)

**This library can be used to integrate custom/unofficial RGB strips with iCUE.**

## Features
* Add support of the Lighting Node PRO protocol to Arduino.
* Control LEDs with the Corsair Link or the iCUE software.
* Easy to use with [FastLED](http://fastled.io/)
* [Supported LED chipsets](https://github.com/FastLED/FastLED/wiki/Overview#chipsets)
* persistent settings for use without USB connection
* Use multiple devices at the same time
* Easy to use with [FastLED](http://fastled.io/).
* [Supported LED chipsets](https://github.com/FastLED/FastLED/wiki/Overview#chipsets).
* Persistent settings for use without a USB connection.
* Use multiple devices at the same time.

![Overview](docs/Overview.png)

Expand All @@ -26,10 +26,10 @@

## Requirements
The library is compatible with all boards using the MCU ATmega32U4.
This includes **Arduino Leonardo**, **SparkFun Pro Micro** and **Arduino Micro**.
This includes **Arduino Leonardo**, **SparkFun Pro Micro**, and **Arduino Micro**.
It also supports the Arduino Uno and Arduino Mega, **but** this requires the [HoodLoader2](https://github.com/NicoHood/HoodLoader2) bootloader, see [this wiki](https://github.com/Legion2/CorsairLightingProtocol/wiki/How-to-use-on-Arduino-Uno-and-Arduino-Mega) for more details.
It is **not** compatible with Arduino Nano.
In the rest of the documentation "Arduino" is used as synonym for all supported boards regardless of the manufacturer.
In the rest of the documentation "Arduino" is used as a synonym for all supported boards regardless of the manufacturer.

As an IDE [Visual Studio](https://visualstudio.microsoft.com/downloads/) with the extension [Visual Micro](https://marketplace.visualstudio.com/items?itemName=VisualMicro.ArduinoIDEforVisualStudio) is recommended.
Visual Micro provides the required functionality for free, but sometimes ask you to buy the full version.
Expand All @@ -39,26 +39,26 @@ You have problems with a board not listed here, please open an [Issue](https://g

## Install the library
Use the [Library-Manager](https://www.visualmicro.com/page/User-Guide.aspx?doc=Library-Manager.html#) to install this library or download a [release](https://github.com/Legion2/CorsairLightingProtocol/releases).
Additionally the [FastLED](http://fastled.io/) library must be installed.
Additionally, the [FastLED](http://fastled.io/) library must be installed.

## Create a Lighting Node PRO
Open the example "LightingNodePRO", you can find it in the Visual Micro Explorer or in the [examples directory](examples).
The library [FastLED](http://fastled.io/) is used to control the leds, for more information on [how to wiring the leds](https://github.com/FastLED/FastLED/wiki/Wiring-leds) and [how to set up the leds in the code](https://github.com/FastLED/FastLED/wiki/Basic-usage#setting-up-the-leds) see the links.
After you did the wiring or at least know which pin is the data pin, you can set this pin in the example sketch and upload it to the arduino.
Open the example "LightingNodePRO", you can find it in the Visual Micro Explorer or the [examples directory](examples).
The library [FastLED](http://fastled.io/) is used to control the LEDs, for more information on [how to wiring the leds](https://github.com/FastLED/FastLED/wiki/Wiring-leds) and [how to set up the LEDs in the code](https://github.com/FastLED/FastLED/wiki/Basic-usage#setting-up-the-leds) see the links.
After you did the wiring or at least know which pin is the data pin, you can set this pin in the example sketch and upload it to the Arduino.
In Visual Studio use the "Release" [configuration](https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/debugger/how-to-set-debug-and-release-configurations.md#change-the-build-configuration).

To verify the library works as expected open the Windows settings -> devices -> connected devices. Somewhere in the list of devices there should be a device called "Lighting Node PRO". (If not, please open an [Issue](https://github.com/Legion2/CorsairLightingProtocol/issues))
To verify the library works as expected open the Windows settings -> devices -> connected devices. Somewhere in the list of devices, there should be a device called "Lighting Node PRO". (If not, please open an [Issue](https://github.com/Legion2/CorsairLightingProtocol/issues))
Open [iCUE](https://www.corsair.com/icue) there should also be the "Lighting Node PRO".

![iCUE RGB Strip example](docs/iCUE.jpg)

In iCUE open the "Lighting Setup" tab of the Lighting Node PRO(LNP) and set for both Lighting Channels the device to "RGB Light Strip" and the amount to a tenth of the leds you have.
In iCUE open the "Lighting Setup" tab of the Lighting Node PRO(LNP) and set for both Lighting Channels the device to "RGB Light Strip" and the amount to a tenth of the LEDs you have.
iCUE groups the LEDs into groups of ten.
So if you have 20 LEDs, set the amount to 2.
Now you can create lighting effects in the "Lighting Channel #" tabs.

The example "SingleStripLightingNodePRO" only requires one LED Stip connected to the Arduino.
Because the "SingleStripLightingNodePRO" concatenate the two channels a total of 120 leds can be controlled on a single LED Strip.
The example "SingleStripLightingNodePRO" only requires one LED strip connected to the Arduino.
Because the "SingleStripLightingNodePRO" concatenate the two channels a total of 120 LEDs can be controlled on a single LED Strip.

## Use the library
If you want to use this library in your own sketch don't forget to use Visual Studio as IDE and include the [board.txt](examples/LightingNodePRO/board.txt) in the root directory of your sketch.
Expand All @@ -73,25 +73,28 @@ These commands are understood by the library and converted into lighting effects

## Use multiple Devices
Each device has two unique IDs, that is, they should be unique.
You must give each device unique ids.
There are two ids that must be changed `SERIAL_NUMBER` and `DeviceID`.
You must give each device a unique ID.
There are two IDs that must be changed `SERIAL_NUMBER` and `DeviceID`.

The `SERIAL_NUMBER` can be changed in the board.txt file.
Uncomment the line with `SERIAL_NUMBER` and change some characters at the end, don't change the length and only use HEX characters(0-9 and A-F).
The `DeviceID` can be changed with the [tool](examples/DeviceIDTool/DeviceIDTool.ino)
Upload the DeviceIDTool sketch and then open the Serial monitor with baudrate 115200.
The tool displays the current DeviceID, you can type in a new DeviceID that is saved on the Arduino.
After that you can upload another sketch.
After that, you can upload another sketch.

## Debugging
For debugging don't use the integrated debugger of Visual Studio, it will most likely break the USB comunication.
For debugging don't use the integrated debugger of Visual Studio, it will most likely break the USB communication.
Use the `DEBUG` macro and the Serial Monitor.
With the `-DDEBUG` flag you can enable debugging in the whole project.
Add this flag in the board.txt file to the `build.extra_flags`.
A Serial Monitor MUST be opened, otherwise the USB connection is blocked for the Corsair Lighting Protocol.

For advanced debugging you can use the [DebugSketch](examples/DebugSketch/DebugSketch.ino).
In the board.txt file, the default values for the debugging options can be set.
After uploading the sketch open the serial monitor with baud rate 115200 and set the line ending to "Line Feed"/"Newline" (`\n`).

# DISCLAIMERS
This is a DO IT YOURSELF project, use at your own risk.
This is a DO IT YOURSELF project, use at your own risk!

# Credits
- [HoodLoader2](https://github.com/NicoHood/HoodLoader2)
Expand Down
2 changes: 1 addition & 1 deletion examples/CommanderPRO/CommanderPRO.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#define CHANNEL_LED_COUNT 60

const uint8_t firmware_version[FIRMWARE_VERSION_SIZE] PROGMEM = { 0x00, 0x08, 0x00 };
const uint8_t firmware_version[FIRMWARE_VERSION_SIZE] PROGMEM = { 0x00, 0x09, 0xD4 };

ThermistorTemperatureController temperatureController;
FastLEDController<CHANNEL_LED_COUNT> ledController(&temperatureController, true);
Expand Down
83 changes: 83 additions & 0 deletions examples/DebugSketch/DebugSketch.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
Copyright 2019 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.
*/
#include <CorsairLightingNodePRO.h>
#include <FastLED.h>

#define CHANNEL_LED_COUNT 60

#define DATA_PIN_CHANNEL_1 2
#define DATA_PIN_CHANNEL_2 3

FastLEDController<CHANNEL_LED_COUNT> ledController(true);
CorsairLightingProtocol cLP(&ledController, firmware_version);
CorsairLightingProtocolHID cLPS(&cLP);

CRGB ledsChannel1[CHANNEL_LED_COUNT];
CRGB ledsChannel2[CHANNEL_LED_COUNT];

bool printLoop = PRINT_LOOP;
bool printUpdate = PRINT_UPDATE;

void setup() {
Serial.begin(115200);
Serial.setTimeout(100);
FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_1>(ledsChannel1, CHANNEL_LED_COUNT);
FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_2>(ledsChannel2, CHANNEL_LED_COUNT);
ledController.addLeds(0, ledsChannel1);
ledController.addLeds(1, ledsChannel2);
}

void loop() {
if (printLoop) Serial.println(F("loop"));
cLPS.update();

if (ledController.updateLEDs()) {
if (printUpdate) Serial.println(F("updateLEDs"));
FastLED.show();
}

if (Serial.available()) {
static String cmd = "";
cmd = Serial.readStringUntil('\n');
processCommand(cmd);
}
}

void processCommand(String& cmd) {
if (cmd == F("print DeviceID")) {
byte DeviceId[4];
EEPROM.get(EEPROM_ADDRESS_DEVICE_ID, DeviceId);
printDeviceID(DeviceId);
Serial.println();
}
#ifdef VERBOSE
else if (cmd == F("toggle command")) {
printCommand = !printCommand;
}
else if (cmd == F("toggle response")) {
printResponse = !printResponse;
}
#endif // VERBOSE
else if (cmd == F("toggle loop")) {
printLoop = !printLoop;
}
else if (cmd == F("toggle update")) {
printUpdate = !printUpdate;
}
else {
Serial.println(F("Unknown command"));
}
}
11 changes: 11 additions & 0 deletions examples/DebugSketch/board.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CorsairLightingProtocol build property overrides
#

##############################################################

build.vid=0x1b1c
build.pid=0x0c0b
build.usb_product="Lighting Node PRO"
build.usb_manufacturer="Corsair"

build.extra_flags={build.usb_flags} '-DSERIAL_NUMBER="FB66DF55421900F5"' -DDEBUG -DVERBOSE -DPRINT_COMMAND=true -DPRINT_RESPONSE=true -DPRINT_LOOP=true -DPRINT_UPDATE=true
Loading

0 comments on commit 283c118

Please sign in to comment.