Skip to content

Commit c59f81a

Browse files
authored
Merge pull request #154 from Legion2/lt100
added support for LT100 Smart Lighting Towers
2 parents 6e64953 + de973ea commit c59f81a

9 files changed

+84
-0
lines changed

.github/workflows/push.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ jobs:
2828
RepeatAndScale.ino,
2929
TransformLLFansFormatToStrip.ino,
3030
LS100.ino,
31+
LT100.ino,
3132
LightingNodeCORE.ino,
3233
NonAddressable.ino,
34+
AdditionalFeatures.ino,
3335
AmbientBacklight.ino,
3436
MultipleFans.ino,
3537
DebugSketch.ino

examples/LT100/LT100.ino

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
#define DATA_PIN_CHANNEL_1 2
20+
21+
CRGB ledsChannel1[108];
22+
23+
CorsairLightingFirmware firmware = corsairLT100Firmware();
24+
FastLEDController ledController(true);
25+
CorsairLightingProtocolController cLP(&ledController, &firmware);
26+
CorsairLightingProtocolHID cHID(&cLP);
27+
28+
void setup() {
29+
FastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 108);
30+
ledController.addLEDs(0, ledsChannel1, 108);
31+
}
32+
33+
void loop() {
34+
cHID.update();
35+
36+
if (ledController.updateLEDs()) {
37+
FastLED.show();
38+
}
39+
}

src/CorsairLightingFirmware.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const uint8_t corsairLightingNodePROFirmwareVersion[FIRMWARE_VERSION_SIZE] PROGM
2323

2424
const uint8_t corsairCommanderPROFirmwareVersion[FIRMWARE_VERSION_SIZE] PROGMEM = {0x00, 0x09, 0xD4};
2525

26+
const uint8_t corsairLT100FirmwareVersion[FIRMWARE_VERSION_SIZE] PROGMEM = {0x01, 0x01, 0x38};
27+
2628
CorsairLightingFirmware::CorsairLightingFirmware(const uint8_t* firmwareVersion) : firmwareVersion(firmwareVersion) {
2729
EEPROM.get(EEPROM_ADDRESS_DEVICE_ID, deviceId);
2830
}
@@ -84,3 +86,5 @@ CorsairLightingFirmware corsairLS100Firmware() {
8486
CorsairLightingFirmware corsairCommanderPROFirmware() {
8587
return CorsairLightingFirmware(corsairCommanderPROFirmwareVersion);
8688
}
89+
90+
CorsairLightingFirmware corsairLT100Firmware() { return CorsairLightingFirmware(corsairLT100FirmwareVersion); }

src/CorsairLightingFirmware.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ CorsairLightingFirmware corsairLightingNodeCOREFirmware();
5252
CorsairLightingFirmware corsairLS100Firmware();
5353

5454
CorsairLightingFirmware corsairCommanderPROFirmware();
55+
56+
CorsairLightingFirmware corsairLT100Firmware();

src/CorsairLightingProtocolConstants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
#define WRITE_LED_BRIGHTNESS 0x39
5656
#define WRITE_LED_COUNT 0x3A
5757
#define WRITE_LED_PORT_TYPE 0x3B
58+
#define WRITE_LED_START_AUTODETECTION 0x3C
59+
#define READ_LED_AUTODETECTION_RESULTS 0x3D
5860

5961
#define PROTOCOL_RESPONSE_OK 0x00
6062
#define PROTOCOL_RESPONSE_ERROR 0x01

src/FastLEDController.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ void FastLEDController::clearLEDColorValues(uint8_t channel) {
503503
}
504504
}
505505

506+
uint8_t FastLEDController::getLEDAutodetectionResult(uint8_t channel) { return channelData[channel].ledCount; }
507+
506508
void FastLEDController::timeoutAction() {
507509
for (int channelId = 0; channelId < CHANNEL_NUM; channelId++) {
508510
triggerSave |= setLEDMode(channelId, ChannelMode::HardwarePlayback);

src/FastLEDController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class FastLEDController : public LEDController {
177177
virtual void setLEDColorValues(uint8_t channel, uint8_t color, uint8_t offset, const uint8_t* values,
178178
size_t len) override;
179179
virtual void clearLEDColorValues(uint8_t channel) override;
180+
virtual uint8_t getLEDAutodetectionResult(uint8_t channel) override;
180181
/**
181182
* This function is called when a timeout occurs.
182183
*/

src/LEDController.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@ void LEDController::handleLEDControl(const Command& command, const CorsairLighti
149149
triggerSave |= setLEDPortType(channel, portType);
150150
break;
151151
}
152+
case WRITE_LED_START_AUTODETECTION: {
153+
startLEDAutodetection(channel);
154+
break;
155+
}
156+
case READ_LED_AUTODETECTION_RESULTS: {
157+
const uint8_t result = getLEDAutodetectionResult(channel);
158+
uint8_t buffer[] = {result};
159+
response->send(buffer, sizeof(buffer));
160+
// don't send default response
161+
return;
162+
break;
163+
}
152164
default: {
153165
#ifdef DEBUG
154166
Serial.print(F("unkown command: "));
@@ -232,6 +244,10 @@ bool LEDController::setLEDPortType(uint8_t channel, PortType ledPortType) {
232244
return false;
233245
}
234246

247+
void LEDController::startLEDAutodetection(uint8_t channel) {
248+
// Nothing to do here
249+
}
250+
235251
bool LEDController::saveIfNeeded() {
236252
if (triggerSave) {
237253
triggerSave = false;

src/LEDController.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,22 @@ class LEDController : public ILEDController {
264264
*/
265265
virtual void clearLEDColorValues(uint8_t channel) = 0;
266266
virtual bool clearLEDGroups(uint8_t channel);
267+
/**
268+
* Start the potentially long running process to detect the current number of LEDs connected to given channel.
269+
*
270+
* @param channel the channel index
271+
* @see getLEDAutodetectionResult()
272+
*/
273+
virtual void startLEDAutodetection(uint8_t channel);
274+
/**
275+
* Get the result of the LED number autodetection on the given channel.
276+
* Potential values for LT100: 27, 54, 81, 108
277+
*
278+
* @param channel the channel index
279+
* @return the number of LEDs currently connected to the channel
280+
* @see startLEDAutodetection()
281+
*/
282+
virtual uint8_t getLEDAutodetectionResult(uint8_t channel) = 0;
267283
virtual bool save() = 0;
268284
virtual bool load() = 0;
269285
/**

0 commit comments

Comments
 (0)