5252 * M150 I1 R ; Set NEOPIXEL index 1 to red
5353 * M150 S1 I1 R ; Set SEPARATE index 1 to red
5454 */
55-
5655void 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