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.

M24_M25.cpp 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 "../../sd/cardreader.h"
  26. #include "../../module/printcounter.h"
  27. #include "../../lcd/marlinui.h"
  28. #if ENABLED(PARK_HEAD_ON_PAUSE)
  29. #include "../../feature/pause.h"
  30. #endif
  31. #if ENABLED(HOST_ACTION_COMMANDS)
  32. #include "../../feature/host_actions.h"
  33. #endif
  34. #if ENABLED(POWER_LOSS_RECOVERY)
  35. #include "../../feature/powerloss.h"
  36. #endif
  37. #if ENABLED(DGUS_LCD_UI_MKS)
  38. #include "../../lcd/extui/dgus/DGUSDisplayDef.h"
  39. #endif
  40. #include "../../MarlinCore.h" // for startOrResumeJob
  41. /**
  42. * M24: Start or Resume SD Print
  43. */
  44. void GcodeSuite::M24() {
  45. #if ENABLED(DGUS_LCD_UI_MKS)
  46. if ((print_job_timer.isPaused() || print_job_timer.isRunning()) && !parser.seen("ST"))
  47. MKS_resume_print_move();
  48. #endif
  49. #if ENABLED(POWER_LOSS_RECOVERY)
  50. if (parser.seenval('S')) card.setIndex(parser.value_long());
  51. if (parser.seenval('T')) print_job_timer.resume(parser.value_long());
  52. #endif
  53. #if ENABLED(PARK_HEAD_ON_PAUSE)
  54. if (did_pause_print) {
  55. resume_print(); // will call print_job_timer.start()
  56. return;
  57. }
  58. #endif
  59. if (card.isFileOpen()) {
  60. card.startOrResumeFilePrinting(); // SD card will now be read for commands
  61. startOrResumeJob(); // Start (or resume) the print job timer
  62. TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
  63. }
  64. #if ENABLED(HOST_ACTION_COMMANDS)
  65. #ifdef ACTION_ON_RESUME
  66. hostui.resume();
  67. #endif
  68. TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("Resuming SD"), FPSTR(DISMISS_STR)));
  69. #endif
  70. ui.reset_status();
  71. }
  72. /**
  73. * M25: Pause SD Print
  74. *
  75. * With PARK_HEAD_ON_PAUSE:
  76. * Invoke M125 to store the current position and move to the park
  77. * position. M24 will move the head back before resuming the print.
  78. */
  79. void GcodeSuite::M25() {
  80. #if ENABLED(PARK_HEAD_ON_PAUSE)
  81. M125();
  82. #else
  83. // Set initial pause flag to prevent more commands from landing in the queue while we try to pause
  84. #if ENABLED(SDSUPPORT)
  85. if (IS_SD_PRINTING()) card.pauseSDPrint();
  86. #endif
  87. #if ENABLED(POWER_LOSS_RECOVERY) && DISABLED(DGUS_LCD_UI_MKS)
  88. if (recovery.enabled) recovery.save(true);
  89. #endif
  90. print_job_timer.pause();
  91. TERN_(DGUS_LCD_UI_MKS, MKS_pause_print_move());
  92. IF_DISABLED(DWIN_CREALITY_LCD, ui.reset_status());
  93. #if ENABLED(HOST_ACTION_COMMANDS)
  94. TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_PAUSE_RESUME, F("Pause SD"), F("Resume")));
  95. #ifdef ACTION_ON_PAUSE
  96. hostui.pause();
  97. #endif
  98. #endif
  99. #endif
  100. }
  101. #endif // SDSUPPORT