Clean up user-wait, SD completion (#17315)
This commit is contained in:
		@@ -1049,6 +1049,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  #define EVENT_GCODE_SD_STOP "G28XY"       // G-code to run on Stop Print (e.g., "G28XY" or "G27")
 | 
					  #define EVENT_GCODE_SD_STOP "G28XY"       // G-code to run on Stop Print (e.g., "G28XY" or "G27")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  #if ENABLED(PRINTER_EVENT_LEDS)
 | 
				
			||||||
 | 
					    #define PE_LEDS_COMPLETED_TIME  (30*60) // (seconds) Time to keep the LED "done" color before restoring normal illumination
 | 
				
			||||||
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Continue after Power-Loss (Creality3D)
 | 
					   * Continue after Power-Loss (Creality3D)
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -210,6 +210,24 @@ bool wait_for_heatup = true;
 | 
				
			|||||||
// For M0/M1, this flag may be cleared (by M108) to exit the wait-for-user loop
 | 
					// For M0/M1, this flag may be cleared (by M108) to exit the wait-for-user loop
 | 
				
			||||||
#if HAS_RESUME_CONTINUE
 | 
					#if HAS_RESUME_CONTINUE
 | 
				
			||||||
  bool wait_for_user; // = false;
 | 
					  bool wait_for_user; // = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) {
 | 
				
			||||||
 | 
					    #if DISABLED(ADVANCED_PAUSE_FEATURE)
 | 
				
			||||||
 | 
					      UNUSED(no_sleep);
 | 
				
			||||||
 | 
					    #endif
 | 
				
			||||||
 | 
					    KEEPALIVE_STATE(PAUSED_FOR_USER);
 | 
				
			||||||
 | 
					    wait_for_user = true;
 | 
				
			||||||
 | 
					    if (ms) ms += millis(); // expire time
 | 
				
			||||||
 | 
					    while (wait_for_user && !(ms && ELAPSED(millis(), ms))) {
 | 
				
			||||||
 | 
					      idle(
 | 
				
			||||||
 | 
					        #if ENABLED(ADVANCED_PAUSE_FEATURE)
 | 
				
			||||||
 | 
					          no_sleep
 | 
				
			||||||
 | 
					        #endif
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    wait_for_user = false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Inactivity shutdown
 | 
					// Inactivity shutdown
 | 
				
			||||||
@@ -418,53 +436,8 @@ void startOrResumeJob() {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  inline void finishSDPrinting() {
 | 
					  inline void finishSDPrinting() {
 | 
				
			||||||
 | 
					    if (queue.enqueue_one_P(PSTR("M1001")))
 | 
				
			||||||
    bool did_state = true;
 | 
					      marlin_state = MF_RUNNING;
 | 
				
			||||||
    switch (card.sdprinting_done_state) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      case 1:
 | 
					 | 
				
			||||||
        if (print_job_timer.duration() > 60)
 | 
					 | 
				
			||||||
          did_state = queue.enqueue_one_P(PSTR("M31"));
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      case 2:
 | 
					 | 
				
			||||||
        did_state = queue.enqueue_one_P(PSTR("M77"));
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      case 3:
 | 
					 | 
				
			||||||
        #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
 | 
					 | 
				
			||||||
          ui.set_progress_done();
 | 
					 | 
				
			||||||
        #endif
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      case 4:                                   // Display "Click to Continue..."
 | 
					 | 
				
			||||||
        #if HAS_LEDS_OFF_FLAG                   // 30 min timeout with LCD, 1 min without
 | 
					 | 
				
			||||||
          did_state = queue.enqueue_one_P(
 | 
					 | 
				
			||||||
            print_job_timer.duration() < 60 ? PSTR("M0Q1P1") : PSTR("M0Q1S" TERN(HAS_LCD_MENU, "1800", "60"))
 | 
					 | 
				
			||||||
          );
 | 
					 | 
				
			||||||
        #endif
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      case 5:
 | 
					 | 
				
			||||||
        #if ENABLED(POWER_LOSS_RECOVERY)
 | 
					 | 
				
			||||||
          recovery.purge();
 | 
					 | 
				
			||||||
        #endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        #if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
 | 
					 | 
				
			||||||
          planner.finish_and_disable();
 | 
					 | 
				
			||||||
        #endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
 | 
					 | 
				
			||||||
          ui.reselect_last_file();
 | 
					 | 
				
			||||||
        #endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        SERIAL_ECHOLNPGM(STR_FILE_PRINTED);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      default:
 | 
					 | 
				
			||||||
        did_state = false;
 | 
					 | 
				
			||||||
        card.sdprinting_done_state = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (did_state) ++card.sdprinting_done_state;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // SDSUPPORT
 | 
					#endif // SDSUPPORT
 | 
				
			||||||
@@ -1209,7 +1182,7 @@ void loop() {
 | 
				
			|||||||
    #if ENABLED(SDSUPPORT)
 | 
					    #if ENABLED(SDSUPPORT)
 | 
				
			||||||
      card.checkautostart();
 | 
					      card.checkautostart();
 | 
				
			||||||
      if (card.flag.abort_sd_printing) abortSDPrinting();
 | 
					      if (card.flag.abort_sd_printing) abortSDPrinting();
 | 
				
			||||||
      if (card.sdprinting_done_state) finishSDPrinting();
 | 
					      if (marlin_state == MF_SD_COMPLETE) finishSDPrinting();
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    queue.advance();
 | 
					    queue.advance();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -83,6 +83,7 @@ enum MarlinState : uint8_t {
 | 
				
			|||||||
  MF_PAUSED       = _BV(1),
 | 
					  MF_PAUSED       = _BV(1),
 | 
				
			||||||
  MF_WAITING      = _BV(2),
 | 
					  MF_WAITING      = _BV(2),
 | 
				
			||||||
  MF_STOPPED      = _BV(3),
 | 
					  MF_STOPPED      = _BV(3),
 | 
				
			||||||
 | 
					  MF_SD_COMPLETE  = _BV(4),
 | 
				
			||||||
  MF_KILLED       = _BV(7)
 | 
					  MF_KILLED       = _BV(7)
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -98,6 +99,7 @@ extern bool wait_for_heatup;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#if HAS_RESUME_CONTINUE
 | 
					#if HAS_RESUME_CONTINUE
 | 
				
			||||||
  extern bool wait_for_user;
 | 
					  extern bool wait_for_user;
 | 
				
			||||||
 | 
					  void wait_for_user_response(millis_t ms=0, const bool no_sleep=false);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Inactivity shutdown timer
 | 
					// Inactivity shutdown timer
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -707,14 +707,13 @@ void MMU2::filament_runout() {
 | 
				
			|||||||
    if (recover)  {
 | 
					    if (recover)  {
 | 
				
			||||||
      LCD_MESSAGEPGM(MSG_MMU2_EJECT_RECOVER);
 | 
					      LCD_MESSAGEPGM(MSG_MMU2_EJECT_RECOVER);
 | 
				
			||||||
      BUZZ(200, 404);
 | 
					      BUZZ(200, 404);
 | 
				
			||||||
      wait_for_user = true;
 | 
					 | 
				
			||||||
      #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
					      #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
				
			||||||
        host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), CONTINUE_STR);
 | 
					        host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), CONTINUE_STR);
 | 
				
			||||||
      #endif
 | 
					      #endif
 | 
				
			||||||
      #if ENABLED(EXTENSIBLE_UI)
 | 
					      #if ENABLED(EXTENSIBLE_UI)
 | 
				
			||||||
        ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover"));
 | 
					        ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover"));
 | 
				
			||||||
      #endif
 | 
					      #endif
 | 
				
			||||||
      while (wait_for_user) idle();
 | 
					      wait_for_user_response();
 | 
				
			||||||
      BUZZ(200, 404);
 | 
					      BUZZ(200, 404);
 | 
				
			||||||
      BUZZ(200, 404);
 | 
					      BUZZ(200, 404);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -184,7 +184,6 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
 | 
				
			|||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    KEEPALIVE_STATE(PAUSED_FOR_USER);
 | 
					    KEEPALIVE_STATE(PAUSED_FOR_USER);
 | 
				
			||||||
    wait_for_user = true;    // LCD click or M108 will clear this
 | 
					 | 
				
			||||||
    #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
					    #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
				
			||||||
      const char tool = '0'
 | 
					      const char tool = '0'
 | 
				
			||||||
        #if NUM_RUNOUT_SENSORS > 1
 | 
					        #if NUM_RUNOUT_SENSORS > 1
 | 
				
			||||||
@@ -246,13 +245,13 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
 | 
				
			|||||||
      if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
 | 
					      if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    wait_for_user = true;
 | 
					 | 
				
			||||||
    #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
					    #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
				
			||||||
      host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR);
 | 
					      host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR);
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    #if ENABLED(EXTENSIBLE_UI)
 | 
					    #if ENABLED(EXTENSIBLE_UI)
 | 
				
			||||||
      ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging..."));
 | 
					      ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging..."));
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
 | 
					    wait_for_user = true; // A click or M108 breaks the purge_length loop
 | 
				
			||||||
    for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
 | 
					    for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
 | 
				
			||||||
      do_pause_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
 | 
					      do_pause_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
 | 
				
			||||||
    wait_for_user = false;
 | 
					    wait_for_user = false;
 | 
				
			||||||
@@ -508,13 +507,13 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Wait for filament insert by user and press button
 | 
					  // Wait for filament insert by user and press button
 | 
				
			||||||
  KEEPALIVE_STATE(PAUSED_FOR_USER);
 | 
					  KEEPALIVE_STATE(PAUSED_FOR_USER);
 | 
				
			||||||
  wait_for_user = true;    // LCD click or M108 will clear this
 | 
					 | 
				
			||||||
  #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
					  #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
				
			||||||
    host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Nozzle Parked"), CONTINUE_STR);
 | 
					    host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Nozzle Parked"), CONTINUE_STR);
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
  #if ENABLED(EXTENSIBLE_UI)
 | 
					  #if ENABLED(EXTENSIBLE_UI)
 | 
				
			||||||
    ExtUI::onUserConfirmRequired_P(PSTR("Nozzle Parked"));
 | 
					    ExtUI::onUserConfirmRequired_P(PSTR("Nozzle Parked"));
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					  wait_for_user = true;    // LCD click or M108 will clear this
 | 
				
			||||||
  while (wait_for_user) {
 | 
					  while (wait_for_user) {
 | 
				
			||||||
    #if HAS_BUZZER
 | 
					    #if HAS_BUZZER
 | 
				
			||||||
      filament_change_beep(max_beep_count);
 | 
					      filament_change_beep(max_beep_count);
 | 
				
			||||||
@@ -540,8 +539,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
 | 
				
			|||||||
        ExtUI::onUserConfirmRequired_P(PSTR("HeaterTimeout"));
 | 
					        ExtUI::onUserConfirmRequired_P(PSTR("HeaterTimeout"));
 | 
				
			||||||
      #endif
 | 
					      #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // Wait for LCD click or M108
 | 
					      wait_for_user_response(0, true); // Wait for LCD click or M108
 | 
				
			||||||
      while (wait_for_user) idle_no_sleep();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
					      #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
				
			||||||
        host_prompt_do(PROMPT_INFO, PSTR("Reheating"));
 | 
					        host_prompt_do(PROMPT_INFO, PSTR("Reheating"));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -857,7 +857,11 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      #if ENABLED(POWER_LOSS_RECOVERY)
 | 
					      #if ENABLED(POWER_LOSS_RECOVERY)
 | 
				
			||||||
        case 413: M413(); break;                                  // M413: Enable/disable/query Power-Loss Recovery
 | 
					        case 413: M413(); break;                                  // M413: Enable/disable/query Power-Loss Recovery
 | 
				
			||||||
        case 1000: M1000(); break;                                // M1000: Resume from power-loss
 | 
					        case 1000: M1000(); break;                                // M1000: [INTERNAL] Resume from power-loss
 | 
				
			||||||
 | 
					      #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      #if ENABLED(SDSUPPORT)
 | 
				
			||||||
 | 
					        case 1001: M1001(); break;                                // M1001: [INTERNAL] Handle SD completion
 | 
				
			||||||
      #endif
 | 
					      #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      #if ENABLED(MAX7219_GCODE)
 | 
					      #if ENABLED(MAX7219_GCODE)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -968,6 +968,10 @@ private:
 | 
				
			|||||||
    static void M1000();
 | 
					    static void M1000();
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  #if ENABLED(SDSUPPORT)
 | 
				
			||||||
 | 
					    static void M1001();
 | 
				
			||||||
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if ENABLED(MAX7219_GCODE)
 | 
					  #if ENABLED(MAX7219_GCODE)
 | 
				
			||||||
    static void M7219();
 | 
					    static void M7219();
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,23 +24,19 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#if HAS_RESUME_CONTINUE
 | 
					#if HAS_RESUME_CONTINUE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "../gcode.h"
 | 
					 | 
				
			||||||
#include "../../module/planner.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "../../inc/MarlinConfig.h"
 | 
					#include "../../inc/MarlinConfig.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "../gcode.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "../../module/planner.h" // for synchronize()
 | 
				
			||||||
 | 
					#include "../../MarlinCore.h"     // for wait_for_user_response()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if HAS_LCD_MENU
 | 
					#if HAS_LCD_MENU
 | 
				
			||||||
  #include "../../lcd/ultralcd.h"
 | 
					  #include "../../lcd/ultralcd.h"
 | 
				
			||||||
#endif
 | 
					#elif ENABLED(EXTENSIBLE_UI)
 | 
				
			||||||
 | 
					 | 
				
			||||||
#if ENABLED(EXTENSIBLE_UI)
 | 
					 | 
				
			||||||
  #include "../../lcd/extui/ui_api.h"
 | 
					  #include "../../lcd/extui/ui_api.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if HAS_LEDS_OFF_FLAG
 | 
					 | 
				
			||||||
  #include "../../feature/leds/printer_event_leds.h"
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if ENABLED(HOST_PROMPT_SUPPORT)
 | 
					#if ENABLED(HOST_PROMPT_SUPPORT)
 | 
				
			||||||
  #include "../../feature/host_actions.h"
 | 
					  #include "../../feature/host_actions.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -56,18 +52,11 @@ void GcodeSuite::M0_M1() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  planner.synchronize();
 | 
					  planner.synchronize();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if HAS_LEDS_OFF_FLAG
 | 
					 | 
				
			||||||
    const bool seenQ = parser.seen('Q');
 | 
					 | 
				
			||||||
    if (seenQ) printerEventLEDs.onPrintCompleted();  // Change LED color for Print Completed
 | 
					 | 
				
			||||||
  #else
 | 
					 | 
				
			||||||
    constexpr bool seenQ = false;
 | 
					 | 
				
			||||||
  #endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  #if HAS_LCD_MENU
 | 
					  #if HAS_LCD_MENU
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (parser.string_arg)
 | 
					    if (parser.string_arg)
 | 
				
			||||||
      ui.set_status(parser.string_arg, true);
 | 
					      ui.set_status(parser.string_arg, true);
 | 
				
			||||||
    else if (!seenQ) {
 | 
					    else {
 | 
				
			||||||
      LCD_MESSAGEPGM(MSG_USERWAIT);
 | 
					      LCD_MESSAGEPGM(MSG_USERWAIT);
 | 
				
			||||||
      #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
 | 
					      #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
 | 
				
			||||||
        ui.reset_progress_bar_timeout();
 | 
					        ui.reset_progress_bar_timeout();
 | 
				
			||||||
@@ -75,12 +64,10 @@ void GcodeSuite::M0_M1() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #elif ENABLED(EXTENSIBLE_UI)
 | 
					  #elif ENABLED(EXTENSIBLE_UI)
 | 
				
			||||||
    if (!seenQ) {
 | 
					 | 
				
			||||||
    if (parser.string_arg)
 | 
					    if (parser.string_arg)
 | 
				
			||||||
      ExtUI::onUserConfirmRequired(parser.string_arg); // Can this take an SRAM string??
 | 
					      ExtUI::onUserConfirmRequired(parser.string_arg); // Can this take an SRAM string??
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_USERWAIT));
 | 
					      ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_USERWAIT));
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  #else
 | 
					  #else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (parser.string_arg) {
 | 
					    if (parser.string_arg) {
 | 
				
			||||||
@@ -90,25 +77,15 @@ void GcodeSuite::M0_M1() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  KEEPALIVE_STATE(PAUSED_FOR_USER);
 | 
					 | 
				
			||||||
  wait_for_user = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
					  #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
				
			||||||
    if (!seenQ) host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR);
 | 
					    host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR);
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (ms > 0) ms += millis();  // wait until this time for a click
 | 
					  wait_for_user_response(ms);
 | 
				
			||||||
  while (wait_for_user && (ms == 0 || PENDING(millis(), ms))) idle();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  #if HAS_LEDS_OFF_FLAG
 | 
					 | 
				
			||||||
    printerEventLEDs.onResumeAfterWait();
 | 
					 | 
				
			||||||
  #endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if HAS_LCD_MENU
 | 
					  #if HAS_LCD_MENU
 | 
				
			||||||
    if (!seenQ) ui.reset_status();
 | 
					    ui.reset_status();
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					 | 
				
			||||||
  wait_for_user = false;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // HAS_RESUME_CONTINUE
 | 
					#endif // HAS_RESUME_CONTINUE
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										109
									
								
								Marlin/src/gcode/sd/M1001.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								Marlin/src/gcode/sd/M1001.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,109 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Marlin 3D Printer Firmware
 | 
				
			||||||
 | 
					 * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Based on Sprinter and grbl.
 | 
				
			||||||
 | 
					 * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation, either version 3 of the License, or
 | 
				
			||||||
 | 
					 * (at your option) any later version.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "../../inc/MarlinConfig.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if ENABLED(SDSUPPORT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "../gcode.h"
 | 
				
			||||||
 | 
					#include "../../module/printcounter.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if EITHER(LCD_SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE)
 | 
				
			||||||
 | 
					  #include "../../lcd/ultralcd.h"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if ENABLED(POWER_LOSS_RECOVERY)
 | 
				
			||||||
 | 
					  #include "../../feature/powerloss.h"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if HAS_LEDS_OFF_FLAG
 | 
				
			||||||
 | 
					  #include "../../feature/leds/printer_event_leds.h"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if ENABLED(EXTENSIBLE_UI)
 | 
				
			||||||
 | 
					  #include "../../lcd/extui/ui_api.h"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if ENABLED(HOST_ACTION_COMMANDS)
 | 
				
			||||||
 | 
					  #include "../../feature/host_actions.h"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
 | 
				
			||||||
 | 
					  #include "../../module/planner.h"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef PE_LEDS_COMPLETED_TIME
 | 
				
			||||||
 | 
					  #define PE_LEDS_COMPLETED_TIME (30*60)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * M1001: Execute actions for SD print completion
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void GcodeSuite::M1001() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Report total print time
 | 
				
			||||||
 | 
					  const bool long_print = print_job_timer.duration() > 60;
 | 
				
			||||||
 | 
					  if (long_print) gcode.process_subcommands_now_P(PSTR("M31"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Stop the print job timer
 | 
				
			||||||
 | 
					  gcode.process_subcommands_now_P(PSTR("M77"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Set the progress bar "done" state
 | 
				
			||||||
 | 
					  #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
 | 
				
			||||||
 | 
					    ui.set_progress_done();
 | 
				
			||||||
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Purge the recovery file
 | 
				
			||||||
 | 
					  #if ENABLED(POWER_LOSS_RECOVERY)
 | 
				
			||||||
 | 
					    recovery.purge();
 | 
				
			||||||
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Announce SD file completion
 | 
				
			||||||
 | 
					  SERIAL_ECHOLNPGM(STR_FILE_PRINTED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Update the status LED color
 | 
				
			||||||
 | 
					  #if HAS_LEDS_OFF_FLAG
 | 
				
			||||||
 | 
					    if (long_print) {
 | 
				
			||||||
 | 
					      printerEventLEDs.onPrintCompleted();
 | 
				
			||||||
 | 
					      #if ENABLED(EXTENSIBLE_UI)
 | 
				
			||||||
 | 
					        ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_PRINT_DONE));
 | 
				
			||||||
 | 
					      #endif
 | 
				
			||||||
 | 
					      #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
				
			||||||
 | 
					        host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_PRINT_DONE), CONTINUE_STR);
 | 
				
			||||||
 | 
					      #endif
 | 
				
			||||||
 | 
					      wait_for_user_response(1000UL * TERN(HAS_LCD_MENU, PE_LEDS_COMPLETED_TIME, 30));
 | 
				
			||||||
 | 
					      printerEventLEDs.onResumeAfterWait();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Wait for the queue to empty (and "clean"), inject SD_FINISHED_RELEASECOMMAND
 | 
				
			||||||
 | 
					  #if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
 | 
				
			||||||
 | 
					    planner.finish_and_disable();
 | 
				
			||||||
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Re-select the last printed file in the UI
 | 
				
			||||||
 | 
					  #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
 | 
				
			||||||
 | 
					    ui.reselect_last_file();
 | 
				
			||||||
 | 
					  #endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // SDSUPPORT
 | 
				
			||||||
@@ -352,6 +352,7 @@ namespace Language_en {
 | 
				
			|||||||
  PROGMEM Language_Str MSG_PRINT_PAUSED                    = _UxGT("Print Paused");
 | 
					  PROGMEM Language_Str MSG_PRINT_PAUSED                    = _UxGT("Print Paused");
 | 
				
			||||||
  PROGMEM Language_Str MSG_PRINTING                        = _UxGT("Printing...");
 | 
					  PROGMEM Language_Str MSG_PRINTING                        = _UxGT("Printing...");
 | 
				
			||||||
  PROGMEM Language_Str MSG_PRINT_ABORTED                   = _UxGT("Print Aborted");
 | 
					  PROGMEM Language_Str MSG_PRINT_ABORTED                   = _UxGT("Print Aborted");
 | 
				
			||||||
 | 
					  PROGMEM Language_Str MSG_PRINT_DONE                      = _UxGT("Print Done");
 | 
				
			||||||
  PROGMEM Language_Str MSG_NO_MOVE                         = _UxGT("No Move.");
 | 
					  PROGMEM Language_Str MSG_NO_MOVE                         = _UxGT("No Move.");
 | 
				
			||||||
  PROGMEM Language_Str MSG_KILLED                          = _UxGT("KILLED. ");
 | 
					  PROGMEM Language_Str MSG_KILLED                          = _UxGT("KILLED. ");
 | 
				
			||||||
  PROGMEM Language_Str MSG_STOPPED                         = _UxGT("STOPPED. ");
 | 
					  PROGMEM Language_Str MSG_STOPPED                         = _UxGT("STOPPED. ");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,16 +61,14 @@ void _man_probe_pt(const xy_pos_t &xy) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  float lcd_probe_pt(const xy_pos_t &xy) {
 | 
					  float lcd_probe_pt(const xy_pos_t &xy) {
 | 
				
			||||||
    _man_probe_pt(xy);
 | 
					    _man_probe_pt(xy);
 | 
				
			||||||
    KEEPALIVE_STATE(PAUSED_FOR_USER);
 | 
					 | 
				
			||||||
    ui.defer_status_screen();
 | 
					    ui.defer_status_screen();
 | 
				
			||||||
    wait_for_user = true;
 | 
					 | 
				
			||||||
    #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
					    #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
				
			||||||
      host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Delta Calibration in progress"), CONTINUE_STR);
 | 
					      host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Delta Calibration in progress"), CONTINUE_STR);
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    #if ENABLED(EXTENSIBLE_UI)
 | 
					    #if ENABLED(EXTENSIBLE_UI)
 | 
				
			||||||
      ExtUI::onUserConfirmRequired_P(PSTR("Delta Calibration in progress"));
 | 
					      ExtUI::onUserConfirmRequired_P(PSTR("Delta Calibration in progress"));
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    while (wait_for_user) idle();
 | 
					    wait_for_user_response();
 | 
				
			||||||
    ui.goto_previous_screen_no_defer();
 | 
					    ui.goto_previous_screen_no_defer();
 | 
				
			||||||
    return current_position.z;
 | 
					    return current_position.z;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -776,6 +776,13 @@ void MarlinUI::update() {
 | 
				
			|||||||
    // If the action button is pressed...
 | 
					    // If the action button is pressed...
 | 
				
			||||||
    static bool wait_for_unclick; // = false
 | 
					    static bool wait_for_unclick; // = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    auto do_click = [&]{
 | 
				
			||||||
 | 
					      wait_for_unclick = true;                        //  - Set debounce flag to ignore continous clicks
 | 
				
			||||||
 | 
					      lcd_clicked = !wait_for_user && !no_reentry;    //  - Keep the click if not waiting for a user-click
 | 
				
			||||||
 | 
					      wait_for_user = false;                          //  - Any click clears wait for user
 | 
				
			||||||
 | 
					      quick_feedback();                               //  - Always make a click sound
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #if ENABLED(TOUCH_BUTTONS)
 | 
					    #if ENABLED(TOUCH_BUTTONS)
 | 
				
			||||||
      if (touch_buttons) {
 | 
					      if (touch_buttons) {
 | 
				
			||||||
        RESET_STATUS_TIMEOUT();
 | 
					        RESET_STATUS_TIMEOUT();
 | 
				
			||||||
@@ -796,12 +803,8 @@ void MarlinUI::update() {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (!wait_for_unclick && (buttons & EN_C)) { // OK button, if not waiting for a debounce release:
 | 
					        else if (!wait_for_unclick && (buttons & EN_C))   // OK button, if not waiting for a debounce release:
 | 
				
			||||||
          wait_for_unclick = true;                        //  - Set debounce flag to ignore continous clicks
 | 
					          do_click();
 | 
				
			||||||
          lcd_clicked = !wait_for_user && !no_reentry;    //  - Keep the click if not waiting for a user-click
 | 
					 | 
				
			||||||
          wait_for_user = false;                          //  - Any click clears wait for user
 | 
					 | 
				
			||||||
          quick_feedback();                               //  - Always make a click sound
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      else // keep wait_for_unclick value
 | 
					      else // keep wait_for_unclick value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -810,12 +813,7 @@ void MarlinUI::update() {
 | 
				
			|||||||
      {
 | 
					      {
 | 
				
			||||||
        // Integrated LCD click handling via button_pressed
 | 
					        // Integrated LCD click handling via button_pressed
 | 
				
			||||||
        if (!external_control && button_pressed()) {
 | 
					        if (!external_control && button_pressed()) {
 | 
				
			||||||
          if (!wait_for_unclick) {                        // If not waiting for a debounce release:
 | 
					          if (!wait_for_unclick) do_click();              // Handle the click
 | 
				
			||||||
            wait_for_unclick = true;                      //  - Set debounce flag to ignore continous clicks
 | 
					 | 
				
			||||||
            lcd_clicked = !wait_for_user && !no_reentry;  //  - Keep the click if not waiting for a user-click
 | 
					 | 
				
			||||||
            wait_for_user = false;                        //  - Any click clears wait for user
 | 
					 | 
				
			||||||
            quick_feedback();                             //  - Always make a click sound
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
          wait_for_unclick = false;
 | 
					          wait_for_unclick = false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -134,12 +134,10 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
 | 
				
			|||||||
      LCD_MESSAGEPGM(MSG_MANUAL_DEPLOY_TOUCHMI);
 | 
					      LCD_MESSAGEPGM(MSG_MANUAL_DEPLOY_TOUCHMI);
 | 
				
			||||||
      ui.return_to_status();
 | 
					      ui.return_to_status();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      KEEPALIVE_STATE(PAUSED_FOR_USER);
 | 
					 | 
				
			||||||
      wait_for_user = true; // LCD click or M108 will clear this
 | 
					 | 
				
			||||||
      #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
					      #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
				
			||||||
        host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Deploy TouchMI probe."), CONTINUE_STR);
 | 
					        host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Deploy TouchMI"), CONTINUE_STR);
 | 
				
			||||||
      #endif
 | 
					      #endif
 | 
				
			||||||
      while (wait_for_user) idle();
 | 
					      wait_for_user_response();
 | 
				
			||||||
      ui.reset_status();
 | 
					      ui.reset_status();
 | 
				
			||||||
      ui.goto_screen(prev_screen);
 | 
					      ui.goto_screen(prev_screen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -297,15 +295,13 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
 | 
				
			|||||||
      serialprintPGM(ds_str);
 | 
					      serialprintPGM(ds_str);
 | 
				
			||||||
      SERIAL_EOL();
 | 
					      SERIAL_EOL();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      KEEPALIVE_STATE(PAUSED_FOR_USER);
 | 
					 | 
				
			||||||
      wait_for_user = true;
 | 
					 | 
				
			||||||
      #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
					      #if ENABLED(HOST_PROMPT_SUPPORT)
 | 
				
			||||||
        host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Stow Probe"), CONTINUE_STR);
 | 
					        host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Stow Probe"), CONTINUE_STR);
 | 
				
			||||||
      #endif
 | 
					      #endif
 | 
				
			||||||
      #if ENABLED(EXTENSIBLE_UI)
 | 
					      #if ENABLED(EXTENSIBLE_UI)
 | 
				
			||||||
        ExtUI::onUserConfirmRequired_P(PSTR("Stow Probe"));
 | 
					        ExtUI::onUserConfirmRequired_P(PSTR("Stow Probe"));
 | 
				
			||||||
      #endif
 | 
					      #endif
 | 
				
			||||||
      while (wait_for_user) idle();
 | 
					      wait_for_user_response();
 | 
				
			||||||
      ui.reset_status();
 | 
					      ui.reset_status();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    } while(
 | 
					    } while(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,7 +49,6 @@
 | 
				
			|||||||
// public:
 | 
					// public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
card_flags_t CardReader::flag;
 | 
					card_flags_t CardReader::flag;
 | 
				
			||||||
uint8_t CardReader::sdprinting_done_state;
 | 
					 | 
				
			||||||
char CardReader::filename[FILENAME_LENGTH], CardReader::longFilename[LONG_FILENAME_LENGTH];
 | 
					char CardReader::filename[FILENAME_LENGTH], CardReader::longFilename[LONG_FILENAME_LENGTH];
 | 
				
			||||||
int8_t CardReader::autostart_index;
 | 
					int8_t CardReader::autostart_index;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1089,7 +1088,7 @@ void CardReader::fileHasFinished() {
 | 
				
			|||||||
      presort();
 | 
					      presort();
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sdprinting_done_state = 1;
 | 
					    marlin_state = MF_SD_COMPLETE;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,7 +49,6 @@ typedef struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class CardReader {
 | 
					class CardReader {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  static uint8_t sdprinting_done_state;
 | 
					 | 
				
			||||||
  static card_flags_t flag;                         // Flags (above)
 | 
					  static card_flags_t flag;                         // Flags (above)
 | 
				
			||||||
  static char filename[FILENAME_LENGTH],            // DOS 8.3 filename of the selected item
 | 
					  static char filename[FILENAME_LENGTH],            // DOS 8.3 filename of the selected item
 | 
				
			||||||
              longFilename[LONG_FILENAME_LENGTH];   // Long name of the selected item
 | 
					              longFilename[LONG_FILENAME_LENGTH];   // Long name of the selected item
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user