Skip to content

Commit 1627603

Browse files
authored
Merge pull request #102 from Legion2/dev
Version 0.10.0
2 parents 7333c75 + 3d00828 commit 1627603

32 files changed

+147
-117
lines changed

.github/workflows/push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
sketch: [LightingNodePRO, SingleStripLightingNodePRO, CommanderPRO, DeviceIDTool, RepeatAndScale, TransformLLFansFormatToStrip, LS100, LightingNodeCORE, NonAddressable]
9+
sketch: [LightingNodePRO, SingleStripLightingNodePRO, CommanderPRO, DeviceIDTool, RepeatAndScale, TransformLLFansFormatToStrip, LS100, LightingNodeCORE, NonAddressable, AmbientBacklight]
1010
board: ["arduino:avr:leonardo", "arduino:avr:micro", "SparkFun:avr:promicro:cpu=16MHzatmega32U4"]
1111
steps:
1212
- uses: actions/checkout@master

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,6 @@ __vm/
269269
*.vcxitems
270270

271271
/doxygen
272+
273+
# VS Code settings
274+
.vscode/

README.md

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
[![arduino-library-badge](https://www.ardu-badge.com/badge/Corsair%20Lighting%20Protocol.svg?)](https://www.ardu-badge.com/Corsair%20Lighting%20Protocol)
2-
![Test Status](https://github.com/Legion2/CorsairLightingProtocol/workflows/Test/badge.svg)
1+
# Corsair Lighting Protocol [![arduino-library-badge](https://www.ardu-badge.com/badge/Corsair%20Lighting%20Protocol.svg?)](https://www.ardu-badge.com/Corsair%20Lighting%20Protocol) [![Test Status](https://github.com/Legion2/CorsairLightingProtocol/workflows/Test/badge.svg)](https://github.com/Legion2/CorsairLightingProtocol/actions?query=workflow%3ATest+branch%3Adev+event%3Apush)
32

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

@@ -21,9 +20,12 @@
2120
![Overview](extra/images/overview.png)
2221

2322
# Getting started
23+
This project is an Arduino library called "Corsair Lighting Protocol".
24+
It can be used to control Arduino boards with iCUE.
25+
This project provides example sketches for easy use with Arduino IDE.
2426

2527
- [Requirements](#requirements)
26-
- [Install the library](#install-the-library)
28+
- [Install the libraries](#install-the-libraries)
2729
- [Create a Lighting Node PRO](#create-a-lighting-node-pro)
2830
- [Use the Lighting Node PRO](#use-the-lighting-node-pro)
2931

@@ -34,28 +36,39 @@ It also supports the Arduino Uno and Arduino Mega, **but** this requires the [Ho
3436
It is **not** compatible with Arduino Nano.
3537
In the rest of the documentation "Arduino" is used as a synonym for all supported boards regardless of the manufacturer.
3638

37-
You have problems with a board not listed here, please open an [Issue](https://github.com/Legion2/CorsairLightingProtocol/issues).
39+
When you have problems with a board not listed here, please open an [Issue](https://github.com/Legion2/CorsairLightingProtocol/issues).
3840

39-
## Install the library
40-
Use the [Library-Manager](https://www.ardu-badge.com/Corsair%20Lighting%20Protocol/ide) to install this library (Corsair Lighting Protocol).
41-
Additionally, the [FastLED](http://fastled.io/) library must be installed.
41+
## Install the libraries
42+
To use this library you must install it with the Library-Manager.
43+
Open the Library-Manager in Arduino IDE via Tools->Manage Libraries...
44+
Search for "Corsair Lighting Protocol" and install the Corsair Lighting Protocol library.
45+
This library also requires the [FastLED](http://fastled.io/) library.
46+
Search for "FastLED" in the Library-Manager and install the FastLED library.
4247

4348
## Create a Lighting Node PRO
4449
This guide will teach you how to create a Lighting Node PRO with an Arduino Leonardo compatible board.
4550
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).
4651

47-
1. Open the example "LightingNodePRO", you can find it in Arduino IDE in the File menu->Examples->Corsair Lighting Protocol->LightingNodePRO or in the [examples directory](examples) if you download this project.
52+
1. Open the example "LightingNodePRO", you can find it in Arduino IDE in the File menu->Examples->Corsair Lighting Protocol->LightingNodePRO.
53+
If you can't open the LightingNodePRO example the Corsair Lighting Protocol library is not installed correctly.
4854

4955
![open example sketch](extra/images/open-example.png)
50-
1. Follow [these steps](https://github.com/Legion2/CorsairLightingProtocolBoards#how-to-use-these-boards-in-arduino) to install the CLP Boards and upload the sketch to your Arduino.
56+
1. Install the [CLP Boards](https://github.com/Legion2/CorsairLightingProtocolBoards).
57+
They can be installed by following the [CLP Boards installation guide](https://github.com/Legion2/CorsairLightingProtocolBoards#how-to-use-these-boards-in-arduino).
58+
After installation it should be possible to select the CLP Boards in the Arduino IDE as shown in the screenshot below.
59+
60+
![select CLP Board](extra/images/select-board.png)
61+
1. Upload the "LightingNodePRO" sketch to your Arduino.
62+
63+
![upload sketch](extra/images/upload-sketch.png)
5164
1. Do the wiring.
5265
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.
5366

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

6073
## Use the Lighting Node PRO
6174

@@ -66,23 +79,22 @@ iCUE groups the LEDs into groups of ten.
6679
So if you have 20 LEDs, set the amount to 2.
6780
Now you can create lighting effects in the "Lighting Channel #" tabs.
6881

69-
# Misc
82+
# Documentation
7083

7184
- [API Documentation](https://legion2.github.io/CorsairLightingProtocol/)
7285
- [How it works](#how-it-works)
73-
- [Use multiple Devices](#use-multiple-devices)
86+
- [Use of multiple devices](#use-of-multiple-devices)
7487
- [Repeat or scale LED channel](#repeat-or-scale-led-channel)
7588

7689
## How it works
77-
This library uses the USB HID interface of the Arduino Micro or Leonardo.
78-
In the board.txt the unique VID and PID of a "Lighting Node PRO" are defined.
79-
After uploading a sketch with the library and these IDs, iCUE recognizes the Arduino as a Lighting Node PRO.
80-
In iCUE you can then select the "Lighting Node PRO" and set some lighting effects.
81-
iCUE sends these via the CorsairLightingProtocol to the Arduino.
90+
This library uses the USB HID interface of the ATmega32U4.
91+
After uploading a sketch with the library and selected CLP Boards, iCUE recognizes the Arduino as a Corsair device, because the CLP Boards use USB IDs of Corsair.
92+
In iCUE you can then select the device and set some lighting effects.
93+
iCUE sends these via the HID protocol to the Arduino.
8294
These commands are understood by the library and converted into lighting effects on the RGB strips connected to the Arduino.
8395
The [FastLED](http://fastled.io/) library is used to control the LEDs.
8496

85-
## Use multiple Devices
97+
## Use of multiple devices
8698
Each device has two unique IDs, that is, they should be unique.
8799
You must give each device a unique ID.
88100
There are two IDs that must be changed `Serial Number` and `DeviceID`.

examples/AdditionalFeatures/board.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
#include <CorsairLightingProtocol.h>
17+
#include <FastLED.h>
18+
19+
// Hint: The channels are swapped in iCUE, so the first channel in iCUE is here channel 2
20+
#define DATA_PIN_CHANNEL_1 2 // For the monitor backlight
21+
#define DATA_PIN_CHANNEL_2 3
22+
23+
CRGB ledsChannel1[84];
24+
CRGB ledsChannel2[105];
25+
26+
CorsairLightingFirmware firmware = corsairLS100Firmware();
27+
FastLEDController ledController(true);
28+
CorsairLightingProtocolController cLP(&ledController, &firmware);
29+
CorsairLightingProtocolHID cHID(&cLP);
30+
31+
void setup() {
32+
FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_1>(ledsChannel1, 84);
33+
FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_2>(ledsChannel2, 105);
34+
ledController.addLEDs(0, ledsChannel1, 84);
35+
ledController.addLEDs(1, ledsChannel2, 105);
36+
ledController.onUpdateHook(0, []() {
37+
// gamma correction with gamma value 2.0. Use napplyGamma_video for other gamma values.
38+
CLP::gammaCorrection(&ledController, 0);
39+
//napplyGamma_video(ledsChannel1, 84, 2.2);
40+
});
41+
}
42+
43+
void loop() {
44+
cHID.update();
45+
46+
if (ledController.updateLEDs()) {
47+
FastLED.show();
48+
}
49+
}

examples/CommanderPRO/board.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/HoodLoader2CLPBridge/board.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/LS100/board.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/LightingNodeCORE/board.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/LightingNodePRO/board.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/NonAddressable/board.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/RepeatAndScale/board.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/SingleStripLightingNodePRO/board.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/TransformLLFansFormatToStrip/board.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

extra/doxygen.conf

Lines changed: 2 additions & 2 deletions
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.9.1
41+
PROJECT_NUMBER = 0.10.0
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
@@ -2099,7 +2099,7 @@ INCLUDE_FILE_PATTERNS =
20992099
# recursively expanded use the := operator instead of the = operator.
21002100
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
21012101

2102-
PREDEFINED = USBCON
2102+
PREDEFINED = USBCON ARDUINO_ARCH_AVR
21032103

21042104
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
21052105
# tag can be used to specify a list of macro names that should be expanded. The

extra/images/select-board.png

48.4 KB
Loading

extra/images/upload-sketch.png

42.6 KB
Loading

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name=Corsair Lighting Protocol
2-
version=0.9.1
2+
version=0.10.0
33
author=Leon Kiefer
44
maintainer=Leon Kiefer
55
sentence=Allows iCUE to control RGB LEDs.
66
paragraph=The library mimics a Lighting Node PRO and can be controlled as such in iCUE.
77
category=Device Control
88
url=https://github.com/Legion2/CorsairLightingProtocol
9-
architectures=*
9+
architectures=avr
1010
includes=CorsairLightingProtocol.h
1111
depends=FastLED

src/CorsairLightingFirmware.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void CorsairLightingFirmware::handleFirmwareCommand(const Command& command, cons
3333
{
3434
case READ_STATUS:
3535
{
36-
uint8_t statusData[] = { PROTOCOL_STATUS_OK };
36+
uint8_t statusData[] = { status };
3737
response->send(statusData, sizeof(statusData));
3838
break;
3939
}
@@ -76,6 +76,16 @@ void CorsairLightingFirmware::setDeviceID(const uint8_t* deviceID)
7676
EEPROM.put(EEPROM_ADDRESS_DEVICE_ID, deviceId);
7777
}
7878

79+
uint8_t CorsairLightingFirmware::getStatus()
80+
{
81+
return status;
82+
}
83+
84+
void CorsairLightingFirmware::setStatus(uint8_t a_status)
85+
{
86+
status = a_status;
87+
}
88+
7989
CorsairLightingFirmware corsairLightingNodePROFirmware()
8090
{
8191
return CorsairLightingFirmware(corsairLightingNodePROFirmwareVersion);

src/CorsairLightingFirmware.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ class CorsairLightingFirmware {
3535
void handleFirmwareCommand(const Command& command, const CorsairLightingProtocolResponse* response);
3636
void getDeviceID(uint8_t* deviceID) const;
3737
void setDeviceID(const uint8_t* deviceID);
38+
uint8_t getStatus();
39+
void setStatus(uint8_t status);
3840
protected:
3941
const uint8_t* firmwareVersion;
4042
uint8_t deviceId[4];
43+
private:
44+
uint8_t status = PROTOCOL_STATUS_OK;
4145
};
4246

4347
CorsairLightingFirmware corsairLightingNodePROFirmware();

src/CorsairLightingNodePRO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
#include "CorsairLightingNodePRO.h"
1717

18-
#if defined(USBCON)
18+
#if defined(SUPPORT_RAW_HID)
1919

2020
CorsairLightingNodePRO::CorsairLightingNodePRO() : ledController(true), cLP(&ledController, &firmware), connectionAdapter(&cLP)
2121
{

src/CorsairLightingNodePRO.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "CorsairLightingProtocolHID.h"
2323
#include <FastLED.h>
2424

25-
#if defined(USBCON)
25+
#if defined(SUPPORT_RAW_HID)
2626

2727
#define CHANNEL_LED_COUNT_DEFAULT 96
2828

src/CorsairLightingProtocolHID.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
limitations under the License.
1515
*/
1616
#include "CorsairLightingProtocolHID.h"
17-
#include "RawHID.h"
1817

19-
#if defined(USBCON)
18+
#if defined(SUPPORT_RAW_HID)
2019

2120
#if (RAWHID_TX_SIZE != RESPONSE_SIZE)
2221
#error "USB endpoint must be the same size as the protocol response"

src/CorsairLightingProtocolHID.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#include "CorsairLightingProtocolResponse.h"
2222
#include "CorsairLightingProtocolConstants.h"
2323

24-
#if defined(USBCON)
24+
#include "RawHID.h"
25+
26+
#if defined(SUPPORT_RAW_HID)
2527

2628
#if defined(DEBUG) && defined(VERBOSE)
2729
extern bool printCommand;

src/CorsairLightingProtocolResponse.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#include "CorsairLightingProtocolConstants.h"
1818

1919
void CorsairLightingProtocolResponse::send(const uint8_t* data, size_t size) const {
20-
uint8_t response[RESPONSE_SIZE];
21-
memset(response, 0x00, sizeof(response));
20+
uint8_t response[RESPONSE_SIZE] = { 0x00 };
2221
if (size + 1 > sizeof(response)) {
2322
return;
2423
}
@@ -28,18 +27,17 @@ void CorsairLightingProtocolResponse::send(const uint8_t* data, size_t size) con
2827
}
2928

3029
void CorsairLightingProtocolResponse::sendError() const {
31-
uint8_t response[RESPONSE_SIZE];
32-
memset(response, 0x00, sizeof(response));
30+
uint8_t response[RESPONSE_SIZE] = { 0x00 };
3331
response[0] = PROTOCOL_RESPONSE_ERROR;
3432
sendX(response, sizeof(response));
3533
}
3634

3735
void CorsairLightingProtocolResponse::send_P(const uint8_t* data, size_t size) const {
38-
uint8_t response[RESPONSE_SIZE];
39-
memset(response, 0x00, sizeof(response));
36+
uint8_t response[RESPONSE_SIZE] = { 0x00 };
4037
if (size + 1 > sizeof(response)) {
4138
return;
4239
}
40+
response[0] = PROTOCOL_RESPONSE_OK;
4341
memcpy_P(response + 1, data, size);
4442
sendX(response, sizeof(response));
4543
}

src/FanController.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ void FanController::handleFanControl(const Command& command, const CorsairLighti
4545
break;
4646
case FanDetectionType::Disconnected:
4747
mask[i] = FanMask::Disconnected;
48+
break;
4849
}
4950
}
5051
response->send(reinterpret_cast<byte*>(mask), sizeof(mask));

0 commit comments

Comments
 (0)