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

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