1
+ /*
2
+ Copyright 2019 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
+ // The Arduino pin where the physical LEDs are connected.
20
+ // Must be PWM pins
21
+ #define RED_PIN 3
22
+ #define GREEN_PIN 5
23
+ #define BLUE_PIN 6
24
+
25
+ CorsairLightingFirmware firmware = corsairLightingNodePROFirmware();
26
+ FastLEDController ledController (true );
27
+ CorsairLightingProtocolController cLP (&ledController, &firmware);
28
+ CorsairLightingProtocolHID cHID (&cLP);
29
+
30
+ CRGB ledsChannel1[10 ];
31
+
32
+ void setup () {
33
+ pinMode (RED_PIN, OUTPUT);
34
+ pinMode (GREEN_PIN, OUTPUT);
35
+ pinMode (BLUE_PIN, OUTPUT);
36
+ ledController.addLEDs (0 , ledsChannel1, 10 );
37
+ ledController.onUpdateHook (0 , []() {
38
+ // use color of first LED of the first channel
39
+ set4PinLEDs (ledsChannel1[0 ]);
40
+ });
41
+ }
42
+
43
+ void loop () {
44
+ cHID.update ();
45
+ ledController.updateLEDs ();
46
+ }
47
+
48
+ void set4PinLEDs (const CRGB& color) {
49
+ analogWrite (RED_PIN, color.r );
50
+ analogWrite (GREEN_PIN, color.g );
51
+ analogWrite (BLUE_PIN, color.b );
52
+ }
0 commit comments