Skip to content

Commit

Permalink
Merge pull request #148 from Legion2/dev
Browse files Browse the repository at this point in the history
Version 0.13.0
  • Loading branch information
Legion2 authored Jun 10, 2020
2 parents a0e5455 + c29c21e commit 7070558
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 6 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ 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.

## Increase the Brightness of the LEDs
By default iCUE only uses 50% of the LEDs brightness even if you set the brightness to max in the iCUE Device Settings.
But there are good news, we can increase the brightness with the Arduino so we can use the full brightness of our LEDs.
Add the `CLP::fixIcueBrightness` function to the `onUpdateHook` in the setup function as shown in the [example](examples/AdditionalFeatures/AdditionalFeatures.ino).
If there are multiple functions called in `onUpdateHook`, `fixIcueBrightness` should be the first.
```C++
ledController.onUpdateHook(0, []() {
CLP::fixIcueBrightness(&ledController, 0);
});
```

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

Expand Down
12 changes: 12 additions & 0 deletions examples/AdditionalFeatures/AdditionalFeatures.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,35 @@
CRGB ledsChannel1[60];
CRGB ledsChannel2[60];

// Define a custom SerialNumber for the device
const char mySerialNumber[] PROGMEM = "202B6949A967";

CorsairLightingFirmware firmware = corsairLightingNodePROFirmware();
FastLEDController ledController(true);
CorsairLightingProtocolController cLP(&ledController, &firmware);
// Set the SerialNumber here
CorsairLightingProtocolHID cHID(&cLP, mySerialNumber);

void setup() {
// Disable the build in RX and TX LEDs of the Arduino
CLP::disableBuildInLEDs();
// enable reset on DeviceId (FF FF FF FF)
if (CLP::shouldReset(&firmware)) {
// reset DeviceId and generate new one
CLP::reset(&firmware);
// reset the LEDController Settings
ledController.reset();
}
FastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_1, GRB>(ledsChannel1, 60);
FastLED.addLeds<WS2812B, DATA_PIN_CHANNEL_2, GRB>(ledsChannel2, 60);
ledController.addLEDs(0, ledsChannel1, 60);
ledController.addLEDs(1, ledsChannel2, 60);

// modify the RGB values before they are shown on the LED strip
ledController.onUpdateHook(0, []() {
// increase the brightness of channel 1 when using iCUE, because iCUE only set brightness to max 50%
CLP::fixIcueBrightness(&ledController, 0);
});
}

