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.

M140_M190.cpp 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. /**
  23. * gcode/temp/M140_M190.cpp
  24. *
  25. * Bed target temperature control
  26. */
  27. #include "../../inc/MarlinConfig.h"
  28. #if HAS_HEATED_BED
  29. #include "../gcode.h"
  30. #include "../../module/temperature.h"
  31. #include "../../module/motion.h"
  32. #include "../../lcd/ultralcd.h"
  33. #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
  34. #include "../../module/printcounter.h"
  35. #endif
  36. #if ENABLED(PRINTER_EVENT_LEDS)
  37. #include "../../feature/leds/leds.h"
  38. #endif
  39. #include "../../MarlinCore.h" // for wait_for_heatup, idle, startOrResumeJob
  40. /**
  41. * M140: Set bed temperature
  42. *
  43. * I<index> : Preset index (if material presets are defined)
  44. * S<target> : The target temperature in current units
  45. */
  46. void GcodeSuite::M140() {
  47. if (DEBUGGING(DRYRUN)) return;
  48. bool got_temp = false;
  49. int16_t temp = 0;
  50. // Accept 'I' if temperature presets are defined
  51. #if PREHEAT_COUNT
  52. got_temp = parser.seenval('I');
  53. if (got_temp) {
  54. const uint8_t index = parser.value_byte();
  55. temp = ui.material_preset[_MIN(index, PREHEAT_COUNT - 1)].bed_temp;
  56. }
  57. #endif
  58. // If no 'I' get the temperature from 'S'
  59. if (!got_temp) {
  60. got_temp = parser.seenval('S');
  61. if (got_temp) temp = parser.value_celsius();
  62. }
  63. if (got_temp) {
  64. thermalManager.setTargetBed(temp);
  65. #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
  66. /**
  67. * Stop the timer at the end of print. Hotend, bed target, and chamber
  68. * temperatures need to be set below mintemp. Order of M140, M104, and M141
  69. * at the end of the print does not matter.
  70. */
  71. thermalManager.check_timer_autostart(false, true);
  72. #endif
  73. }
  74. }
  75. /**
  76. * M190 - Set Bed Temperature target and wait
  77. *
  78. * Parameters:
  79. * I<index> : Preset index (if material presets are defined)
  80. * S<target> : The target temperature in current units. Wait for heating only.
  81. * R<target> : The target temperature in current units. Wait for heating and cooling.
  82. *
  83. * Examples:
  84. * M190 S60 : Set target to 60°. Wait until the bed is at or above 60°.
  85. * M190 R40 : Set target to 40°. Wait until the bed gets close to 40°.
  86. *
  87. * With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer
  88. * (used by printingIsActive, etc.) and turning off heaters will stop the timer.
  89. */
  90. void GcodeSuite::M190() {
  91. if (DEBUGGING(DRYRUN)) return;
  92. bool got_temp = false;
  93. int16_t temp = 0;
  94. // Accept 'I' if temperature presets are defined
  95. #if PREHEAT_COUNT
  96. got_temp = parser.seenval('I');
  97. if (got_temp) {
  98. const uint8_t index = parser.value_byte();
  99. temp = ui.material_preset[_MIN(index, PREHEAT_COUNT - 1)].bed_temp;
  100. }
  101. #endif
  102. // Get the temperature from 'S' or 'R'
  103. bool no_wait_for_cooling = false;
  104. if (!got_temp) {
  105. no_wait_for_cooling = parser.seenval('S');
  106. got_temp = no_wait_for_cooling || parser.seenval('R');
  107. if (got_temp) temp = int16_t(parser.value_celsius());
  108. }
  109. if (!got_temp) return;
  110. thermalManager.setTargetBed(temp);
  111. TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.check_timer_autostart(true, false));
  112. ui.set_status_P(thermalManager.isHeatingBed() ? GET_TEXT(MSG_BED_HEATING) : GET_TEXT(MSG_BED_COOLING));
  113. thermalManager.wait_for_bed(no_wait_for_cooling);
  114. }
  115. #endif // HAS_HEATED_BED