My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

M1001.cpp 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfig.h"
  23. #if ENABLED(SDSUPPORT)
  24. #include "../gcode.h"
  25. #include "../../module/planner.h"
  26. #include "../../module/printcounter.h"
  27. #include "../../module/temperature.h"
  28. #include "../../sd/cardreader.h"
  29. #ifdef SD_FINISHED_RELEASECOMMAND
  30. #include "../queue.h"
  31. #endif
  32. #if EITHER(SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE)
  33. #include "../../lcd/marlinui.h"
  34. #endif
  35. #if ENABLED(POWER_LOSS_RECOVERY)
  36. #include "../../feature/powerloss.h"
  37. #endif
  38. #if HAS_LEDS_OFF_FLAG
  39. #include "../../MarlinCore.h" // for wait_for_user_response()
  40. #include "../../feature/leds/printer_event_leds.h"
  41. #endif
  42. #if ENABLED(EXTENSIBLE_UI)
  43. #include "../../lcd/extui/ui_api.h"
  44. #elif ENABLED(DWIN_LCD_PROUI)
  45. #include "../../lcd/e3v2/proui/dwin.h"
  46. #endif
  47. #if ENABLED(HOST_ACTION_COMMANDS)
  48. #include "../../feature/host_actions.h"
  49. #endif
  50. #ifndef PE_LEDS_COMPLETED_TIME
  51. #define PE_LEDS_COMPLETED_TIME (30*60)
  52. #endif
  53. /**
  54. * M1001: Execute actions for SD print completion
  55. */
  56. void GcodeSuite::M1001() {
  57. planner.synchronize();
  58. // SD Printing is finished when the queue reaches M1001
  59. card.flag.sdprinting = card.flag.sdprintdone = false;
  60. // If there's another auto#.g file to run...
  61. if (TERN(NO_SD_AUTOSTART, false, card.autofile_check())) return;
  62. // Purge the recovery file...
  63. TERN_(POWER_LOSS_RECOVERY, recovery.purge());
  64. // Report total print time
  65. const bool long_print = print_job_timer.duration() > 60;
  66. if (long_print) process_subcommands_now(F("M31"));
  67. // Stop the print job timer
  68. process_subcommands_now(F("M77"));
  69. // Set the progress bar "done" state
  70. TERN_(SET_PROGRESS_PERCENT, ui.set_progress_done());
  71. // Announce SD file completion
  72. {
  73. PORT_REDIRECT(SerialMask::All);
  74. SERIAL_ECHOLNPGM(STR_FILE_PRINTED);
  75. }
  76. // Update the status LED color
  77. #if HAS_LEDS_OFF_FLAG
  78. if (long_print) {
  79. printerEventLEDs.onPrintCompleted();
  80. TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_PRINT_DONE)));
  81. TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_PRINT_DONE), FPSTR(CONTINUE_STR)));
  82. TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_MARLINUI_MENU, PE_LEDS_COMPLETED_TIME, 30))));
  83. printerEventLEDs.onResumeAfterWait();
  84. }
  85. #endif
  86. // Inject SD_FINISHED_RELEASECOMMAND, if any
  87. #ifdef SD_FINISHED_RELEASECOMMAND
  88. process_subcommands_now(F(SD_FINISHED_RELEASECOMMAND));
  89. #endif
  90. TERN_(EXTENSIBLE_UI, ExtUI::onPrintDone());
  91. TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished());
  92. // Re-select the last printed file in the UI
  93. TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file());
  94. }
  95. #endif // SDSUPPORT