Selaa lähdekoodia

Merge pull request #4073 from thinkyhead/rc_temp_mystery

Minor tweaks to M109 / M190
Scott Lahteine 8 vuotta sitten
vanhempi
commit
3a150f07c2
1 muutettua tiedostoa jossa 31 lisäystä ja 33 poistoa
  1. 31
    33
      Marlin/Marlin_main.cpp

+ 31
- 33
Marlin/Marlin_main.cpp Näytä tiedosto

@@ -4702,12 +4702,23 @@ inline void gcode_M109() {
4702 4702
   KEEPALIVE_STATE(NOT_BUSY);
4703 4703
 
4704 4704
   do {
4705
+    // Target temperature might be changed during the loop
4706
+    if (theTarget != thermalManager.degTargetHotend(target_extruder)) {
4707
+      wants_to_cool = thermalManager.isCoolingHotend(target_extruder);
4708
+      theTarget = thermalManager.degTargetHotend(target_extruder);
4709
+
4710
+      // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4711
+      if (no_wait_for_cooling && wants_to_cool) break;
4712
+
4713
+      // Prevent a wait-forever situation if R is misused i.e. M109 R0
4714
+      // Try to calculate a ballpark safe margin by halving EXTRUDE_MINTEMP
4715
+      if (wants_to_cool && theTarget < (EXTRUDE_MINTEMP)/2) break;
4716
+    }
4717
+
4705 4718
     now = millis();
4706 4719
     if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
4707 4720
       next_temp_ms = now + 1000UL;
4708
-      #if HAS_TEMP_HOTEND || HAS_TEMP_BED
4709
-        print_heaterstates();
4710
-      #endif
4721
+      print_heaterstates();
4711 4722
       #if TEMP_RESIDENCY_TIME > 0
4712 4723
         SERIAL_PROTOCOLPGM(" W:");
4713 4724
         if (residency_start_ms) {
@@ -4722,19 +4733,6 @@ inline void gcode_M109() {
4722 4733
       #endif
4723 4734
     }
4724 4735
 
4725
-    // Target temperature might be changed during the loop
4726
-    if (theTarget != thermalManager.degTargetHotend(target_extruder)) {
4727
-      wants_to_cool = thermalManager.isCoolingHotend(target_extruder);
4728
-      theTarget = thermalManager.degTargetHotend(target_extruder);
4729
-
4730
-      // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4731
-      if (no_wait_for_cooling && wants_to_cool) break;
4732
-
4733
-      // Prevent a wait-forever situation if R is misused i.e. M109 R0
4734
-      // Try to calculate a ballpark safe margin by halving EXTRUDE_MINTEMP
4735
-      if (wants_to_cool && theTarget < (EXTRUDE_MINTEMP)/2) break;
4736
-    }
4737
-
4738 4736
     idle();
4739 4737
     refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4740 4738
 
@@ -4744,11 +4742,11 @@ inline void gcode_M109() {
4744 4742
 
4745 4743
       if (!residency_start_ms) {
4746 4744
         // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
4747
-        if (temp_diff < TEMP_WINDOW) residency_start_ms = millis();
4745
+        if (temp_diff < TEMP_WINDOW) residency_start_ms = now;
4748 4746
       }
4749 4747
       else if (temp_diff > TEMP_HYSTERESIS) {
4750 4748
         // Restart the timer whenever the temperature falls outside the hysteresis.
4751
-        residency_start_ms = millis();
4749
+        residency_start_ms = now;
4752 4750
       }
4753 4751
 
4754 4752
     #endif //TEMP_RESIDENCY_TIME > 0
@@ -4789,6 +4787,19 @@ inline void gcode_M109() {
4789 4787
     KEEPALIVE_STATE(NOT_BUSY);
4790 4788
 
4791 4789
     do {
4790
+      // Target temperature might be changed during the loop
4791
+      if (theTarget != thermalManager.degTargetBed()) {
4792
+        wants_to_cool = thermalManager.isCoolingBed();
4793
+        theTarget = thermalManager.degTargetBed();
4794
+
4795
+        // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4796
+        if (no_wait_for_cooling && wants_to_cool) break;
4797
+
4798
+        // Prevent a wait-forever situation if R is misused i.e. M190 R0
4799
+        // Simply don't wait to cool a bed under 30C
4800
+        if (wants_to_cool && theTarget < 30) break;
4801
+      }
4802
+
4792 4803
       now = millis();
4793 4804
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
4794 4805
         next_temp_ms = now + 1000UL;
@@ -4807,19 +4818,6 @@ inline void gcode_M109() {
4807 4818
         #endif
4808 4819
       }
4809 4820
 
4810
-      // Target temperature might be changed during the loop
4811
-      if (theTarget != thermalManager.degTargetBed()) {
4812
-        wants_to_cool = thermalManager.isCoolingBed();
4813
-        theTarget = thermalManager.degTargetBed();
4814
-
4815
-        // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4816
-        if (no_wait_for_cooling && wants_to_cool) break;
4817
-
4818
-        // Prevent a wait-forever situation if R is misused i.e. M190 R0
4819
-        // Simply don't wait to cool a bed under 30C
4820
-        if (wants_to_cool && theTarget < 30) break;
4821
-      }
4822
-
4823 4821
       idle();
4824 4822
       refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4825 4823
 
@@ -4829,11 +4827,11 @@ inline void gcode_M109() {
4829 4827
 
4830 4828
         if (!residency_start_ms) {
4831 4829
           // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
4832
-          if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = millis();
4830
+          if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = now;
4833 4831
         }
4834 4832
         else if (temp_diff > TEMP_BED_HYSTERESIS) {
4835 4833
           // Restart the timer whenever the temperature falls outside the hysteresis.
4836
-          residency_start_ms = millis();
4834
+          residency_start_ms = now;
4837 4835
         }
4838 4836
 
4839 4837
       #endif //TEMP_BED_RESIDENCY_TIME > 0

Loading…
Peruuta
Tallenna