Pārlūkot izejas kodu

Merge pull request #3469 from thinkyhead/rc_aleph_cooldownfix

Fix for M109 and M190 cooldown
Scott Lahteine 8 gadus atpakaļ
vecāks
revīzija
56acaf3594
1 mainītis faili ar 21 papildinājumiem un 17 dzēšanām
  1. 21
    17
      Marlin/Marlin_main.cpp

+ 21
- 17
Marlin/Marlin_main.cpp Parādīt failu

@@ -4262,12 +4262,11 @@ inline void gcode_M105() {
4262 4262
  *       Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling.
4263 4263
  */
4264 4264
 inline void gcode_M109() {
4265
-  bool no_wait_for_cooling = true;
4266 4265
 
4267 4266
   if (setTargetedHotend(109)) return;
4268 4267
   if (DEBUGGING(DRYRUN)) return;
4269 4268
 
4270
-  no_wait_for_cooling = code_seen('S');
4269
+  bool no_wait_for_cooling = code_seen('S');
4271 4270
   if (no_wait_for_cooling || code_seen('R')) {
4272 4271
     float temp = code_value();
4273 4272
     setTargetHotend(temp, target_extruder);
@@ -4302,12 +4301,14 @@ inline void gcode_M109() {
4302 4301
     if (code_seen('B')) autotemp_max = code_value();
4303 4302
   #endif
4304 4303
 
4305
-  // Exit if the temperature is above target and not waiting for cooling
4306
-  if (no_wait_for_cooling && !isHeatingHotend(target_extruder)) return;
4304
+  bool wants_to_cool = isCoolingHotend(target_extruder);
4305
+
4306
+  // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4307
+  if (no_wait_for_cooling && wants_to_cool) return;
4307 4308
 
4308 4309
   // Prevents a wait-forever situation if R is misused i.e. M109 R0
4309 4310
   // Try to calculate a ballpark safe margin by halving EXTRUDE_MINTEMP
4310
-  if (degTargetHotend(target_extruder) < (EXTRUDE_MINTEMP)/2) return;
4311
+  if (wants_to_cool && degTargetHotend(target_extruder) < (EXTRUDE_MINTEMP)/2) return;
4311 4312
 
4312 4313
   #ifdef TEMP_RESIDENCY_TIME
4313 4314
     millis_t residency_start_ms = 0;
@@ -4315,12 +4316,12 @@ inline void gcode_M109() {
4315 4316
     #define TEMP_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL))
4316 4317
   #else
4317 4318
     // Loop until the temperature is very close target
4318
-    #define TEMP_CONDITIONS (isHeatingHotend(target_extruder))
4319
+    #define TEMP_CONDITIONS (wants_to_cool ? isCoolingHotend(target_extruder) : isHeatingHotend(target_extruder))
4319 4320
   #endif //TEMP_RESIDENCY_TIME
4320 4321
 
4321 4322
   cancel_heatup = false;
4322
-  millis_t now = millis(), next_temp_ms = now + 1000UL;
4323
-  while (!cancel_heatup && TEMP_CONDITIONS) {
4323
+  millis_t now, next_temp_ms = 0;
4324
+  do {
4324 4325
     now = millis();
4325 4326
     if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
4326 4327
       next_temp_ms = now + 1000UL;
@@ -4346,7 +4347,7 @@ inline void gcode_M109() {
4346 4347
 
4347 4348
     #ifdef TEMP_RESIDENCY_TIME
4348 4349
 
4349
-      float temp_diff = labs(degHotend(target_extruder) - degTargetHotend(target_extruder));
4350
+      float temp_diff = fabs(degTargetHotend(target_extruder) - degHotend(target_extruder));
4350 4351
 
4351 4352
       if (!residency_start_ms) {
4352 4353
         // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
@@ -4359,7 +4360,7 @@ inline void gcode_M109() {
4359 4360
 
4360 4361
     #endif //TEMP_RESIDENCY_TIME
4361 4362
 
4362
-  } // while(!cancel_heatup && TEMP_CONDITIONS)
4363
+  } while (!cancel_heatup && TEMP_CONDITIONS);
4363 4364
 
4364 4365
   LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
4365 4366
 }
@@ -4375,15 +4376,18 @@ inline void gcode_M109() {
4375 4376
 
4376 4377
     LCD_MESSAGEPGM(MSG_BED_HEATING);
4377 4378
     bool no_wait_for_cooling = code_seen('S');
4378
-    if (no_wait_for_cooling || code_seen('R'))
4379
-      setTargetBed(code_value());
4379
+    if (no_wait_for_cooling || code_seen('R')) setTargetBed(code_value());
4380
+
4381
+    bool wants_to_cool = isCoolingBed();
4380 4382
 
4381
-    // Exit if the temperature is above target and not waiting for cooling
4382
-    if (no_wait_for_cooling && !isHeatingBed()) return;
4383
+    // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4384
+    if (no_wait_for_cooling && wants_to_cool) return;
4383 4385
 
4384 4386
     cancel_heatup = false;
4385
-    millis_t now = millis(), next_temp_ms = now + 1000UL;
4386
-    while (!cancel_heatup && isHeatingBed()) {
4387
+    millis_t next_temp_ms = 0;
4388
+
4389
+    // Wait for temperature to come close enough
4390
+    do {
4387 4391
       millis_t now = millis();
4388 4392
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
4389 4393
         next_temp_ms = now + 1000UL;
@@ -4392,7 +4396,7 @@ inline void gcode_M109() {
4392 4396
       }
4393 4397
       idle();
4394 4398
       refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4395
-    }
4399
+    } while (!cancel_heatup && (wants_to_cool ? isCoolingBed() : isHeatingBed()));
4396 4400
     LCD_MESSAGEPGM(MSG_BED_DONE);
4397 4401
   }
4398 4402
 

Notiek ielāde…
Atcelt
Saglabāt