From bafe8d920a780bc5f5c0ad41437a09ffa823432d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 26 Feb 2020 12:02:54 -0600 Subject: [PATCH] Handle print completed LED event in M0 --- Marlin/src/MarlinCore.cpp | 20 +++++--------------- Marlin/src/gcode/lcd/M0_M1.cpp | 9 +++++++-- Marlin/src/gcode/parser.h | 2 +- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index ab469d581..5a527482c 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -412,23 +412,13 @@ void startOrResumeJob() { #endif } - #if ENABLED(PRINTER_EVENT_LEDS) - #include "feature/leds/printer_event_leds.h" - #endif - inline void finishSDPrinting() { bool did_state = true; switch (card.sdprinting_done_state) { - #if ENABLED(PRINTER_EVENT_LEDS) - case 1: - printerEventLEDs.onPrintCompleted(); // Change LED color for Print Completed - break; - #endif - #if HAS_RESUME_CONTINUE // Display "Click to Continue..." - case 2: - did_state = queue.enqueue_P(PSTR("M0 S" + case 1: + did_state = queue.enqueue_P(PSTR("M0Q1S" #if HAS_LCD_MENU "1800" // ...for 30 minutes with LCD #else @@ -438,13 +428,13 @@ void startOrResumeJob() { break; #endif - case 3: print_job_timer.stop(); break; + case 2: print_job_timer.stop(); break; - case 4: + case 3: did_state = print_job_timer.duration() < 60 || queue.enqueue_P(PSTR("M31")); break; - case 5: + case 4: #if ENABLED(POWER_LOSS_RECOVERY) recovery.purge(); #endif diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 2f110c5c5..2b35ddf3f 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -67,11 +67,16 @@ void GcodeSuite::M0_M1() { planner.synchronize(); + #if HAS_LEDS_OFF_FLAG + if (parser.seen('Q')) + printerEventLEDs.onPrintCompleted(); // Change LED color for Print Completed + #endif + #if HAS_LCD_MENU if (has_message) ui.set_status(args, true); - else if (!parser.seenval('Q')) { + else { LCD_MESSAGEPGM(MSG_USERWAIT); #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0 ui.reset_progress_bar_timeout(); @@ -98,7 +103,7 @@ void GcodeSuite::M0_M1() { wait_for_user = true; #if ENABLED(HOST_PROMPT_SUPPORT) - host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M0/1 Break Called"), CONTINUE_STR); + host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR); #endif if (ms > 0) ms += millis(); // wait until this time for a click diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 7c5e1518b..06e41ccf1 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -241,7 +241,7 @@ public: // Seen a parameter with a value static inline bool seenval(const char c) { return seen(c) && has_value(); } - // Float removes 'E' to prevent scientific notation interpretation + // The value as a string static inline char* value_string() { return value_ptr; } // Float removes 'E' to prevent scientific notation interpretation