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

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/M104_M109.cpp
  24. *
  25. * Hotend target temperature control
  26. */
  27. #include "../../inc/MarlinConfigPre.h"
  28. #if HAS_EXTRUDERS
  29. #include "../gcode.h"
  30. #include "../../module/temperature.h"
  31. #include "../../module/motion.h"
  32. #include "../../module/planner.h"
  33. #include "../../lcd/marlinui.h"
  34. #include "../../MarlinCore.h" // for startOrResumeJob, etc.
  35. #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
  36. #include "../../module/printcounter.h"
  37. #if ENABLED(CANCEL_OBJECTS)
  38. #include "../../feature/cancel_object.h"
  39. #endif
  40. #endif
  41. #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
  42. #include "../../module/tool_change.h"
  43. #endif
  44. /**
  45. * M104: Set Hotend Temperature target and return immediately
  46. * M109: Set Hotend Temperature target and wait
  47. *
  48. * Parameters
  49. * I<preset> : Material Preset index (if material presets are defined)
  50. * T<index> : Tool index. If omitted, applies to the active tool
  51. * S<target> : The target temperature in current units. For M109, only wait when heating up.
  52. *
  53. * With AUTOTEMP...
  54. * F<factor> : Autotemp Scaling Factor. Set non-zero to enable Auto-temp.
  55. * S<min> : Minimum temperature, in current units.
  56. * B<max> : Maximum temperature, in current units.
  57. *
  58. * M109 Parameters
  59. * R<target> : The target temperature in current units. Wait for heating and cooling.
  60. *
  61. * Examples
  62. * M104 S100 : Set target to 100° and return.
  63. * M109 R150 : Set target to 150°. Wait until the hotend gets close to 150°.
  64. *
  65. * With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer
  66. * (used by printingIsActive, etc.) and turning off heaters will stop the timer.
  67. */
  68. void GcodeSuite::M104_M109(const bool isM109) {
  69. if (DEBUGGING(DRYRUN)) return;
  70. #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
  71. constexpr int8_t target_extruder = 0;
  72. #else
  73. const int8_t target_extruder = get_target_extruder_from_command();
  74. if (target_extruder < 0) return;
  75. #endif
  76. bool got_temp = false;
  77. celsius_t temp = 0;
  78. // Accept 'I' if temperature presets are defined
  79. #if HAS_PREHEAT
  80. got_temp = parser.seenval('I');
  81. if (got_temp) {
  82. const uint8_t index = parser.value_byte();
  83. temp = ui.material_preset[_MIN(index, PREHEAT_COUNT - 1)].hotend_temp;
  84. }
  85. #endif
  86. // Get the temperature from 'S' or 'R'
  87. bool no_wait_for_cooling = false;
  88. if (!got_temp) {
  89. no_wait_for_cooling = parser.seenval('S');
  90. got_temp = no_wait_for_cooling || (isM109 && parser.seenval('R'));
  91. if (got_temp) temp = parser.value_celsius();
  92. }
  93. if (got_temp) {
  94. #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
  95. thermalManager.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 (idex_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. thermalManager.auto_job_check_timer(isM109, true);
  110. #endif
  111. if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling)
  112. thermalManager.set_heating_message(target_extruder, !isM109 && got_temp);
  113. }
  114. TERN_(AUTOTEMP, planner.autotemp_M104_M109());
  115. if (isM109 && got_temp)
  116. (void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling);
  117. }
  118. #endif // EXTRUDERS