Selaa lähdekoodia

Fix for M109 and M190 cooldown

Also removes the re-definition of now inside M190's while loop
gralco 9 vuotta sitten
vanhempi
commit
c218db136a
1 muutettua tiedostoa jossa 21 lisäystä ja 17 poistoa
  1. 21
    17
      Marlin/Marlin_main.cpp

+ 21
- 17
Marlin/Marlin_main.cpp Näytä tiedosto

4242
  *       Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling.
4242
  *       Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling.
4243
  */
4243
  */
4244
 inline void gcode_M109() {
4244
 inline void gcode_M109() {
4245
-  bool no_wait_for_cooling = true;
4246
 
4245
 
4247
   if (setTargetedHotend(109)) return;
4246
   if (setTargetedHotend(109)) return;
4248
   if (DEBUGGING(DRYRUN)) return;
4247
   if (DEBUGGING(DRYRUN)) return;
4249
 
4248
 
4250
-  no_wait_for_cooling = code_seen('S');
4249
+  bool no_wait_for_cooling = code_seen('S');
4251
   if (no_wait_for_cooling || code_seen('R')) {
4250
   if (no_wait_for_cooling || code_seen('R')) {
4252
     float temp = code_value();
4251
     float temp = code_value();
4253
     setTargetHotend(temp, target_extruder);
4252
     setTargetHotend(temp, target_extruder);
4282
     if (code_seen('B')) autotemp_max = code_value();
4281
     if (code_seen('B')) autotemp_max = code_value();
4283
   #endif
4282
   #endif
4284
 
4283
 
4285
-  // Exit if the temperature is above target and not waiting for cooling
4286
-  if (no_wait_for_cooling && !isHeatingHotend(target_extruder)) return;
4284
+  bool wants_to_cool = isCoolingHotend(target_extruder);
4285
+
4286
+  // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4287
+  if (no_wait_for_cooling && wants_to_cool) return;
4287
 
4288
 
4288
   // Prevents a wait-forever situation if R is misused i.e. M109 R0
4289
   // Prevents a wait-forever situation if R is misused i.e. M109 R0
4289
   // Try to calculate a ballpark safe margin by halving EXTRUDE_MINTEMP
4290
   // Try to calculate a ballpark safe margin by halving EXTRUDE_MINTEMP
4290
-  if (degTargetHotend(target_extruder) < (EXTRUDE_MINTEMP)/2) return;
4291
+  if (wants_to_cool && degTargetHotend(target_extruder) < (EXTRUDE_MINTEMP)/2) return;
4291
 
4292
 
4292
   #ifdef TEMP_RESIDENCY_TIME
4293
   #ifdef TEMP_RESIDENCY_TIME
4293
     millis_t residency_start_ms = 0;
4294
     millis_t residency_start_ms = 0;
4295
     #define TEMP_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL))
4296
     #define TEMP_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL))
4296
   #else
4297
   #else
4297
     // Loop until the temperature is very close target
4298
     // Loop until the temperature is very close target
4298
-    #define TEMP_CONDITIONS (isHeatingHotend(target_extruder))
4299
+    #define TEMP_CONDITIONS (wants_to_cool ? isCoolingHotend(target_extruder) : isHeatingHotend(target_extruder))
4299
   #endif //TEMP_RESIDENCY_TIME
4300
   #endif //TEMP_RESIDENCY_TIME
4300
 
4301
 
4301
   cancel_heatup = false;
4302
   cancel_heatup = false;
4302
-  millis_t now = millis(), next_temp_ms = now + 1000UL;
4303
-  while (!cancel_heatup && TEMP_CONDITIONS) {
4303
+  millis_t now, next_temp_ms = 0;
4304
+  do {
4304
     now = millis();
4305
     now = millis();
4305
     if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
4306
     if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
4306
       next_temp_ms = now + 1000UL;
4307
       next_temp_ms = now + 1000UL;
4326
 
4327
 
4327
     #ifdef TEMP_RESIDENCY_TIME
4328
     #ifdef TEMP_RESIDENCY_TIME
4328
 
4329
 
4329
-      float temp_diff = labs(degHotend(target_extruder) - degTargetHotend(target_extruder));
4330
+      float temp_diff = fabs(degTargetHotend(target_extruder) - degHotend(target_extruder));
4330
 
4331
 
4331
       if (!residency_start_ms) {
4332
       if (!residency_start_ms) {
4332
         // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
4333
         // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
4339
 
4340
 
4340
     #endif //TEMP_RESIDENCY_TIME
4341
     #endif //TEMP_RESIDENCY_TIME
4341
 
4342
 
4342
-  } // while(!cancel_heatup && TEMP_CONDITIONS)
4343
+  } while (!cancel_heatup && TEMP_CONDITIONS);
4343
 
4344
 
4344
   LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
4345
   LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
4345
 }
4346
 }
4355
 
4356
 
4356
     LCD_MESSAGEPGM(MSG_BED_HEATING);
4357
     LCD_MESSAGEPGM(MSG_BED_HEATING);
4357
     bool no_wait_for_cooling = code_seen('S');
4358
     bool no_wait_for_cooling = code_seen('S');
4358
-    if (no_wait_for_cooling || code_seen('R'))
4359
-      setTargetBed(code_value());
4359
+    if (no_wait_for_cooling || code_seen('R')) setTargetBed(code_value());
4360
+
4361
+    bool wants_to_cool = isCoolingBed();
4360
 
4362
 
4361
-    // Exit if the temperature is above target and not waiting for cooling
4362
-    if (no_wait_for_cooling && !isHeatingBed()) return;
4363
+    // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4364
+    if (no_wait_for_cooling && wants_to_cool) return;
4363
 
4365
 
4364
     cancel_heatup = false;
4366
     cancel_heatup = false;
4365
-    millis_t now = millis(), next_temp_ms = now + 1000UL;
4366
-    while (!cancel_heatup && isHeatingBed()) {
4367
+    millis_t next_temp_ms = 0;
4368
+
4369
+    // Wait for temperature to come close enough
4370
+    do {
4367
       millis_t now = millis();
4371
       millis_t now = millis();
4368
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
4372
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
4369
         next_temp_ms = now + 1000UL;
4373
         next_temp_ms = now + 1000UL;
4372
       }
4376
       }
4373
       idle();
4377
       idle();
4374
       refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4378
       refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4375
-    }
4379
+    } while (!cancel_heatup && (wants_to_cool ? isCoolingBed() : isHeatingBed()));
4376
     LCD_MESSAGEPGM(MSG_BED_DONE);
4380
     LCD_MESSAGEPGM(MSG_BED_DONE);
4377
   }
4381
   }
4378
 
4382
 

Loading…
Peruuta
Tallenna