void loop() {
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.12.0
PROJECT_NUMBER = 0.13.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.12.0
version=0.13.0
author=Leon Kiefer
maintainer=Leon Kiefer
sentence=Control LED strips via USB from a PC.
Expand Down
4 changes: 3 additions & 1 deletion src/FastLEDController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,9 @@ void FastLEDController::setLEDColorValues(uint8_t channel, uint8_t color, uint8_
}

void FastLEDController::clearLEDColorValues(uint8_t channel) {
memset(channelData[channel].valuesBuffer[0], 0, channelData[channel].ledCount);
for (uint8_t*& buffer : channelData[channel].valuesBuffer) {
memset(buffer, 0, channelData[channel].ledCount);
}
}

void FastLEDController::timeoutAction() {
Expand Down
26 changes: 23 additions & 3 deletions src/FastLEDControllerUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ void CLP::transformLLFanToStrip(FastLEDController* controller, uint8_t channelIn
auto& channel = controller->getChannel(channelIndex);
if (channel.mode == ChannelMode::SoftwarePlayback) {
auto leds = controller->getLEDs(channelIndex);
for (uint8_t fanIndex = 0; fanIndex < controller->getLEDCount(channelIndex) / 16; fanIndex++) {
auto count = controller->getLEDCount(channelIndex);
for (uint8_t fanIndex = 0; fanIndex < count / 16; fanIndex++) {
for (uint8_t ledIndex = 0; ledIndex < 8; ledIndex++) {
CRGB temp = leds[fanIndex * 16 + ledIndex];
leds[fanIndex * 16 + ledIndex] = leds[fanIndex * 16 + 15 - ledIndex];
Expand All @@ -35,8 +36,14 @@ void CLP::transformLLFanToStrip(FastLEDController* controller, uint8_t channelIn
void CLP::scale(FastLEDController* controller, uint8_t channelIndex, int scaleToSize) {
auto leds = controller->getLEDs(channelIndex);
const float scaleFactor = (float)controller->getLEDCount(channelIndex) / scaleToSize;
for (int ledIndex = scaleToSize - 1; ledIndex >= 0; ledIndex--) {
leds[ledIndex] = leds[lround(ledIndex * scaleFactor)];
if (scaleFactor < 1.0f) {
for (int ledIndex = scaleToSize - 1; ledIndex >= 0; ledIndex--) {
leds[ledIndex] = leds[lround(ledIndex * scaleFactor)];
}
} else {
for (int ledIndex = 0; ledIndex < scaleToSize; ledIndex++) {
leds[ledIndex] = leds[lround(ledIndex * scaleFactor)];
}
}
}

Expand Down Expand Up @@ -106,3 +113,16 @@ void CLP::gammaCorrection(FastLEDController* controller, uint8_t channelIndex) {
leds[ledIndex].b = dim8_video(leds[ledIndex].b);
}
}

void CLP::fixIcueBrightness(FastLEDController* controller, uint8_t channelIndex) {
auto& channel = controller->getChannel(channelIndex);
if (channel.mode == ChannelMode::SoftwarePlayback) {
auto leds = controller->getLEDs(channelIndex);
auto count = controller->getLEDCount(channelIndex);
for (int ledIndex = 0; ledIndex < count; ledIndex++) {
leds[ledIndex].r = leds[ledIndex].r * 2;
leds[ledIndex].g = leds[ledIndex].g * 2;
leds[ledIndex].b = leds[ledIndex].b * 2;
}
}
}
9 changes: 9 additions & 0 deletions src/FastLEDControllerUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,13 @@ void reverse(FastLEDController* controller, uint8_t channelIndex);
* @param channelIndex the index of the channel
*/
void gammaCorrection(FastLEDController* controller, uint8_t channelIndex);

/**
* Increase the brightness of a LED channel when using iCUE Software lighting, because iCUE only send the RGB value in
* the range (0 - 127) which is only 50% of max possible brightness. This function doubles the received RGB value.
*
* @param controller the FastLEDController controlling the LEDs
* @param channelIndex the index of the channel
*/
void fixIcueBrightness(FastLEDController* controller, uint8_t channelIndex);
} // namespace CLP
16 changes: 16 additions & 0 deletions src/LEDController.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ class LEDController : public ILEDController {
*/
virtual void setLEDExternalTemperature(uint8_t channel, uint16_t temp) = 0;
virtual bool setLEDGroup(uint8_t channel, uint8_t groupIndex, LEDGroup& group);
/**
* Set the LED color values for one color-channel (red, green or blue) of the given channel.
*
* @param channel the channel index
* @param color the color index to set the values for red(0), green(1), blue(2)
* @param offset the offset in the LED colors buffer to write to
* @param values the array of values to write
* @param len the length of the array of values to write
* @see clearLEDColorValues()
*/
virtual void setLEDColorValues(uint8_t channel, uint8_t color, uint8_t offset, const uint8_t* values,
size_t len) = 0;
/**
Expand All @@ -246,6 +256,12 @@ class LEDController : public ILEDController {
* @return true if the port type was changed
*/
virtual bool setLEDPortType(uint8_t channel, PortType ledPortType);
/**
* Clear the LED color buffer for the given channel.
*
* @param channel the channel index
* @see setLEDColorValues()
*/
virtual void clearLEDColorValues(uint8_t channel) = 0;
virtual bool clearLEDGroups(uint8_t channel);
virtual bool save() = 0;
Expand Down

0 comments on commit 7070558

Please sign in to comment.