|
@@ -52,14 +52,16 @@
|
52
|
52
|
* M150 I1 R ; Set NEOPIXEL index 1 to red
|
53
|
53
|
* M150 S1 I1 R ; Set SEPARATE index 1 to red
|
54
|
54
|
*/
|
55
|
|
-
|
56
|
55
|
void GcodeSuite::M150() {
|
57
|
56
|
#if ENABLED(NEOPIXEL_LED)
|
58
|
|
- const uint8_t index = parser.intval('I', -1);
|
|
57
|
+ const int8_t index = parser.intval('I', -1);
|
59
|
58
|
#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
|
+ }
|
63
|
65
|
#else
|
64
|
66
|
const uint8_t brightness = neo.brightness();
|
65
|
67
|
neo.neoindex = index;
|
|
@@ -75,10 +77,15 @@ void GcodeSuite::M150() {
|
75
|
77
|
);
|
76
|
78
|
|
77
|
79
|
#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
|
+ }
|
79
|
84
|
#endif
|
80
|
85
|
|
|
86
|
+ // If 'S' is not specified use both
|
81
|
87
|
leds.set_color(color);
|
|
88
|
+ TERN_(NEOPIXEL2_SEPARATE, leds2.set_color(color));
|
82
|
89
|
}
|
83
|
90
|
|
84
|
91
|
#endif // HAS_COLOR_LEDS
|