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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 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/MarlinConfig.h"
  23. #if HAS_RESUME_CONTINUE
  24. #include "../gcode.h"
  25. #include "../../module/stepper.h"
  26. #if HAS_LCD_MENU
  27. #include "../../lcd/ultralcd.h"
  28. #endif
  29. #if ENABLED(EXTENSIBLE_UI)
  30. #include "../../lcd/extensible_ui/ui_api.h"
  31. #endif
  32. #include "../../sd/cardreader.h"
  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. const char * const args = parser.string_arg;
  45. millis_t ms = 0;
  46. bool hasP = false, hasS = false;
  47. if (parser.seenval('P')) {
  48. ms = parser.value_millis(); // milliseconds to wait
  49. hasP = ms > 0;
  50. }
  51. if (parser.seenval('S')) {
  52. ms = parser.value_millis_from_seconds(); // seconds to wait
  53. hasS = ms > 0;
  54. }
  55. const bool has_message = !hasP && !hasS && args && *args;
  56. planner.synchronize();
  57. #if HAS_LCD_MENU
  58. if (has_message)
  59. ui.set_status(args, true);
  60. else {
  61. LCD_MESSAGEPGM(MSG_USERWAIT);
  62. #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
  63. ui.reset_progress_bar_timeout();
  64. #endif
  65. }
  66. #elif ENABLED(EXTENSIBLE_UI)
  67. if (has_message)
  68. ExtUI::onUserConfirmRequired(args); // Can this take an SRAM string??
  69. else
  70. ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_USERWAIT));
  71. #else
  72. if (has_message) {
  73. SERIAL_ECHO_START();
  74. SERIAL_ECHOLN(args);
  75. }
  76. #endif
  77. KEEPALIVE_STATE(PAUSED_FOR_USER);
  78. wait_for_user = true;
  79. #if ENABLED(HOST_PROMPT_SUPPORT)
  80. host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M0/1 Break Called"), PSTR("Continue"));
  81. #endif
  82. #if ENABLED(EXTENSIBLE_UI)
  83. ExtUI::onUserConfirmRequired_P(PSTR("M0/1 Break Called"));
  84. #endif
  85. if (ms > 0) {
  86. ms += millis(); // wait until this time for a click
  87. while (PENDING(millis(), ms) && wait_for_user) idle();
  88. }
  89. else
  90. while (wait_for_user) idle();
  91. #if HAS_LEDS_OFF_FLAG
  92. printerEventLEDs.onResumeAfterWait();
  93. #endif
  94. #if HAS_LCD_MENU
  95. ui.reset_status();
  96. #endif
  97. wait_for_user = false;
  98. }
  99. #endif // HAS_RESUME_CONTINUE