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.

M104_M109.cpp 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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/MarlinConfigPre.h"
  23. #if EXTRUDERS
  24. #include "../gcode.h"
  25. #include "../../module/temperature.h"
  26. #include "../../module/motion.h"
  27. #include "../../module/planner.h"
  28. #include "../../lcd/ultralcd.h"
  29. #include "../../MarlinCore.h" // for startOrResumeJob, etc.
  30. #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
  31. #include "../../module/printcounter.h"
  32. #if ENABLED(CANCEL_OBJECTS)
  33. #include "../../feature/cancel_object.h"
  34. #endif
  35. #endif
  36. #if ENABLED(SINGLENOZZLE)
  37. #include "../../module/tool_change.h"
  38. #endif
  39. /**
  40. * M104: Set hot end temperature
  41. */
  42. void GcodeSuite::M104() {
  43. if (DEBUGGING(DRYRUN)) return;
  44. #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
  45. constexpr int8_t target_extruder = 0;
  46. #else
  47. const int8_t target_extruder = get_target_extruder_from_command();
  48. if (target_extruder < 0) return;
  49. #endif
  50. if (parser.seenval('S')) {
  51. const int16_t temp = parser.value_celsius();
  52. #if ENABLED(SINGLENOZZLE)
  53. singlenozzle_temp[target_extruder] = temp;
  54. if (target_extruder != active_extruder) return;
  55. #endif
  56. thermalManager.setTargetHotend(temp, target_extruder);
  57. #if ENABLED(DUAL_X_CARRIAGE)
  58. if (dxc_is_duplicating() && target_extruder == 0)
  59. thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
  60. #endif
  61. #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
  62. /**
  63. * Stop the timer at the end of print. Start is managed by 'heat and wait' M109.
  64. * We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot
  65. * standby mode, for instance in a dual extruder setup, without affecting
  66. * the running print timer.
  67. */
  68. if (temp <= (EXTRUDE_MINTEMP) / 2) {
  69. print_job_timer.stop();
  70. ui.reset_status();
  71. }
  72. #endif
  73. }
  74. #if ENABLED(AUTOTEMP)
  75. planner.autotemp_M104_M109();
  76. #endif
  77. }
  78. /**
  79. * M109: Sxxx Wait for extruder(s) to reach temperature. Waits only when heating.
  80. * Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling.
  81. */
  82. void GcodeSuite::M109() {
  83. if (DEBUGGING(DRYRUN)) return;
  84. #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
  85. constexpr int8_t target_extruder = 0;
  86. #else
  87. const int8_t target_extruder = get_target_extruder_from_command();
  88. if (target_extruder < 0) return;
  89. #endif
  90. const bool no_wait_for_cooling = parser.seenval('S'),
  91. set_temp = no_wait_for_cooling || parser.seenval('R');
  92. if (set_temp) {
  93. const int16_t temp = parser.value_celsius();
  94. #if ENABLED(SINGLENOZZLE)
  95. singlenozzle_temp[target_extruder] = temp;
  96. if (target_extruder != active_extruder) return;
  97. #endif
  98. thermalManager.setTargetHotend(temp, target_extruder);
  99. #if ENABLED(DUAL_X_CARRIAGE)
  100. if (dxc_is_duplicating() && target_extruder == 0)
  101. thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
  102. #endif
  103. #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
  104. /**
  105. * Use half EXTRUDE_MINTEMP to allow nozzles to be put into hot
  106. * standby mode, (e.g., in a dual extruder setup) without affecting
  107. * the running print timer.
  108. */
  109. if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) {
  110. print_job_timer.stop();
  111. ui.reset_status();
  112. }
  113. else
  114. startOrResumeJob();
  115. #endif
  116. #if HAS_DISPLAY
  117. if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling)
  118. thermalManager.set_heating_message(target_extruder);
  119. #endif
  120. }
  121. #if ENABLED(AUTOTEMP)
  122. planner.autotemp_M104_M109();
  123. #endif
  124. if (set_temp)
  125. (void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling);
  126. }
  127. #endif // EXTRUDERS