Skip to content

Commit

Permalink
Merge pull request #124 from Legion2/dev
Browse files Browse the repository at this point in the history
Version 0.11.0
  • Loading branch information
Legion2 authored Apr 15, 2020
2 parents 1627603 + 4fd82a1 commit ae284f2
Show file tree
Hide file tree
Showing 54 changed files with 1,319 additions and 1,374 deletions.
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BasedOnStyle: Google
ColumnLimit: 120
IndentWidth: 4
TabWidth: 4
UseTab: ForContinuationAndIndentation
AccessModifierOffset: -4
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = tab
indent_size = 4
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true

[*.{yml,yaml}]
indent_style = space
indent_size = 2
22 changes: 22 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Check Code Format

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Check src format
uses: DoozyX/[email protected]
with:
source: './src'
extensions: 'h,cpp'
clangFormatVersion: 9
- name: Check examples format
uses: DoozyX/[email protected]
with:
source: './examples'
extensions: 'h,cpp,ino'
clangFormatVersion: 9
114 changes: 47 additions & 67 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,65 @@ on: [push, pull_request]
name: Test
jobs:
test:
name: Test ${{ matrix.sketch }} for ${{ matrix.board }}
name: Test for ${{ matrix.board }}
runs-on: ubuntu-latest
strategy:
matrix:
sketch: [LightingNodePRO, SingleStripLightingNodePRO, CommanderPRO, DeviceIDTool, RepeatAndScale, TransformLLFansFormatToStrip, LS100, LightingNodeCORE, NonAddressable, AmbientBacklight]
board: ["arduino:avr:leonardo", "arduino:avr:micro", "SparkFun:avr:promicro:cpu=16MHzatmega32U4"]
board:
[
"Legion2:avr:leonardoclp",
"Legion2:avr:promicro5vclp",
"Legion2:avr:promicro3vclp",
]
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/[email protected]
with:
board: ${{ matrix.board }}
sketch: ./examples/${{ matrix.sketch }}/${{ matrix.sketch }}.ino
- uses: actions/checkout@master
- name: Build for ${{ matrix.board }}
uses: ArminJo/[email protected]
with:
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],SparkFun:[email protected],Legion2:[email protected]
required-libraries: [email protected]
sketch-names: LightingNodePRO.ino,
SingleStripLightingNodePRO.ino,
CommanderPRO.ino,
DeviceIDTool.ino,
RepeatAndScale.ino,
TransformLLFansFormatToStrip.ino,
LS100.ino,
LightingNodeCORE.ino,
NonAddressable.ino,
AmbientBacklight.ino,
DebugSketch.ino
examples-build-properties: '{"DebugSketch": "-DDEBUG -DVERBOSE -DPRINT_COMMAND=true -DPRINT_RESPONSE=true -DPRINT_LOOP=true -DPRINT_UPDATE=true"}'
testUnoMega:
name: Test UnoMega ${{ matrix.sketch }} for ${{ matrix.board }}
name: Test UnoMega sketches 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/[email protected]
with:
board: ${{ matrix.board }}
sketch: ./examples/${{ matrix.sketch }}/${{ matrix.sketch }}.ino
- uses: actions/checkout@master
- name: Build for ${{ matrix.board }}
uses: ArminJo/[email protected]
with:
arduino-board-fqbn: ${{ matrix.board }}
arduino-platform: arduino:[email protected]
required-libraries: [email protected]
sketch-names: HoodLoader2UnoMegaController.ino
test16u2:
name: Test 16u2 ${{ matrix.sketch }} for ${{ matrix.board }}
name: Test 16u2 sketch for ${{ matrix.board }}
runs-on: ubuntu-latest
strategy:
matrix:
sketch: [HoodLoader2CLPBridge]
board: ["HoodLoader2:avr:HoodLoader2atmega16u2:board=uno", "HoodLoader2:avr:HoodLoader2atmega16u2:board=mega2560"]
board: ["Legion2:avr:HoodLoader2atmega16u2clp"]
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/[email protected]
with:
board: ${{ matrix.board }}
sketch: ./examples/${{ matrix.sketch }}/${{ matrix.sketch }}.ino
- uses: actions/checkout@master
- name: Build for ${{ matrix.board }}
uses: ArminJo/[email protected]
with:
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],HoodLoader2:[email protected],Legion2:[email protected]
required-libraries: [email protected]
sketch-names: HoodLoader2CLPBridge.ino
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,7 @@ __vm/

