Skip to content

Commit 8050813

Browse files
GeoSafferthinkyhead
authored andcommitted
🐛 Fix dual Neopixels (MarlinFirmware#22174)
1 parent 25e7e2f commit 8050813

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Marlin/src/feature/leds/neopixel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ class Marlin_NeoPixel {
114114
#if CONJOINED_NEOPIXEL
115115
adaneo2.show();
116116
#else
117-
IF_DISABLED(NEOPIXEL2_SEPARATE, adaneo1.setPin(NEOPIXEL2_PIN));
118117
adaneo1.show();
119118
adaneo1.setPin(NEOPIXEL_PIN);
120119
#endif

Marlin/src/gcode/feature/leds/M150.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,16 @@
5252
* M150 I1 R ; Set NEOPIXEL index 1 to red
5353
* M150 S1 I1 R ; Set SEPARATE index 1 to red
5454
*/
55-
5655
void GcodeSuite::M150() {
5756
#if ENABLED(NEOPIXEL_LED)
58-
const uint8_t index = parser.intval('I', -1);
57+
const int8_t index = parser.intval('I', -1);
5958
#if ENABLED(NEOPIXEL2_SEPARATE)
60-
const uint8_t unit = parser.intval('S'),
61-
brightness = unit ? neo2.brightness() : neo.brightness();
62-
*(unit ? &neo2.neoindex : &neo.neoindex) = index;
59+
int8_t brightness, unit = parser.intval('S', -1);
60+
switch (unit) {
61+
case -1: neo2.neoindex = index; // fall-thru
62+
case 0: neo.neoindex = index; brightness = neo.brightness(); break;
63+
case 1: neo2.neoindex = index; brightness = neo2.brightness(); break;
64+
}
6365
#else
6466
const uint8_t brightness = neo.brightness();
6567
neo.neoindex = index;
@@ -75,10 +77,15 @@ void GcodeSuite::M150() {
7577
);
7678

7779
#if ENABLED(NEOPIXEL2_SEPARATE)
78-
if (unit == 1) { leds2.set_color(color); return; }
80+
switch (unit) {
81+
case 0: leds.set_color(color); return;
82+
case 1: leds2.set_color(color); return;
83+
}
7984
#endif
8085

86+
// If 'S' is not specified use both
8187
leds.set_color(color);
88+
TERN_(NEOPIXEL2_SEPARATE, leds2.set_color(color));
8289
}
8390

8491
#endif // HAS_COLOR_LEDS

0 commit comments

Comments
 (0)