Browse Source

Minor tweaks to M109 / M190

Scott Lahteine 8 years ago
parent
commit
de177ba6c9
1 changed files with 31 additions and 33 deletions
  1. 31
    33
      Marlin/Marlin_main.cpp

+ 31
- 33
Marlin/Marlin_main.cpp View File

@@ -4738,12 +4738,23 @@ inline void gcode_M109() {
4738 4738
   KEEPALIVE_STATE(NOT_BUSY);
4739 4739
 
4740 4740
   do {
4741
+    // Target temperature might be changed during the loop
4742
+    if (theTarget != thermalManager.degTargetHotend(target_extruder)) {
4743
+      wants_to_cool = thermalManager.isCoolingHotend(target_extruder);
4744
+      theTarget = thermalManager.degTargetHotend(target_extruder);
4745
+
4746
+      // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4747
+      if (no_wait_for_cooling && wants_to_cool) break;
4748
+
4749
+      // Prevent a wait-forever situation if R is misused i.e. M109 R0
4750
+      // Try to calculate a ballpark safe margin by halving EXTRUDE_MINTEMP
4751
+      if (wants_to_cool && theTarget < (EXTRUDE_MINTEMP)/2) break;
4752
+    }
4753
+
4741 4754
     now = millis();
4742 4755
     if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
4743 4756
       next_temp_ms = now + 1000UL;
4744
-      #if HAS_TEMP_HOTEND || HAS_TEMP_BED
4745
-        print_heaterstates();
4746
-      #endif
4757
+      print_heaterstates();
4747 4758
       #if TEMP_RESIDENCY_TIME > 0
4748 4759
         SERIAL_PROTOCOLPGM(" W:");
4749 4760
         if (residency_start_ms) {
@@ -4758,19 +4769,6 @@ inline void gcode_M109() {
4758 4769
       #endif
4759 4770
     }
4760 4771
 
4761
-    // Target temperature might be changed during the loop
4762
-    if (theTarget != thermalManager.degTargetHotend(target_extruder)) {
4763
-      wants_to_cool = thermalManager.isCoolingHotend(target_extruder);
4764
-      theTarget = thermalManager.degTargetHotend(target_extruder);
4765
-
4766
-      // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4767
-      if (no_wait_for_cooling && wants_to_cool) break;
4768
-
4769
-      // Prevent a wait-forever situation if R is misused i.e. M109 R0
4770
-      // Try to calculate a ballpark safe margin by halving EXTRUDE_MINTEMP
4771
-      if (wants_to_cool && theTarget < (EXTRUDE_MINTEMP)/2) break;
4772
-    }
4773
-
4774 4772
     idle();
4775 4773
     refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4776 4774
 
@@ -4780,11 +4778,11 @@ inline void gcode_M109() {
4780 4778
 
4781 4779
       if (!residency_start_ms) {
4782 4780
         // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
4783
-        if (temp_diff < TEMP_WINDOW) residency_start_ms = millis();
4781
+        if (temp_diff < TEMP_WINDOW) residency_start_ms = now;
4784 4782
       }
4785 4783
       else if (temp_diff > TEMP_HYSTERESIS) {
4786 4784
         // Restart the timer whenever the temperature falls outside the hysteresis.
4787
-        residency_start_ms = millis();
4785
+        residency_start_ms = now;
4788 4786
       }
4789 4787
 
4790 4788
     #endif //TEMP_RESIDENCY_TIME > 0
@@ -4825,6 +4823,19 @@ inline void gcode_M109() {
4825 4823
     KEEPALIVE_STATE(NOT_BUSY);
4826 4824
 
4827 4825
     do {
4826
+      // Target temperature might be changed during the loop
4827
+      if (theTarget != thermalManager.degTargetBed()) {
4828
+        wants_to_cool = thermalManager.isCoolingBed();
4829
+        theTarget = thermalManager.degTargetBed();
4830
+
4831
+        // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4832
+        if (no_wait_for_cooling && wants_to_cool) break;
4833
+
4834
+        // Prevent a wait-forever situation if R is misused i.e. M190 R0
4835
+        // Simply don't wait to cool a bed under 30C
4836
+        if (wants_to_cool && theTarget < 30) break;
4837
+      }
4838
+
4828 4839
       now = millis();
4829 4840
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
4830 4841
         next_temp_ms = now + 1000UL;
@@ -4843,19 +4854,6 @@ inline void gcode_M109() {
4843 4854
         #endif
4844 4855
       }
4845 4856
 
4846
-      // Target temperature might be changed during the loop
4847
-      if (theTarget != thermalManager.degTargetBed()) {
4848
-        wants_to_cool = thermalManager.isCoolingBed();
4849
-        theTarget = thermalManager.degTargetBed();
4850
-
4851
-        // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4852
-        if (no_wait_for_cooling && wants_to_cool) break;
4853
-
4854
-        // Prevent a wait-forever situation if R is misused i.e. M190 R0
4855
-        // Simply don't wait to cool a bed under 30C
4856
-        if (wants_to_cool && theTarget < 30) break;
4857
-      }
4858
-
4859 4857
       idle();
4860 4858
       refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4861 4859
 
@@ -4865,11 +4863,11 @@ inline void gcode_M109() {
4865 4863
 
4866 4864
         if (!residency_start_ms) {
4867 4865
           // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
4868
-          if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = millis();
4866
+          if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = now;
4869 4867
         }
4870 4868
         else if (temp_diff > TEMP_BED_HYSTERESIS) {
4871 4869
           // Restart the timer whenever the temperature falls outside the hysteresis.
4872
-          residency_start_ms = millis();
4870
+          residency_start_ms = now;
4873 4871
         }
4874 4872
 
4875 4873
       #endif //TEMP_BED_RESIDENCY_TIME > 0

Loading…
Cancel
Save