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 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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 ENABLED(ULTIPANEL)
  27. #include "../../lcd/ultralcd.h"
  28. #endif
  29. #include "../../sd/cardreader.h"
  30. /**
  31. * M0: Unconditional stop - Wait for user button press on LCD
  32. * M1: Conditional stop - Wait for user button press on LCD
  33. */
  34. void GcodeSuite::M0_M1() {
  35. const char * const args = parser.string_arg;
  36. millis_t ms = 0;
  37. bool hasP = false, hasS = false;
  38. if (parser.seenval('P')) {
  39. ms = parser.value_millis(); // milliseconds to wait
  40. hasP = ms > 0;
  41. }
  42. if (parser.seenval('S')) {
  43. ms = parser.value_millis_from_seconds(); // seconds to wait
  44. hasS = ms > 0;
  45. }
  46. #if ENABLED(ULTIPANEL)
  47. if (!hasP && !hasS && args && *args)
  48. lcd_setstatus(args, true);
  49. else {
  50. LCD_MESSAGEPGM(MSG_USERWAIT);
  51. #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
  52. dontExpireStatus();
  53. #endif
  54. }
  55. #else
  56. if (!hasP && !hasS && args && *args) {
  57. SERIAL_ECHO_START();
  58. SERIAL_ECHOLN(args);
  59. }
  60. #endif
  61. KEEPALIVE_STATE(PAUSED_FOR_USER);
  62. wait_for_user = true;
  63. stepper.synchronize();
  64. refresh_cmd_timeout();
  65. if (ms > 0) {
  66. ms += previous_cmd_ms; // wait until this time for a click
  67. while (PENDING(millis(), ms) && wait_for_user) idle();
  68. }
  69. else {
  70. #if ENABLED(ULTIPANEL)
  71. if (lcd_detected()) {
  72. while (wait_for_user) idle();
  73. IS_SD_PRINTING ? LCD_MESSAGEPGM(MSG_RESUMING) : LCD_MESSAGEPGM(WELCOME_MSG);
  74. }
  75. #else
  76. while (wait_for_user) idle();
  77. #endif
  78. }
  79. wait_for_user = false;
  80. KEEPALIVE_STATE(IN_HANDLER);
  81. }
  82. #endif // HAS_RESUME_CONTINUE