Skip to content

Commit

Permalink
Merge pull request #85 from Legion2/dev
Browse files Browse the repository at this point in the history
Version 0.9.0
  • Loading branch information
Legion2 authored Dec 23, 2019
2 parents 68510f9 + 7849c65 commit 9b5cdf0
Show file tree
Hide file tree
Showing 36 changed files with 813 additions and 242 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
sketch: [LightingNodePRO, SingleStripLightingNodePRO, CommanderPRO, DeviceIDTool, RepeatAndScale, TransformLLFansFormatToStrip, LS100]
sketch: [LightingNodePRO, SingleStripLightingNodePRO, CommanderPRO, DeviceIDTool, RepeatAndScale, TransformLLFansFormatToStrip, LS100, LightingNodeCORE]
board: ["arduino:avr:leonardo", "arduino:avr:micro", "SparkFun:avr:promicro:cpu=16MHzatmega32U4"]
steps:
- uses: actions/checkout@master
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ Then the third argument of the `scale` function is `144`.
For both functions it's **important**, that the CRGB arrays have at least the length of the physical LED strip.
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.

# License
This project is licensed under the Apache 2.0 License.

# DISCLAIMERS
This is a DO IT YOURSELF project, use at your own risk!

Expand Down
2 changes: 1 addition & 1 deletion examples/CommanderPRO/PWMFan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PWMFan::PWMFan(uint8_t pwmPin, uint16_t minRPM ,uint16_t maxRPM) : pwmPin(pwmPin
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"));
Serial.println(F("We don't want to mess up Arduino time functions"));
#endif // DEBUG
break;
case TIMER3A:/* 5 */
Expand Down
10 changes: 8 additions & 2 deletions examples/CommanderPRO/PWMFan.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@

class PWMFan {
public:
// minRPM should be the rpm value at 0% power and maxRPM at 100% power
// These values are used to map speed to power using linear interpolation
/**
* 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
*/
PWMFan(uint8_t pwmPin, uint16_t minRPM, uint16_t maxRPM);
virtual void setPower(uint8_t percentage);
virtual uint8_t calculatePowerFromSpeed(uint16_t rpm);
Expand Down
16 changes: 8 additions & 8 deletions examples/CommanderPRO/SimpleFanController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ bool SimpleFanController::updateFans()
long currentUpdateNumber = currentUpdate / updateRate;
lastUpdate = currentUpdate;
if (lastUpdateNumber < currentUpdateNumber) {
if (trigger_save) {
trigger_save = false;
if (triggerSave) {
triggerSave = false;
save();
}

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

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

void SimpleFanController::setFanCurve(uint8_t fan, uint8_t group, FanCurve& fanCurve)
{
fanData[fan].fanCurve = fanCurve;
fanData[fan].tempGroup = group;
fanData[fan].mode = FAN_CONTROL_MODE_CURVE;
trigger_save = true;
triggerSave = true;
}

void SimpleFanController::setFanExternalTemperature(uint8_t fan, uint16_t temp)
Expand All @@ -140,16 +140,16 @@ void SimpleFanController::setFanForce3PinMode(bool flag)
force3PinMode = flag;
}

uint8_t SimpleFanController::getFanDetectionType(uint8_t fan)
FanDetectionType SimpleFanController::getFanDetectionType(uint8_t fan)
{
return fanData[fan].detectionType;
}

void SimpleFanController::setFanDetectionType(uint8_t fan, uint8_t type)
void SimpleFanController::setFanDetectionType(uint8_t fan, FanDetectionType type)
{
if (fanData[fan].detectionType != type) {
fanData[fan].detectionType = type;
trigger_save = true;
triggerSave = true;
}
}

Expand Down
35 changes: 27 additions & 8 deletions examples/CommanderPRO/SimpleFanController.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,35 @@ struct FanData {
uint8_t mode = FAN_CONTROL_MODE_FIXED_POWER;
uint8_t power = 0;
uint16_t speed = 0;
uint8_t detectionType = FAN_DETECTION_TYPE_DISCONNECTED;
FanDetectionType detectionType = FanDetectionType::Disconnected;
uint8_t tempGroup;
FanCurve fanCurve;
};

// This simple Fan Controller implementation does not implement all features of a Fan Controller.
// It should only demonstrate how to implement your own Fan Controller.
/**
* This simple Fan Controller implementation does not implement all features of a Fan Controller.
* It should only demonstrate how to implement your own Fan Controller.
*/
class SimpleFanController : public FanController {
public:
// Fan Contorller must use the EEPROM else on startup the fans can't be controlled
// updateRate it the time between fan speed updates in ms
/**
* Fan Controller must use the EEPROM else on startup the fans can't be controlled
*
* @param temperatureController the TemperatureController used to get the temperature to control the fans
* @param updateRate is the time between fan speed updates in ms
* @param eEPROMAdress the address where the data is stored in EEPROM
*/
SimpleFanController(TemperatureController* temperatureController, uint16_t updateRate, uint16_t eEPROMAdress);
/**
* Add a fan to the Controller.
*
* @param index the index of the fan
* @param fan the fan object
*/
void addFan(uint8_t index, PWMFan* fan);
/**
* Update the fan speeds based on the temperature and commands.
*/
virtual bool updateFans();
protected:
virtual uint16_t getFanSpeed(uint8_t fan) override;
Expand All @@ -50,8 +66,8 @@ class SimpleFanController : public FanController {
virtual void setFanCurve(uint8_t fan, uint8_t group, FanCurve& fanCurve) override;
virtual void setFanExternalTemperature(uint8_t fan, uint16_t temp) override;
virtual void setFanForce3PinMode(bool flag) override;
virtual uint8_t getFanDetectionType(uint8_t fan) override;
virtual void setFanDetectionType(uint8_t fan, uint8_t type) override;
virtual FanDetectionType getFanDetectionType(uint8_t fan) override;
virtual void setFanDetectionType(uint8_t fan, FanDetectionType type) override;
bool load();
bool save();

Expand All @@ -62,6 +78,9 @@ class SimpleFanController : public FanController {
uint16_t externalTemp[FAN_NUM];
uint16_t updateRate;
uint16_t eEPROMAdress;
bool trigger_save = false;
/**
* Indicates that the configuration of the fans has been changed and should be saved.
*/
bool triggerSave = false;
long lastUpdate = 0;
};
22 changes: 16 additions & 6 deletions examples/CommanderPRO/ThermistorTemperatureController.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@
#pragma once

#include "TemperatureController.h"
/*
Thermistor Schematic :
| ---- [10k - Resistor] ----- | ----- [Thermistor] ---- |
| | |
[Ground] Analog Pin [+5v]
*/
/**
* This TemperatureController uses Thermistors and Resistors to messure the temperature. It does not implement the voltage rail measurements.
*
* Thermistor Schematic:
* <pre>
* | ---- [10k - Resistor] ---- | ---- [Thermistor] ---- |
* | | |
* [Ground] Analog Pin [+5v]
* </pre>
*/
class ThermistorTemperatureController : public TemperatureController {
public:
/**
* Add a Sensor to the TemperatureController using an Arduino analog pin connected as shown in {@link ThermistorTemperatureController}.
*
* @param index the index of the sensorPins
* @param pin the Arduino analog pin
*/
void addSensor(uint8_t index, uint8_t pin);
protected:
virtual uint16_t getTemperatureValue(uint8_t temperatureSensor) override;
Expand Down
31 changes: 29 additions & 2 deletions examples/LS100/LS100.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#define DATA_PIN_CHANNEL_1 2
#define DATA_PIN_CHANNEL_2 3

#define BUTTON_PIN 4

CRGB ledsChannel1[135];
CRGB ledsChannel2[135];

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

void loop() {
static bool lightingEnabled = true;
cHID.update();

if (ledController.updateLEDs()) {
FastLED.show();
if (buttonClicked()) {
lightingEnabled = !lightingEnabled;
fill_solid(ledsChannel1, 135, CRGB::Black);
fill_solid(ledsChannel2, 135, CRGB::Black);
FastLED.show();
}

if (lightingEnabled && ledController.updateLEDs()) {
FastLED.show();
}
}

/**
* Handle button of the LS100. The button is optional.
*
* @return true if the button was pressed and then released.
*/
bool buttonClicked() {
static bool previousState = 1;
bool state = digitalRead(BUTTON_PIN);
if (previousState == 0 && state == 1) {
previousState = state;
return true;
}
previousState = state;
return false;
}
39 changes: 39 additions & 0 deletions examples/LightingNodeCORE/LightingNodeCORE.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright 2019 Leon Kiefer
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <CorsairLightingProtocol.h>
#include <FastLED.h>

#define DATA_PIN_CHANNEL_1 2

CRGB ledsChannel1[204];

CorsairLightingFirmware firmware = corsairLightingNodeCOREFirmware();
FastLEDController ledController(true);
CorsairLightingProtocolController cLP(&ledController, &firmware);
CorsairLightingProtocolHID cHID(&cLP);

void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_1>(ledsChannel1, 204);
ledController.addLEDs(0, ledsChannel1, 204);
}

void loop() {
cHID.update();

if (ledController.updateLEDs()) {
FastLED.show();
}
}
6 changes: 6 additions & 0 deletions examples/LightingNodeCORE/board.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# CorsairLightingProtocol build property overrides

build.vid=0x1b1c
build.pid=0x0c1a
build.usb_product="Lighting Node CORE"
build.usb_manufacturer="Corsair"
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// The number of LEDs per channel.
#define CHANNEL_LED_COUNT 50

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

// The Arduino pin where the physical LEDs are connected.
Expand Down
2 changes: 1 addition & 1 deletion extra/doxygen.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "Corsair Lighting Protocol"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.8.0
PROJECT_NUMBER = 0.9.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Corsair Lighting Protocol
version=0.8.0
version=0.9.0
author=Leon Kiefer
maintainer=Leon Kiefer
sentence=Allows iCUE to control RGB LEDs.
Expand Down
2 changes: 1 addition & 1 deletion src/CLPUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace CLP
bool isResetID(const uint8_t* deviceId);

/**
* This will disable the RX and TX built in leds on Arduino Leonardo, Micro and Pro Micro.
* This will disable the RX and TX built in LEDs on Arduino Leonardo, Micro and Pro Micro.
*/
void disableBuildInLEDs();

Expand Down
9 changes: 9 additions & 0 deletions src/CorsairLightingFirmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ void CorsairLightingFirmware::handleFirmwareCommand(const Command& command, cons
response->send_P(bootloader_version, sizeof(bootloader_version));
break;
}
default:
{
response->sendError();
}
}
}

Expand All @@ -77,6 +81,11 @@ CorsairLightingFirmware corsairLightingNodePROFirmware()
return CorsairLightingFirmware(corsairLightingNodePROFirmwareVersion);
}

CorsairLightingFirmware corsairLightingNodeCOREFirmware()
{
return CorsairLightingFirmware(corsairLightingNodePROFirmwareVersion);
}

CorsairLightingFirmware corsairLS100Firmware()
{
return CorsairLightingFirmware(corsairLightingNodePROFirmwareVersion);
Expand Down
2 changes: 2 additions & 0 deletions src/CorsairLightingFirmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class CorsairLightingFirmware {

CorsairLightingFirmware corsairLightingNodePROFirmware();

CorsairLightingFirmware corsairLightingNodeCOREFirmware();

CorsairLightingFirmware corsairLS100Firmware();

CorsairLightingFirmware corsairCommanderPROFirmware();
2 changes: 1 addition & 1 deletion src/CorsairLightingNodePRO.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "Arduino.h"
#include "CorsairLightingFirmware.h"
#include "FastLEDController.h"
#include "CorsairLightingProtocol.h"
#include "CorsairLightingProtocolController.h"
#include "CorsairLightingProtocolHID.h"
#include <FastLED.h>

Expand Down
5 changes: 4 additions & 1 deletion src/CorsairLightingProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
#pragma once

// central include file for CorsairLightingProtocolController
/**
* @file
* The central include file for CorsairLightingProtocol.
*/
#include "CorsairLightingFirmware.h"
#include "CorsairLightingNodePRO.h"
#include "CorsairLightingProtocolConstants.h"
Expand Down
Loading

0 comments on commit 9b5cdf0

Please sign in to comment.