Skip to content

Commit 3325334

Browse files
authored
Merge pull request #91 from Legion2/ls100-low-memory
fixed out of memory bug in LS100
2 parents 6ceb86f + 178429e commit 3325334

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

examples/LS100/LS100.ino

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222

2323
#define BUTTON_PIN 4
2424

25+
// Hint: The ATmega32U4 does not have enough memory for 135 leds on both channels
2526
CRGB ledsChannel1[135];
26-
CRGB ledsChannel2[135];
27+
CRGB ledsChannel2[54];
2728

2829
CorsairLightingFirmware firmware = corsairLS100Firmware();
2930
FastLEDController ledController(true);
@@ -32,25 +33,25 @@ CorsairLightingProtocolHID cHID(&cLP);
3233

3334
void setup() {
3435
FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_1>(ledsChannel1, 135);
35-
FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_2>(ledsChannel2, 135);
36+
FastLED.addLeds<NEOPIXEL, DATA_PIN_CHANNEL_2>(ledsChannel2, 54);
3637
ledController.addLEDs(0, ledsChannel1, 135);
37-
ledController.addLEDs(1, ledsChannel2, 135);
38-
pinMode(BUTTON_PIN, INPUT_PULLUP);
38+
ledController.addLEDs(1, ledsChannel2, 54);
39+
pinMode(BUTTON_PIN, INPUT_PULLUP);
3940
}
4041

4142
void loop() {
4243
static bool lightingEnabled = true;
4344
cHID.update();
4445

45-
if (buttonClicked()) {
46-
lightingEnabled = !lightingEnabled;
47-
fill_solid(ledsChannel1, 135, CRGB::Black);
48-
fill_solid(ledsChannel2, 135, CRGB::Black);
49-
FastLED.show();
50-
}
46+
if (buttonClicked()) {
47+
lightingEnabled = !lightingEnabled;
48+
fill_solid(ledsChannel1, 135, CRGB::Black);
49+
fill_solid(ledsChannel2, 54, CRGB::Black);
50+
FastLED.show();
51+
}
5152

5253
if (lightingEnabled && ledController.updateLEDs()) {
53-
FastLED.show();
54+
FastLED.show();
5455
}
5556
}
5657

@@ -60,12 +61,12 @@ void loop() {
6061
* @return true if the button was pressed and then released.
6162
*/
6263
bool buttonClicked() {
63-
static bool previousState = 1;
64-
bool state = digitalRead(BUTTON_PIN);
65-
if (previousState == 0 && state == 1) {
66-
previousState = state;
67-
return true;
68-
}
69-
previousState = state;
70-
return false;
64+
static bool previousState = 1;
65+
bool state = digitalRead(BUTTON_PIN);
66+
if (previousState == 0 && state == 1) {
67+
previousState = state;
68+
return true;
69+
}
70+
previousState = state;
71+
return false;
7172
}

0 commit comments

Comments
 (0)