From 6c1fd1f69c349b24ded49d7c5a1118fe7a5e37dd Mon Sep 17 00:00:00 2001 From: qwertymodo Date: Thu, 25 Jan 2024 16:16:32 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20single=20Neo=20strip=20M15?= =?UTF-8?q?0=20K=20(#26709)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/gcode/feature/leds/M150.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index 43062c3f75..dd5752ee4c 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -60,6 +60,7 @@ void GcodeSuite::M150() { #if ENABLED(NEOPIXEL_LED) const pixel_index_t index = parser.intval('I', -1); + const bool seenK = parser.seen_test('K'); #if ENABLED(NEOPIXEL2_SEPARATE) #ifndef NEOPIXEL_M150_DEFAULT #define NEOPIXEL_M150_DEFAULT -1 @@ -69,12 +70,13 @@ void GcodeSuite::M150() { int8_t brightness = neo.brightness(), unit = parser.intval('S', NEOPIXEL_M150_DEFAULT); switch (unit) { case -1: neo2.neoindex = index; // fall-thru - case 0: neo.neoindex = index; old_color = parser.seen('K') ? neo.pixel_color(index >= 0 ? index : 0) : 0; break; - case 1: neo2.neoindex = index; brightness = neo2.brightness(); old_color = parser.seen('K') ? neo2.pixel_color(index >= 0 ? index : 0) : 0; break; + case 0: neo.neoindex = index; old_color = seenK ? neo.pixel_color(_MAX(index, 0)) : 0; break; + case 1: neo2.neoindex = index; brightness = neo2.brightness(); old_color = seenK ? neo2.pixel_color(_MAX(index, 0)) : 0; break; } #else const uint8_t brightness = neo.brightness(); neo.neoindex = index; + old_color = seenK ? neo.pixel_color(_MAX(index, 0)) : 0; #endif #endif