Skip to content

Commit 8b1edfc

Browse files
authored
Merge pull request #99 from Legion2/road-to-stable
Improvements for stable release
2 parents 530a334 + f8d3db4 commit 8b1edfc

File tree

22 files changed

+52
-90
lines changed

22 files changed

+52
-90
lines changed

.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: 5 additions & 7 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)](https://github.com/Legion2/CorsairLightingProtocol/actions?query=workflow%3ATest+branch%3Adev+event%3Apush)
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

@@ -88,11 +87,10 @@ Now you can create lighting effects in the "Lighting Channel #" tabs.
8887
- [Repeat or scale LED channel](#repeat-or-scale-led-channel)
8988

9089
## How it works
91-
This library uses the USB HID interface of the Arduino Micro or Leonardo.
92-
In the board.txt the unique VID and PID of a "Lighting Node PRO" are defined.
93-
After uploading a sketch with the library and these IDs, iCUE recognizes the Arduino as a Lighting Node PRO.
94-
In iCUE you can then select the "Lighting Node PRO" and set some lighting effects.
95-
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.
9694
These commands are understood by the library and converted into lighting effects on the RGB strips connected to the Arduino.
9795
The [FastLED](http://fastled.io/) library is used to control the LEDs.
9896

examples/AdditionalFeatures/board.txt

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

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

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/FastLEDController.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ bool FastLEDController::updateLEDs()
255255
}
256256
else if (tempGroup < TEMPERATURE_NUM && temperatureController != nullptr) {
257257
currentTemperature = temperatureController->getTemperature(tempGroup);
258+
} else {
259+
break;
258260
}
259261

260262
CRGB color;

src/RawHID.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
THE SOFTWARE.
2323
*/
24-
2524
#include "RawHID.h"
26-
#if defined(USBCON)
27-
#ifndef HID_REPORTID_RAWHID
28-
#define HID_REPORTID_RAWHID 0x00
29-
#endif
25+
26+
#if defined(ARDUINO_ARCH_AVR) && defined(USBCON)
3027

3128
#ifndef HID_ENDPOINT_INTERVAL_RAWHID
3229
#define HID_ENDPOINT_INTERVAL_RAWHID 0x01

src/RawHID.h

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,14 @@ THE SOFTWARE.
2626
#include <Arduino.h>
2727

2828
#if defined(ARDUINO_ARCH_AVR)
29+
#include <HID.h>
30+
#endif
2931

30-
#include "HID.h"
31-
#if defined(USBCON)
32-
33-
#define EPTYPE_DESCRIPTOR_SIZE uint8_t
34-
// HID Functional Characteristics HID1.11 Page 10 4.4 Interfaces
35-
// Interrupt Out Endpoint is optional, contoll endpoint is used by default
36-
#define ENDPOINT_COUNT 1
37-
38-
#define HID_ENDPOINT_IN pluggedEndpoint
39-
#define HID_TX HID_ENDPOINT_IN
32+
#if defined(ARDUINO_ARCH_AVR) && defined(USBCON)
33+
#define SUPPORT_RAW_HID
34+
#endif
4035

36+
#if defined(SUPPORT_RAW_HID)
4137
// RawHID might never work with multireports, because of OS problems
4238
// therefore we have to make it a single report with no idea. No other HID device will be supported then.
4339
#undef RAWHID_USAGE_PAGE
@@ -49,6 +45,18 @@ THE SOFTWARE.
4945
#define RAWHID_TX_SIZE 64
5046
#define RAWHID_RX_SIZE 64
5147

48+
#endif
49+
50+
#if defined(ARDUINO_ARCH_AVR) && defined(USBCON) // Arduino Core
51+
52+
#define EPTYPE_DESCRIPTOR_SIZE uint8_t
53+
// HID Functional Characteristics HID1.11 Page 10 4.4 Interfaces
54+
// Interrupt Out Endpoint is optional, contoll endpoint is used by default
55+
#define ENDPOINT_COUNT 1
56+
57+
#define HID_ENDPOINT_IN pluggedEndpoint
58+
#define HID_TX HID_ENDPOINT_IN
59+
5260
class RawHID_ : public PluggableUSBModule, public Stream
5361
{
5462
public:
@@ -167,4 +175,3 @@ class RawHID_ : public PluggableUSBModule, public Stream
167175
};
168176
extern RawHID_ RawHID;
169177
#endif
170-
#endif

0 commit comments

Comments
 (0)