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.3KB

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