Skip to content

Commit 9b5cdf0

Browse files
authored
Merge pull request #85 from Legion2/dev
Version 0.9.0
2 parents 68510f9 + 7849c65 commit 9b5cdf0

36 files changed

+813
-242
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]
9+
sketch: [LightingNodePRO, SingleStripLightingNodePRO, CommanderPRO, DeviceIDTool, RepeatAndScale, TransformLLFansFormatToStrip, LS100, LightingNodeCORE]
1010
board: ["arduino:avr:leonardo", "arduino:avr:micro", "SparkFun:avr:promicro:cpu=16MHzatmega32U4"]
1111
steps:
1212
- uses: actions/checkout@master

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ Then the third argument of the `scale` function is `144`.
126126
For both functions it's **important**, that the CRGB arrays have at least the length of the physical LED strip.
127127
This means if your LED channel from iCUE has 50 LEDs and you use the `repeat` function to control 100 physical LEDs you MUST declare the CRGB array at least with a length of 100.
128128

129+
# License
130+
This project is licensed under the Apache 2.0 License.
131+
129132
# DISCLAIMERS
130133
This is a DO IT YOURSELF project, use at your own risk!
131134

examples/CommanderPRO/PWMFan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PWMFan::PWMFan(uint8_t pwmPin, uint16_t minRPM ,uint16_t maxRPM) : pwmPin(pwmPin
2323
case TIMER0B:/* 3 */
2424
#ifdef DEBUG
2525
Serial.println(F("Pin not supported as PWM fan pin"));
26-
Serial.println(F("We don't want to mess up arduino time functions"));
26+
Serial.println(F("We don't want to mess up Arduino time functions"));
2727
#endif // DEBUG
2828
break;
2929
case TIMER3A:/* 5 */

examples/CommanderPRO/PWMFan.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@
1919

2020
class PWMFan {
2121
public:
22-
// minRPM should be the rpm value at 0% power and maxRPM at 100% power
23-
// These values are used to map speed to power using linear interpolation
22+
/**
23+
* PWM fan which maps speed to power using linear interpolation.
24+
* This fan does not read the real RPM values. The Arduino timer for the given pin will be set to higher speed.
25+
*
26+
* @param pwmPin the Arduino pwm pin for this fan. Not all PWM pins are supported.
27+
* @param minRPM the speed in RPM at 0% power
28+
* @param maxRPM the speed in RPM at 100% power
29+
*/
2430
PWMFan(uint8_t pwmPin, uint16_t minRPM, uint16_t maxRPM);
2531
virtual void setPower(uint8_t percentage);
2632
virtual uint8_t calculatePowerFromSpeed(uint16_t rpm);

examples/CommanderPRO/SimpleFanController.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ bool SimpleFanController::updateFans()
4545
long currentUpdateNumber = currentUpdate / updateRate;
4646
lastUpdate = currentUpdate;
4747
if (lastUpdateNumber < currentUpdateNumber) {
48-
if (trigger_save) {
49-
trigger_save = false;
48+
if (triggerSave) {
49+
triggerSave = false;
5050
save();
5151
}
5252

@@ -106,7 +106,7 @@ void SimpleFanController::setFanSpeed(uint8_t fan, uint16_t speed)
106106
fanData[fan].speed = speed;
107107
fanData[fan].mode = FAN_CONTROL_MODE_FIXED_RPM;
108108
fanData[fan].power = fans[fan] != nullptr ? fans[fan]->calculatePowerFromSpeed(speed) : 0;
109-
trigger_save = true;
109+
triggerSave = true;
110110
}
111111

112112
uint8_t SimpleFanController::getFanPower(uint8_t fan)
@@ -119,15 +119,15 @@ void SimpleFanController::setFanPower(uint8_t fan, uint8_t percentage)
119119
fanData[fan].power = percentage;
120120
fanData[fan].mode = FAN_CONTROL_MODE_FIXED_POWER;
121121
fanData[fan].speed = fans[fan] != nullptr ? fans[fan]->calculateSpeedFromPower(percentage) : 0;
122-
trigger_save = true;
122+
triggerSave = true;
123123
}
124124

125125
void SimpleFanController::setFanCurve(uint8_t fan, uint8_t group, FanCurve& fanCurve)
126126
{
127127
fanData[fan].fanCurve = fanCurve;
128128
fanData[fan].tempGroup = group;
129129
fanData[fan].mode = FAN_CONTROL_MODE_CURVE;
130-
trigger_save = true;
130+
triggerSave = true;
131131
}
132132

133133
void SimpleFanController::setFanExternalTemperature(uint8_t fan, uint16_t temp)
@@ -140,16 +140,16 @@ void SimpleFanController::setFanForce3PinMode(bool flag)
140140
force3PinMode = flag;
141141
}
142142

143-
uint8_t SimpleFanController::getFanDetectionType(uint8_t fan)
143+
FanDetectionType SimpleFanController::getFanDetectionType(uint8_t fan)
144144
{
145145
return fanData[fan].detectionType;
146146
}
147147

148-
void SimpleFanController::setFanDetectionType(uint8_t fan, uint8_t type)
148+
void SimpleFanController::setFanDetectionType(uint8_t fan, FanDetectionType type)
149149
{
150150
if (fanData[fan].detectionType != type) {
151151
fanData[fan].detectionType = type;
152-
trigger_save = true;
152+
triggerSave = true;
153153
}
154154
}
155155

examples/CommanderPRO/SimpleFanController.h

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,35 @@ struct FanData {
2828
uint8_t mode = FAN_CONTROL_MODE_FIXED_POWER;
2929
uint8_t power = 0;
3030
uint16_t speed = 0;
31-
uint8_t detectionType = FAN_DETECTION_TYPE_DISCONNECTED;
31+
FanDetectionType detectionType = FanDetectionType::Disconnected;
3232
uint8_t tempGroup;
3333
FanCurve fanCurve;
3434
};
3535

36-
// This simple Fan Controller implementation does not implement all features of a Fan Controller.
37-
// It should only demonstrate how to implement your own Fan Controller.
36+
/**
37+
* This simple Fan Controller implementation does not implement all features of a Fan Controller.
38+
* It should only demonstrate how to implement your own Fan Controller.
39+
*/
3840
class SimpleFanController : public FanController {
3941
public:
40-
// Fan Contorller must use the EEPROM else on startup the fans can't be controlled
41-
// updateRate it the time between fan speed updates in ms
42+
/**
43+
* Fan Controller must use the EEPROM else on startup the fans can't be controlled
44+
*
45+
* @param temperatureController the TemperatureController used to get the temperature to control the fans
46+
* @param updateRate is the time between fan speed updates in ms
47+
* @param eEPROMAdress the address where the data is stored in EEPROM
48+
*/
4249
SimpleFanController(TemperatureController* temperatureController, uint16_t updateRate, uint16_t eEPROMAdress);
50+
/**
51+
* Add a fan to the Controller.
52+
*
53+
* @param index the index of the fan
54+
* @param fan the fan object
55+
*/
4356
void addFan(uint8_t index, PWMFan* fan);
57+
/**
58+
* Update the fan speeds based on the temperature and commands.
59+
*/
4460
virtual bool updateFans();
4561
protected:
4662
virtual uint16_t getFanSpeed(uint8_t fan) override;
@@ -50,8 +66,8 @@ class SimpleFanController : public FanController {
5066
virtual void setFanCurve(uint8_t fan, uint8_t group, FanCurve& fanCurve) override;
5167
virtual void setFanExternalTemperature(uint8_t fan, uint16_t temp) override;
5268
virtual void setFanForce3PinMode(bool flag) override;
53-
virtual uint8_t getFanDetectionType(uint8_t fan) override;
54-
virtual void setFanDetectionType(uint8_t fan, uint8_t type) override;
69+
virtual FanDetectionType getFanDetectionType(uint8_t fan) override;
70+
virtual void setFanDetectionType(uint8_t fan, FanDetectionType type) override;
5571
bool load();
5672
bool save();
5773

@@ -62,6 +78,9 @@ class SimpleFanController : public FanController {
6278
uint16_t externalTemp[FAN_NUM];
6379
uint16_t updateRate;
6480
uint16_t eEPROMAdress;
65-
bool trigger_save = false;
81+
/**
82+
* Indicates that the configuration of the fans has been changed and should be saved.
83+
*/
84+
bool triggerSave = false;
6685
long lastUpdate = 0;
6786
};

examples/CommanderPRO/ThermistorTemperatureController.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,24 @@
1616
#pragma once
1717

1818
#include "TemperatureController.h"
19-
/*
20-
Thermistor Schematic :
21-
| ---- [10k - Resistor] ----- | ----- [Thermistor] ---- |
22-
| | |
23-
[Ground] Analog Pin [+5v]
24-
*/
19+
/**
20+
* This TemperatureController uses Thermistors and Resistors to messure the temperature. It does not implement the voltage rail measurements.
21+
*
22+
* Thermistor Schematic:
23+
* <pre>
24+
* | ---- [10k - Resistor] ---- | ---- [Thermistor] ---- |
25+
* | | |
26+
* [Ground] Analog Pin [+5v]
27+
* </pre>
28+
*/
2529
class ThermistorTemperatureController : public TemperatureController {
2630
public:
31+
/**
32+
* Add a Sensor to the TemperatureController using an Arduino analog pin connected as shown in {@link ThermistorTemperatureController}.
33+
*
34+
* @param index the index of the sensorPins
35+
* @param pin the Arduino analog pin
36+
*/
2737
void addSensor(uint8_t index, uint8_t pin);
2838
protected:
2939
virtual uint16_t getTemperatureValue(uint8_t temperatureSensor) override;

examples/LS100/LS100.ino

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#define DATA_PIN_CHANNEL_1 2
2121
#define DATA_PIN_CHANNEL_2 3
2222

23+
#define BUTTON_PIN 4
24+
2325
CRGB ledsChannel1[135];
2426
CRGB ledsChannel2[135];
2527

@@ -33,12 +35,37 @@ void setup() {
3335
FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_2>(ledsChannel2, 135);
3436
ledController.addLEDs(0, ledsChannel1, 135);
3537
ledController.addLEDs(1, ledsChannel2, 135);
38+
pinMode(BUTTON_PIN, INPUT_PULLUP);
3639
}
3740

3841
void loop() {
42+
static bool lightingEnabled = true;
3943
cHID.update();
4044

41-
if (ledController.updateLEDs()) {
42-
FastLED.show();
45+
if (buttonClicked()) {
46+
lightingEnabled = !lightingEnabled;
47+
fill_solid(ledsChannel1, 135, CRGB::Black);
48+
fill_solid(ledsChannel2, 135, CRGB::Black);
49+
FastLED.show();
50+
}
51+
52+
if (lightingEnabled && ledController.updateLEDs()) {
53+
FastLED.show();
4354
}
4455
}
56+
57+
/**
58+
* Handle button of the LS100. The button is optional.
59+
*
60+
* @return true if the button was pressed and then released.
61+
*/
62+
bool buttonClicked() {
63+
static bool previousState = 1;
64+
bool state = digitalRead(BUTTON_PIN);
65+
if (previousState == 0 && state == 1) {
66+
previousState = state;
67+
return true;
68+
}
69+
previousState = state;
70+
return false;
71+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Copyright 2019 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+
#define DATA_PIN_CHANNEL_1 2
20+
21+
CRGB ledsChannel1[204];
22+
23+
CorsairLightingFirmware firmware = corsairLightingNodeCOREFirmware();
24+
FastLEDController ledController(true);
25+
CorsairLightingProtocolController cLP(&ledController, &firmware);
26+
CorsairLightingProtocolHID cHID(&cLP);
27+
28+
void setup() {
29+
FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_1>(ledsChannel1, 204);
30+
ledController.addLEDs(0, ledsChannel1, 204);
31+
}
32+
33+
void loop() {
34+
cHID.update();
35+
36+
if (ledController.updateLEDs()) {
37+
FastLED.show();
38+
}
39+
}

examples/LightingNodeCORE/board.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# CorsairLightingProtocol build property overrides
2+
3+
build.vid=0x1b1c
4+
build.pid=0x0c1a
5+
build.usb_product="Lighting Node CORE"
6+
build.usb_manufacturer="Corsair"

examples/SingleStripLightingNodePRO/SingleStripLightingNodePRO.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// The number of LEDs per channel.
2020
#define CHANNEL_LED_COUNT 50
2121

22-
// Total count of LEDs on all channels, the value is calculated based on the leds per channel.
22+
// Total count of LEDs on all channels, the value is calculated based on the LEDs per channel.
2323
#define NUM_LEDS (CHANNEL_LED_COUNT * 2)
2424

2525
// The Arduino pin where the physical LEDs are connected.

extra/doxygen.conf

Lines changed: 1 addition & 1 deletion
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.8.0
41+
PROJECT_NUMBER = 0.9.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

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Corsair Lighting Protocol
2-
version=0.8.0
2+
version=0.9.0
33
author=Leon Kiefer
44
maintainer=Leon Kiefer
55
sentence=Allows iCUE to control RGB LEDs.

src/CLPUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace CLP
5858
bool isResetID(const uint8_t* deviceId);
5959

6060
/**
61-
* This will disable the RX and TX built in leds on Arduino Leonardo, Micro and Pro Micro.
61+
* This will disable the RX and TX built in LEDs on Arduino Leonardo, Micro and Pro Micro.
6262
*/
6363
void disableBuildInLEDs();
6464

src/CorsairLightingFirmware.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ void CorsairLightingFirmware::handleFirmwareCommand(const Command& command, cons
5858
response->send_P(bootloader_version, sizeof(bootloader_version));
5959
break;
6060
}
61+
default:
62+
{
63+
response->sendError();
64+
}
6165
}
6266
}
6367

@@ -77,6 +81,11 @@ CorsairLightingFirmware corsairLightingNodePROFirmware()
7781
return CorsairLightingFirmware(corsairLightingNodePROFirmwareVersion);
7882
}
7983

84+
CorsairLightingFirmware corsairLightingNodeCOREFirmware()
85+
{
86+
return CorsairLightingFirmware(corsairLightingNodePROFirmwareVersion);
87+
}
88+
8089
CorsairLightingFirmware corsairLS100Firmware()
8190
{
8291
return CorsairLightingFirmware(corsairLightingNodePROFirmwareVersion);

src/CorsairLightingFirmware.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class CorsairLightingFirmware {
4242

4343
CorsairLightingFirmware corsairLightingNodePROFirmware();
4444

45+
CorsairLightingFirmware corsairLightingNodeCOREFirmware();
46+
4547
CorsairLightingFirmware corsairLS100Firmware();
4648

4749
CorsairLightingFirmware corsairCommanderPROFirmware();

src/CorsairLightingNodePRO.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "Arduino.h"
1919
#include "CorsairLightingFirmware.h"
2020
#include "FastLEDController.h"
21-
#include "CorsairLightingProtocol.h"
21+
#include "CorsairLightingProtocolController.h"
2222
#include "CorsairLightingProtocolHID.h"
2323
#include <FastLED.h>
2424

src/CorsairLightingProtocol.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
*/
1616
#pragma once
1717

18-
// central include file for CorsairLightingProtocolController
18+
/**
19+
* @file
20+
* The central include file for CorsairLightingProtocol.
21+
*/
1922
#include "CorsairLightingFirmware.h"
2023
#include "CorsairLightingNodePRO.h"
2124
#include "CorsairLightingProtocolConstants.h"

0 commit comments

Comments
 (0)