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.

M0_M1.cpp 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfigPre.h"
  23. #if HAS_RESUME_CONTINUE
  24. #include "../gcode.h"
  25. #include "../../module/planner.h"
  26. #include "../../inc/MarlinConfig.h"
  27. #if HAS_LCD_MENU
  28. #include "../../lcd/ultralcd.h"
  29. #endif
  30. #if ENABLED(EXTENSIBLE_UI)
  31. #include "../../lcd/extensible_ui/ui_api.h"
  32. #endif
  33. #if HAS_LEDS_OFF_FLAG
  34. #include "../../feature/leds/printer_event_leds.h"
  35. #endif
  36. #if ENABLED(HOST_PROMPT_SUPPORT)
  37. #include "../../feature/host_actions.h"
  38. #endif
  39. /**
  40. * M0: Unconditional stop - Wait for user button press on LCD
  41. * M1: Conditional stop - Wait for user button press on LCD
  42. */
  43. void GcodeSuite::M0_M1() {
  44. millis_t ms = 0;
  45. if (parser.seenval('P')) ms = parser.value_millis(); // Milliseconds to wait
  46. if (parser.seenval('S')) ms = parser.value_millis_from_seconds(); // Seconds to wait
  47. planner.synchronize();
  48. #if HAS_LEDS_OFF_FLAG
  49. const bool seenQ = parser.seen('Q');
  50. if (seenQ) printerEventLEDs.onPrintCompleted(); // Change LED color for Print Completed
  51. #else
  52. constexpr bool seenQ = false;
  53. #endif
  54. #if HAS_LCD_MENU
  55. if (parser.string_arg)
  56. ui.set_status(parser.string_arg, true);
  57. else if (!seenQ) {
  58. LCD_MESSAGEPGM(MSG_USERWAIT);
  59. #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
  60. ui.reset_progress_bar_timeout();
  61. #endif
  62. }
  63. #elif ENABLED(EXTENSIBLE_UI)
  64. if (parser.string_arg)
  65. ExtUI::onUserConfirmRequired(parser.string_arg); // Can this take an SRAM string??
  66. else
  67. ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_USERWAIT));
  68. #else
  69. if (parser.string_arg) {
  70. SERIAL_ECHO_START();
  71. SERIAL_ECHOLN(parser.string_arg);
  72. }
  73. #endif
  74. KEEPALIVE_STATE(PAUSED_FOR_USER);
  75. wait_for_user = true;
  76. #if ENABLED(HOST_PROMPT_SUPPORT)
  77. host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR);
  78. #endif
  79. if (ms > 0) ms += millis(); // wait until this time for a click
  80. while (wait_for_user && (ms == 0 || PENDING(millis(), ms))) idle();
  81. #if HAS_LEDS_OFF_FLAG
  82. printerEventLEDs.onResumeAfterWait();
  83. #endif
  84. #if HAS_LCD_MENU
  85. ui.reset_status();
  86. #endif
  87. wait_for_user = false;
  88. }
  89. #endif // HAS_RESUME_CONTINUE