Skip to content

Commit

Permalink
Merge pull request #267 from Legion2/dev
Browse files Browse the repository at this point in the history
Version 0.15.0
  • Loading branch information
Legion2 authored Feb 19, 2022
2 parents ca41ced + dc2eb9c commit 61240f1
Show file tree
Hide file tree
Showing 63 changed files with 1,204 additions and 253 deletions.
8 changes: 5 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ If applicable, add screenshots to help explain your problem.
**System (please complete the following information):**
- OS: [e.g. Windows 10]
- Board: [e.g. Arduino Leonardo]
- IDE: [e.g. Arduino IDE]
- Version: [e.g. 0.3.0]
- Sketch: [e.g. SingleStripLightingNodePRO]
- Device: [e.g. Lighting Node PRO]
- Version of IDE: [e.g. Arduino IDE 1.8.13]
- Version of CLP: [e.g. 0.15.0]
- Version of CLP Boards: [e.g. 0.2.0]
- Sketch: [e.g. RepeatAndScale]

**Code changes**
Did you changed the code of the library or the sketch?
8 changes: 5 additions & 3 deletions .github/ISSUE_TEMPLATE/support.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ If applicable, add screenshots to help explain your problem.
**System (please complete the following information):**
- OS: [e.g. Windows 10]
- Board: [e.g. Arduino Leonardo]
- IDE: [e.g. Arduino IDE]
- Version: [e.g. 0.3.0]
- Sketch: [e.g. SingleStripLightingNodePRO]
- Device: [e.g. Lighting Node PRO]
- Version of IDE: [e.g. Arduino IDE 1.8.13]
- Version of CLP: [e.g. 0.15.0]
- Version of CLP Boards: [e.g. 0.2.0]
- Sketch: [e.g. RepeatAndScale]

