From 9e4c037cefe0d457b21867121e3371f3400c5473 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 28 Mar 2018 22:59:28 -0500 Subject: [PATCH] Wait before turning off PRINTER_EVENT_LEDS at print end (#10248) --- Marlin/src/gcode/gcode.h | 4 ++++ Marlin/src/gcode/lcd/M0_M1.cpp | 12 ++++++++++++ Marlin/src/gcode/queue.cpp | 15 +++++++++++---- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index a668c05f8d..eebcc4f235 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -324,6 +324,10 @@ public: #define KEEPALIVE_STATE(n) NOOP #endif + #if ENABLED(PRINTER_EVENT_LEDS) && ENABLED(SDSUPPORT) && HAS_RESUME_CONTINUE + static bool lights_off_after_print; + #endif + static void dwell(millis_t time); private: diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 4944cd11b6..8d1354e6ec 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -33,6 +33,11 @@ #include "../../sd/cardreader.h" +#if ENABLED(PRINTER_EVENT_LEDS) && ENABLED(SDSUPPORT) + bool GcodeSuite::lights_off_after_print; + #include "../../feature/leds/leds.h" +#endif + /** * M0: Unconditional stop - Wait for user button press on LCD * M1: Conditional stop - Wait for user button press on LCD @@ -91,6 +96,13 @@ void GcodeSuite::M0_M1() { #endif } + #if ENABLED(PRINTER_EVENT_LEDS) && ENABLED(SDSUPPORT) + if (lights_off_after_print) { + leds.set_off(); + lights_off_after_print = false; + } + #endif + wait_for_user = false; KEEPALIVE_STATE(IN_HANDLER); } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 1e7717ed1c..8ad6d842fc 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -449,12 +449,19 @@ inline void get_serial_commands() { LCD_MESSAGEPGM(MSG_INFO_COMPLETED_PRINTS); leds.set_green(); #if HAS_RESUME_CONTINUE - enqueue_and_echo_commands_P(PSTR("M0")); // end of the queue! + gcode.lights_off_after_print = true; + enqueue_and_echo_commands_P(PSTR("M0 S" + #if ENABLED(NEWPANEL) + "1800" + #else + "60" + #endif + )); #else - safe_delay(1000); + safe_delay(2000); + leds.set_off(); #endif - leds.set_off(); - #endif + #endif // PRINTER_EVENT_LEDS card.checkautostart(true); } }