|
| 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 | +// Hint: The channels are swapped in iCUE, so the first channel in iCUE is here channel 2 |
| 20 | +#define DATA_PIN_CHANNEL_1 2 // For the monitor backlight |
| 21 | +#define DATA_PIN_CHANNEL_2 3 |
| 22 | + |
| 23 | +CRGB ledsChannel1[84]; |
| 24 | +CRGB ledsChannel2[105]; |
| 25 | + |
| 26 | +CorsairLightingFirmware firmware = corsairLS100Firmware(); |
| 27 | +FastLEDController ledController(true); |
| 28 | +CorsairLightingProtocolController cLP(&ledController, &firmware); |
| 29 | +CorsairLightingProtocolHID cHID(&cLP); |
| 30 | + |
| 31 | +void setup() { |
| 32 | + FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_1>(ledsChannel1, 84); |
| 33 | + FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_2>(ledsChannel2, 105); |
| 34 | + ledController.addLEDs(0, ledsChannel1, 84); |
| 35 | + ledController.addLEDs(1, ledsChannel2, 105); |
| 36 | + ledController.onUpdateHook(0, []() { |
| 37 | + // gamma correction with gamma value 2.0. Use napplyGamma_video for other gamma values. |
| 38 | + CLP::gammaCorrection(&ledController, 0); |
| 39 | + //napplyGamma_video(ledsChannel1, 84, 2.2); |
| 40 | + }); |
| 41 | +} |
| 42 | + |
| 43 | +void loop() { |
| 44 | + cHID.update(); |
| 45 | + |
| 46 | + if (ledController.updateLEDs()) { |
| 47 | + FastLED.show(); |
| 48 | + } |
| 49 | +} |
0 commit comments