**Code changes**
Did you changed the code of the library or the sketch?
17 changes: 0 additions & 17 deletions .github/stale.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Run doxygen
run: doxygen extra/doxygen.conf
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v3.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Check src format
uses: DoozyX/clang-format-lint-action@v0.9
uses: DoozyX/clang-format-lint-action@v0.13
with:
source: './src'
extensions: 'h,cpp'
clangFormatVersion: 9
- name: Check examples format
uses: DoozyX/clang-format-lint-action@v0.9
uses: DoozyX/clang-format-lint-action@v0.13
with:
source: './examples'
extensions: 'h,cpp,ino'
Expand Down
92 changes: 77 additions & 15 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]
name: Test
jobs:
test:
name: Test for ${{ matrix.board }}
name: Test for Board ${{ matrix.board }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -15,12 +15,13 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build for ${{ matrix.board }}
uses: ArminJo/arduino-test-compile@v2.6.0
uses: ArminJo/arduino-test-compile@v3
with:
cli-version: 0.18.3
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
arduino-platform: arduino:[email protected].2,SparkFun:[email protected].5,Legion2:avr@0.1.3
required-libraries: FastLED@3.3.3
arduino-platform: arduino:[email protected].3,SparkFun:[email protected].13,Legion2:avr@0.3.1
required-libraries: FastLED@3.5.0
sketch-names: LightingNodePRO.ino,
SingleStripLightingNodePRO.ino,
CommanderPRO.ino,
Expand All @@ -34,36 +35,97 @@ jobs:
AdditionalFeatures.ino,
AmbientBacklight.ino,
MultipleFans.ino,
DebugSketch.ino
examples-build-properties: '{"DebugSketch": "-DDEBUG -DVERBOSE -DPRINT_COMMAND=true -DPRINT_RESPONSE=true -DPRINT_LOOP=true -DPRINT_UPDATE=true"}'
DebugSketch.ino,
NoEEPROM.ino
build-properties: '{"DebugSketch": "-DDEBUG -DVERBOSE -DPRINT_COMMAND=true -DPRINT_RESPONSE=true -DPRINT_LOOP=true -DPRINT_UPDATE=true"}'
testUnoMega:
name: Test UnoMega sketches for ${{ matrix.board }}
name: Test Arduino Uno/Mega sketches for Board ${{ matrix.board }}
runs-on: ubuntu-latest
strategy:
matrix:
board: ["arduino:avr:uno", "arduino:avr:mega:cpu=atmega2560"]
steps:
- uses: actions/checkout@v2
- name: Build for ${{ matrix.board }}
uses: ArminJo/arduino-test-compile@v2.6.0
uses: ArminJo/arduino-test-compile@v3
with:
cli-version: 0.18.3
arduino-board-fqbn: ${{ matrix.board }}
arduino-platform: arduino:[email protected].2
required-libraries: FastLED@3.3.3
arduino-platform: arduino:[email protected].3
required-libraries: FastLED@3.5.0
sketch-names: HoodLoader2UnoMegaController.ino
test16u2:
name: Test 16u2 sketch for ${{ matrix.board }}
name: Test 16u2 sketch for Board ${{ matrix.board }}
runs-on: ubuntu-latest
strategy:
matrix:
board: ["Legion2:avr:HoodLoader2atmega16u2clp"]
steps:
- uses: actions/checkout@v2
- name: Build for ${{ matrix.board }}
uses: ArminJo/arduino-test-compile@v2.6.0
uses: ArminJo/arduino-test-compile@v3
with:
cli-version: 0.18.3
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
arduino-platform: arduino:[email protected].2,HoodLoader2:[email protected],Legion2:avr@0.1.3
required-libraries: FastLED@3.3.3
arduino-platform: arduino:[email protected].3,HoodLoader2:[email protected],Legion2:avr@0.3.1
required-libraries: FastLED@3.5.0
sketch-names: HoodLoader2CLPBridge.ino
testAdafruitSAMD:
name: Test for Board ${{ matrix.board }}
runs-on: ubuntu-latest
strategy:
matrix:
board:
[
"adafruit:samd:adafruit_feather_m0:usbstack=tinyusb",
"adafruit:samd:adafruit_metro_m0:usbstack=tinyusb",
"adafruit:samd:adafruit_circuitplayground_m0:usbstack=tinyusb",
"adafruit:samd:adafruit_gemma_m0:usbstack=tinyusb",
"adafruit:samd:adafruit_trinket_m0:usbstack=tinyusb",
"adafruit:samd:adafruit_qtpy_m0:usbstack=tinyusb",
"adafruit:samd:adafruit_itsybitsy_m0:usbstack=tinyusb",
"adafruit:samd:adafruit_itsybitsy_m4:usbstack=tinyusb",
"adafruit:samd:adafruit_metro_m4_airliftlite:usbstack=tinyusb",
# "adafruit:samd:adafruit_feather_m4:usbstack=tinyusb", #Should work but doesn't have the pins needed for the sketch
"adafruit:samd:adafruit_matrixportal_m4:usbstack=tinyusb"
]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build for ${{ matrix.board }}
uses: ArminJo/arduino-test-compile@v3
with:
cli-version: 0.18.3
arduino-board-fqbn: ${{ matrix.board }}
platform-url: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
arduino-platform: adafruit:[email protected]
required-libraries: [email protected],Adafruit TinyUSB [email protected]
sketch-names: TinyUSB.ino
testAdafruitnRF52:
name: Test for Board ${{ matrix.board }}
runs-on: ubuntu-latest
strategy:
matrix:
board:
[
"adafruit:nrf52:feather52840",
"adafruit:nrf52:itsybitsy52840",
# "adafruit:nrf52:cplaynrf52840", #Should work but doesn't have the pins needed for the sketch
"adafruit:nrf52:metro52840"
]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get adafruit-nrfutil
run: |
pip3 install adafruit-nrfutil --user
- name: Build for ${{ matrix.board }}
uses: ArminJo/arduino-test-compile@v3
with:
cli-version: 0.18.3
arduino-board-fqbn: ${{ matrix.board }}
platform-url: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
arduino-platform: adafruit:[email protected]
required-libraries: [email protected],Adafruit TinyUSB [email protected]
sketch-names: TinyUSB.ino
18 changes: 18 additions & 0 deletions .github/workflows/stale.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v4
with:
days-before-stale: 14
days-before-close: 7
exempt-issue-labels: bug,enhancement,refactoring,documentation
stale-issue-message: >
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.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -274,5 +274,4 @@ __vm/
.vscode/

# Arduino CLI
*.elf
*.hex
build/
62 changes: 53 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<a href="https://gitlab.com/CalcProgrammer1/OpenRGB"><img src="extra/images/OpenRGBBadge.png" alt="OpenRGB" height="80" /></a>

**This library can be used to integrate custom/unofficial RGB strips with iCUE.**
_This is not an official corsair project._
_This is not an official Corsair project._

## Features
* Add support of Corsair DIY device protocol to Arduino.
* Control LEDs with the [Corsair iCUE software](https://www.corsair.com/icue).
* [Support common LED chipsets](https://github.com/FastLED/FastLED/wiki/Overview#chipsets). (e.g. WS2812B, WS2801)
* Support [FastLED](http://fastled.io/).
* Supported platform: Arduino AVR
* Supported platforms: Arduino AVR, [TinyUSB supported cores](https://github.com/adafruit/Adafruit_TinyUSB_Arduino#supported-cores)
* Hardware Lighting mode.
* Use multiple devices at the same time.
* Repeat or scale LED channels to arbitrary size.
Expand All @@ -33,14 +33,19 @@ This project provides example sketches for easy use with Arduino IDE.

- [Requirements](#requirements)
- [Install the libraries](#install-the-libraries)
- [Create a Lighting Node PRO](#create-a-lighting-node-pro)
- [Create a Lighting Node PRO with AVR](#create-a-lighting-node-pro-with-avr)
- [Create a Lighting Node PRO with TinyUSB](#create-a-lighting-node-pro-for-a-raspberry-pi-pico-with-tinyusb)
- [Use the Lighting Node PRO](#use-the-lighting-node-pro)

## 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**, **Arduino Micro**, and **Adafruit 32u4 AVR Boards**.
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 ATmega328 (Arduino Nano), STM8S103F3, teensy, ESP8266 and ESP32 see [list of architecture/platform](https://github.com/Legion2/CorsairLightingProtocol/issues?q=is%3Aissue+label%3Aarchitecture%2Fplatform) for a detailed description why they are not supported.

In addition, any board compatible with **Adafruit TinyUSB for Arduino** is also supported without the use of custom board definitions. Be sure to define USE_TINYUSB, which is done automatically when using a supported core and selecting TinyUSB for the USB Stack. See the TinyUSB example for implementation details.

It is **not** compatible with ATmega328 (Arduino Nano), STM8S103F3, teensy, or ESP8266 see [list of architecture/platform](https://github.com/Legion2/CorsairLightingProtocol/issues?q=is%3Aissue+label%3Aarchitecture%2Fplatform) for a detailed description why they are not supported.

In the rest of the documentation "Arduino" is used as a synonym for all supported boards regardless of the manufacturer.

When you have problems with a board not listed here, please open an [Issue](https://github.com/Legion2/CorsairLightingProtocol/issues).
Expand All @@ -51,8 +56,9 @@ Open the Library-Manager in Arduino IDE via Tools->Manage Libraries...
Search for "Corsair Lighting Protocol" and install the Corsair Lighting Protocol library.
This library also requires the [FastLED](http://fastled.io/) library.
Search for "FastLED" in the Library-Manager and install the FastLED library.
If using TinyUSB, also install the latest "Adafruit TinyUSB Library" as it supersedes some of the core versions.

## Create a Lighting Node PRO
## Create a Lighting Node PRO with AVR
This guide will teach you how to create a Lighting Node PRO with an Arduino Leonardo compatible board.
If you have an Arduino Uno or Mega, see the [other guide](https://github.com/Legion2/CorsairLightingProtocol/wiki/How-to-use-on-Arduino-Uno-and-Arduino-Mega).

Expand All @@ -63,20 +69,50 @@ If you have an Arduino Uno or Mega, see the [other guide](https://github.com/Leg
1. Install the [CLP Boards](https://github.com/Legion2/CorsairLightingProtocolBoards).
They can be installed by following the [CLP Boards installation guide](https://github.com/Legion2/CorsairLightingProtocolBoards#how-to-use-these-boards-in-arduino).
After installation it should be possible to select the CLP Boards in the Arduino IDE as shown in the screenshot below.
If your are using a Sparkfun Pro Micro also install the [SparkFun Boards definition](https://github.com/sparkfun/Arduino_Boards#installation-instructions).

![select CLP Board](extra/images/select-board.png)
1. Upload the "LightingNodePRO" sketch to your Arduino.

![upload sketch](extra/images/upload-sketch.png)
1. Do the wiring.
For more information on [how to wire 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.
For more information on [how to wire 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.

![the wiring](extra/images/board-wiring.jpg)
1. Verify your device works as expected.
Open the Windows settings->devices->Other devices.
Somewhere in the list of devices, there should be a device called "Lighting Node PRO".
1. Now open [iCUE](https://www.corsair.com/icue) there you should see the "Lighting Node PRO".

> If you have any problem during setup you may find the solution in the [Troubleshooting section](https://github.com/Legion2/CorsairLightingProtocol/wiki/Troubleshooting).
## Create a Lighting Node PRO for a Raspberry Pi Pico with TinyUSB

This guide will teach you how to create a Lighting Node PRO with a Raspberry Pi Pico.

**Note:** FastLED currently does not support the RP2040 natively. You must manually merge support by modifying your library to include the [6 RP2040 platform files](https://github.com/FastLED/FastLED/pull/1261/files#diff-fda1710ad90fcc4b2f07be21a834da7d24b00008867655232c84fb0369cfc74b) in the FastLED/src/platforms/arm/rp2040 folder and `#elif defined(ARDUINO_ARCH_RP2040)` / `#include` statements in [led_sysdefs.h](https://github.com/FastLED/FastLED/pull/1261/files#diff-95f6b43a0e6b0e58988e1be3bc6415ded5284082a4f2ce2aaa90f5931d4194af) and [platforms.h](https://github.com/FastLED/FastLED/pull/1261/files#diff-255ea38a6573ed237ea1fe164d5e87ca46811eef21ba6e2cef120fda47c6e62f).

1. Install the [Raspberry Pi Pico Arduino core](https://github.com/earlephilhower/arduino-pico#installing-via-arduino-boards-manager).

1. Open the example "TinyUSB", you can find it in Arduino IDE in the File menu->Examples->Corsair Lighting Protocol->TinyUSB.
If you can't open the LightingNodePRO example the Corsair Lighting Protocol library is not installed correctly.

1. Select the Raspberry Pi Pico as shown in the screenshot below. Be sure to select the "Adafruit TinyUSB" USB Stack.

![select Raspberry Pi Pico](extra/images/select-board-pico.png)
1. Upload the "TinyUSB" sketch to your Pico.

1. Do the wiring.
For more information on [how to wire 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.

A level shifter or buffer, like [this one](https://www.ti.com/product/SN74AHCT1G126), is recommended in between the Pico and LEDs to translate the 3.3v logic level of the Pico IO to the 5v logic level of the LEDs. Your setup may not work reliably without one.

![the wiring](extra/images/board-wiring-pico.jpg)
1. Verify your device works as expected.
Open the Windows settings->devices->Other devices.
Somewhere in the list of devices, there should be a device called "Lighting Node PRO".
1. Now open [iCUE](https://www.corsair.com/icue) there you should see the "Lighting Node PRO".

## Use the Lighting Node PRO

![iCUE RGB Strip example](extra/images/iCUE.jpg)
Expand Down Expand Up @@ -118,7 +154,7 @@ The Serial Number MAY only consist of HEX characters (0-9 and A-F).
The DeviceID can be set with the `setDeviceID` function of `CorsairLightingFirmware`.
```C++
void setup() {
byte deviceId[4] = { 0x9A, 0xDA, 0xA7, 0x8E };
DeviceID deviceId = { 0x9A, 0xDA, 0xA7, 0x8E };
firmware.setDeviceID(deviceId);
...
}
Expand Down Expand Up @@ -158,11 +194,19 @@ ledController.onUpdateHook(0, []() {
});
```

## Reverse direction of LED Strip
If you want to change the direction of the LEDs of the Strip without physically change the strip, the `CLP::reverse` function can be used.
The reverse function must be called be for scaling.
```C++
ledController.onUpdateHook(0, []() {
CLP::reverse(&ledController, 0);
});
```
## Hardware Lighting mode
The [Hardware Lighting mode](https://forum.corsair.com/v3/showthread.php?t=182874) can be configured in iCUE.
It allows you the set lighting effects that will be active when iCUE **is not** running.
This is the case when the PC is off, in sleep mode, booting or the user is logged out.
So if you want to have lighing effects in all these situations, use the Hardware Lighting mode.
So if you want to have lighting effects in all these situations, use the Hardware Lighting mode.
If you don't want it, configure a static black color.

# License
Expand Down
6 changes: 4 additions & 2 deletions examples/AdditionalFeatures/AdditionalFeatures.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ CRGB ledsChannel2[60];
// Define a custom SerialNumber for the device
const char mySerialNumber[] PROGMEM = "202B6949A967";

CorsairLightingFirmware firmware = corsairLightingNodePROFirmware();
FastLEDController ledController(true);
CorsairLightingFirmwareStorageEEPROM firmwareStorage;
CorsairLightingFirmware firmware(CORSAIR_LIGHTING_NODE_PRO, &firmwareStorage);
FastLEDControllerStorageEEPROM storage;
FastLEDController ledController(&storage);
CorsairLightingProtocolController cLP(&ledController, &firmware);
// Set the SerialNumber here
CorsairLightingProtocolHID cHID(&cLP, mySerialNumber);
Expand Down
6 changes: 4 additions & 2 deletions examples/AmbientBacklight/AmbientBacklight.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
CRGB ledsChannel1[84];
CRGB ledsChannel2[105];

CorsairLightingFirmware firmware = corsairLS100Firmware();
FastLEDController ledController(true);
CorsairLightingFirmwareStorageEEPROM firmwareStorage;
CorsairLightingFirmware firmware(CORSAIR_SMART_LIGHTING_CONTROLLER, &firmwareStorage);
FastLEDControllerStorageEEPROM storage;
FastLEDController ledController(&storage);
CorsairLightingProtocolController cLP(&ledController, &firmware);
CorsairLightingProtocolHID cHID(&cLP);

Expand Down
Loading

0 comments on commit 61240f1

Please sign in to comment.