5151
5252/* *
5353 * M104: Set Hotend Temperature target and return immediately
54- *
55- * Parameters:
56- * I<preset> : Material Preset index (if material presets are defined)
57- * T<index> : Tool index. If omitted, applies to the active tool
58- * S<target> : The target temperature in current units
59- */
60- void GcodeSuite::M104 () {
61-
62- if (DEBUGGING (DRYRUN)) return ;
63-
64- #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
65- constexpr int8_t target_extruder = 0 ;
66- #else
67- const int8_t target_extruder = get_target_extruder_from_command ();
68- if (target_extruder < 0 ) return ;
69- #endif
70-
71- bool got_temp = false ;
72- celsius_t temp = 0 ;
73-
74- // Accept 'I' if temperature presets are defined
75- #if PREHEAT_COUNT
76- got_temp = parser.seenval (' I' );
77- if (got_temp) {
78- const uint8_t index = parser.value_byte ();
79- temp = ui.material_preset [_MIN (index, PREHEAT_COUNT - 1 )].hotend_temp ;
80- }
81- #endif
82-
83- // If no 'I' get the temperature from 'S'
84- if (!got_temp) {
85- got_temp = parser.seenval (' S' );
86- if (got_temp) temp = parser.value_celsius ();
87- }
88-
89- if (got_temp) {
90- #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
91- thermalManager.singlenozzle_temp [target_extruder] = temp;
92- if (target_extruder != active_extruder) return ;
93- #endif
94- thermalManager.setTargetHotend (temp, target_extruder);
95-
96- #if ENABLED(DUAL_X_CARRIAGE)
97- if (idex_is_duplicating () && target_extruder == 0 )
98- thermalManager.setTargetHotend (temp ? temp + duplicate_extruder_temp_offset : 0 , 1 );
99- #endif
100-
101- #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
102- /* *
103- * Stop the timer at the end of print. Start is managed by 'heat and wait' M109.
104- * Hotends use EXTRUDE_MINTEMP / 2 to allow nozzles to be put into hot standby
105- * mode, for instance in a dual extruder setup, without affecting the running
106- * print timer.
107- */
108- thermalManager.auto_job_check_timer (false , true );
109- #endif
110- }
111-
112- TERN_ (AUTOTEMP, planner.autotemp_M104_M109 ());
113- }
114-
115- /* *
11654 * M109: Set Hotend Temperature target and wait
11755 *
11856 * Parameters
11957 * I<preset> : Material Preset index (if material presets are defined)
12058 * T<index> : Tool index. If omitted, applies to the active tool
121- * S<target> : The target temperature in current units. Wait for heating only.
122- * R<target> : The target temperature in current units. Wait for heating and cooling.
59+ * S<target> : The target temperature in current units. For M109, only wait when heating up.
12360 *
12461 * With AUTOTEMP...
12562 * F<factor> : Autotemp Scaling Factor. Set non-zero to enable Auto-temp.
12663 * S<min> : Minimum temperature, in current units.
12764 * B<max> : Maximum temperature, in current units.
12865 *
66+ * M109 Parameters
67+ * R<target> : The target temperature in current units. Wait for heating and cooling.
68+ *
12969 * Examples
130- * M109 S100 : Set target to 100°. Wait until the hotend is at or above 100° .
70+ * M104 S100 : Set target to 100° and return .
13171 * M109 R150 : Set target to 150°. Wait until the hotend gets close to 150°.
13272 *
13373 * With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer
13474 * (used by printingIsActive, etc.) and turning off heaters will stop the timer.
13575 */
136- void GcodeSuite::M109 ( ) {
76+ void GcodeSuite::M104_M109 ( const bool isM109 ) {
13777
13878 if (DEBUGGING (DRYRUN)) return ;
13979
@@ -160,7 +100,7 @@ void GcodeSuite::M109() {
160100 bool no_wait_for_cooling = false ;
161101 if (!got_temp) {
162102 no_wait_for_cooling = parser.seenval (' S' );
163- got_temp = no_wait_for_cooling || parser.seenval (' R' );
103+ got_temp = no_wait_for_cooling || (isM109 && parser.seenval (' R' ) );
164104 if (got_temp) temp = parser.value_celsius ();
165105 }
166106
@@ -182,7 +122,7 @@ void GcodeSuite::M109() {
182122 * standby mode, (e.g., in a dual extruder setup) without affecting
183123 * the running print timer.
184124 */
185- thermalManager.auto_job_check_timer (true , true );
125+ thermalManager.auto_job_check_timer (isM109 , true );
186126 #endif
187127
188128 #if HAS_STATUS_MESSAGE
@@ -193,7 +133,7 @@ void GcodeSuite::M109() {
193133
194134 TERN_ (AUTOTEMP, planner.autotemp_M104_M109 ());
195135
196- if (got_temp)
136+ if (isM109 && got_temp)
197137 (void )thermalManager.wait_for_hotend (target_extruder, no_wait_for_cooling);
198138}
199139
0 commit comments