Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neopixel bugfix #22174

Merged
merged 3 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Marlin/src/feature/leds/neopixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class Marlin_NeoPixel {
#if CONJOINED_NEOPIXEL
adaneo2.show();
#else
IF_DISABLED(NEOPIXEL2_SEPARATE, adaneo1.setPin(NEOPIXEL2_PIN));
adaneo1.show();
adaneo1.setPin(NEOPIXEL_PIN);
#endif
Expand Down
19 changes: 13 additions & 6 deletions Marlin/src/gcode/feature/leds/M150.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@
* M150 I1 R ; Set NEOPIXEL index 1 to red
* M150 S1 I1 R ; Set SEPARATE index 1 to red
*/

void GcodeSuite::M150() {
#if ENABLED(NEOPIXEL_LED)
const uint8_t index = parser.intval('I', -1);
const int8_t index = parser.intval('I', -1);
#if ENABLED(NEOPIXEL2_SEPARATE)
const uint8_t unit = parser.intval('S'),
brightness = unit ? neo2.brightness() : neo.brightness();
*(unit ? &neo2.neoindex : &neo.neoindex) = index;
int8_t brightness, unit = parser.intval('S', -1);
switch (unit) {
case -1: neo2.neoindex = index; // fall-thru
case 0: neo.neoindex = index; brightness = neo.brightness(); break;
case 1: neo2.neoindex = index; brightness = neo2.brightness(); break;
}
#else
const uint8_t brightness = neo.brightness();
neo.neoindex = index;
Expand All @@ -75,10 +77,15 @@ void GcodeSuite::M150() {
);

#if ENABLED(NEOPIXEL2_SEPARATE)
if (unit == 1) { leds2.set_color(color); return; }
switch (unit) {
case 0: leds.set_color(color); return;
case 1: leds2.set_color(color); return;
}
#endif

// If 'S' is not specified use both
leds.set_color(color);
TERN_(NEOPIXEL2_SEPARATE, leds2.set_color(color));
}

#endif // HAS_COLOR_LEDS