# VS Code settings
.vscode/

# Arduino CLI
*.elf
*.hex
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
**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.
* Add support of Corsair DIY device protocol to Arduino.
* Control LEDs with the [Corsair iCUE software](https://www.corsair.com/icue).
* Easy to use with [FastLED](http://fastled.io/).
* [Supported LED chipsets](https://github.com/FastLED/FastLED/wiki/Overview#chipsets).
* [Supported LED chipsets](https://github.com/FastLED/FastLED/wiki/Overview#chipsets). (e.g. WS2812B, WS2801)
* Supported platform: Arduino AVR
* Persistent settings for use without a USB connection.
* Use multiple devices at the same time.
* Repeat or scale LED channels to arbitrary size.
Expand Down
10 changes: 10 additions & 0 deletions examples/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
BasedOnStyle: Google
ColumnLimit: 120
IndentWidth: 4
TabWidth: 4
UseTab: ForContinuationAndIndentation
AccessModifierOffset: -4

AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortLambdasOnASingleLine: false
4 changes: 2 additions & 2 deletions examples/AmbientBacklight/AmbientBacklight.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <FastLED.h>

// Hint: The channels are swapped in iCUE, so the first channel in iCUE is here channel 2
#define DATA_PIN_CHANNEL_1 2 // For the monitor backlight
#define DATA_PIN_CHANNEL_1 2 // For the monitor backlight
#define DATA_PIN_CHANNEL_2 3

CRGB ledsChannel1[84];
Expand All @@ -36,7 +36,7 @@ void setup() {
ledController.onUpdateHook(0, []() {
// gamma correction with gamma value 2.0. Use napplyGamma_video for other gamma values.
CLP::gammaCorrection(&ledController, 0);
//napplyGamma_video(ledsChannel1, 84, 2.2);
// napplyGamma_video(ledsChannel1, 84, 2.2);
});
}

Expand Down
10 changes: 6 additions & 4 deletions examples/CommanderPRO/CommanderPRO.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "SimpleFanController.h"
#include "ThermistorTemperatureController.h"
#include <CorsairLightingProtocol.h>
#include <FastLED.h>

#include "SimpleFanController.h"
#include "ThermistorTemperatureController.h"

#define DATA_PIN_CHANNEL_1 2
#define DATA_PIN_CHANNEL_2 3

Expand All @@ -35,7 +36,8 @@
CorsairLightingFirmware firmware = corsairCommanderPROFirmware();
ThermistorTemperatureController temperatureController;
FastLEDController ledController(&temperatureController, true);
SimpleFanController fanController(&temperatureController, FAN_UPDATE_RATE, EEPROM_ADDRESS + ledController.getEEPROMSize());
SimpleFanController fanController(&temperatureController, FAN_UPDATE_RATE,
EEPROM_ADDRESS + ledController.getEEPROMSize());
CorsairLightingProtocolController cLP(&ledController, &temperatureController, &fanController, &firmware);
CorsairLightingProtocolHID cHID(&cLP);

Expand Down Expand Up @@ -68,4 +70,4 @@ void loop() {
FastLED.show();
}
fanController.updateFans();
}
}
56 changes: 26 additions & 30 deletions examples/CommanderPRO/PWMFan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,46 @@
*/
#include "PWMFan.h"

PWMFan::PWMFan(uint8_t pwmPin, uint16_t minRPM ,uint16_t maxRPM) : pwmPin(pwmPin), minRPM(minRPM), maxRPM(maxRPM)
{
PWMFan::PWMFan(uint8_t pwmPin, uint16_t minRPM, uint16_t maxRPM) : pwmPin(pwmPin), minRPM(minRPM), maxRPM(maxRPM) {
pinMode(pwmPin, OUTPUT);
analogWrite(pwmPin, 0);
switch (digitalPinToTimer(pwmPin)) {
case TIMER0B:/* 3 */
case TIMER0B: /* 3 */
#ifdef DEBUG
Serial.println(F("Pin not supported as PWM fan pin"));
Serial.println(F("We don't want to mess up Arduino time functions"));
#endif // DEBUG
break;
case TIMER3A:/* 5 */
TCCR3B = (TCCR3B & B11111000) | 0x01;
break;
case TIMER4D:/* 6 */
//PLLFRQ = (PLLFRQ & B11001111) | (0x03 << PLLTM0);
TCCR4B = (TCCR4B & B11110000) | 0x01;
break;
case TIMER1A:/* 9 */
TCCR1B = (TCCR1B & B11111000) | 0x01;
break;
case TIMER1B:/* 10 */
TCCR1B = (TCCR1B & B11111000) | 0x01;
break;
default:
Serial.println(F("Pin not supported as PWM fan pin"));
Serial.println(F("We don't want to mess up Arduino time functions"));
#endif // DEBUG
break;
case TIMER3A: /* 5 */
TCCR3B = (TCCR3B & B11111000) | 0x01;
break;
case TIMER4D: /* 6 */
// PLLFRQ = (PLLFRQ & B11001111) | (0x03 << PLLTM0);
TCCR4B = (TCCR4B & B11110000) | 0x01;
break;
case TIMER1A: /* 9 */
TCCR1B = (TCCR1B & B11111000) | 0x01;
break;
case TIMER1B: /* 10 */
TCCR1B = (TCCR1B & B11111000) | 0x01;
break;
default:
#ifdef DEBUG
Serial.println(F("Pin not supported as PWM fan pin"));
#endif // DEBUG
break;
Serial.println(F("Pin not supported as PWM fan pin"));
#endif // DEBUG
break;
}
}

void PWMFan::setPower(uint8_t percentage)
{
void PWMFan::setPower(uint8_t percentage) {
analogWrite(pwmPin, percentage);
}

uint8_t PWMFan::calculatePowerFromSpeed(uint16_t rpm)
{
uint8_t PWMFan::calculatePowerFromSpeed(uint16_t rpm) {
rpm = constrain(rpm, minRPM, maxRPM);
return ((float)(rpm - minRPM) / (float)(maxRPM - minRPM)) * 255;
}

uint16_t PWMFan::calculateSpeedFromPower(uint8_t power)
{
uint16_t PWMFan::calculateSpeedFromPower(uint8_t power) {
return map(power, 0, 255, minRPM, maxRPM);
}
7 changes: 4 additions & 3 deletions examples/CommanderPRO/PWMFan.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
class PWMFan {
public:
/**
* PWM fan which maps speed to power using linear interpolation.
* This fan does not read the real RPM values. The Arduino timer for the given pin will be set to higher speed.
*
* PWM fan which maps speed to power using linear interpolation. This fan does not read the real RPM values. The
* Arduino timer for the given pin will be set to higher speed.
*
* @param pwmPin the Arduino pwm pin for this fan. Not all PWM pins are supported.
* @param minRPM the speed in RPM at 0% power
* @param maxRPM the speed in RPM at 100% power
Expand All @@ -31,6 +31,7 @@ class PWMFan {
virtual void setPower(uint8_t percentage);
virtual uint8_t calculatePowerFromSpeed(uint16_t rpm);
virtual uint16_t calculateSpeedFromPower(uint8_t power);

protected:
const uint8_t pwmPin;
const uint16_t minRPM;
Expand Down
Loading

0 comments on commit ae284f2

Please sign in to comment.