Преглед изворни кода

Skip hysteresis check when temp is already close to target

To eliminate a long delay during pause, park, and filament change
Scott Lahteine пре 6 година
родитељ
комит
7fde3ed915
1 измењених фајлова са 11 додато и 3 уклоњено
  1. 11
    3
      Marlin/src/module/temperature.cpp

+ 11
- 3
Marlin/src/module/temperature.cpp Прегледај датотеку

@@ -2716,7 +2716,7 @@ void Temperature::isr() {
2716 2716
       #endif
2717 2717
 
2718 2718
       float target_temp = -1.0, old_temp = 9999.0;
2719
-      bool wants_to_cool = false;
2719
+      bool wants_to_cool = false, first_loop = true;
2720 2720
       wait_for_heatup = true;
2721 2721
       millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
2722 2722
       do {
@@ -2759,7 +2759,10 @@ void Temperature::isr() {
2759 2759
 
2760 2760
           if (!residency_start_ms) {
2761 2761
             // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
2762
-            if (temp_diff < TEMP_WINDOW) residency_start_ms = now;
2762
+            if (temp_diff < TEMP_WINDOW) {
2763
+              residency_start_ms = now;
2764
+              if (first_loop) residency_start_ms += (TEMP_RESIDENCY_TIME) * 1000UL;
2765
+            }
2763 2766
           }
2764 2767
           else if (temp_diff > TEMP_HYSTERESIS) {
2765 2768
             // Restart the timer whenever the temperature falls outside the hysteresis.
@@ -2786,6 +2789,8 @@ void Temperature::isr() {
2786 2789
           }
2787 2790
         #endif
2788 2791
 
2792
+        first_loop = false;
2793
+
2789 2794
       } while (wait_for_heatup && TEMP_CONDITIONS);
2790 2795
 
2791 2796
       if (wait_for_heatup) {
@@ -2828,7 +2833,7 @@ void Temperature::isr() {
2828 2833
       #endif
2829 2834
 
2830 2835
       float target_temp = -1, old_temp = 9999;
2831
-      bool wants_to_cool = false;
2836
+      bool wants_to_cool = false, first_loop = true;
2832 2837
       wait_for_heatup = true;
2833 2838
       millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
2834 2839
 
@@ -2883,6 +2888,7 @@ void Temperature::isr() {
2883 2888
           if (!residency_start_ms) {
2884 2889
             // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
2885 2890
             if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = now;
2891
+            if (first_loop) residency_start_ms += (TEMP_BED_RESIDENCY_TIME) * 1000UL;
2886 2892
           }
2887 2893
           else if (temp_diff > TEMP_BED_HYSTERESIS) {
2888 2894
             // Restart the timer whenever the temperature falls outside the hysteresis.
@@ -2909,6 +2915,8 @@ void Temperature::isr() {
2909 2915
           }
2910 2916
         #endif
2911 2917
 
2918
+        first_loop = false;
2919
+
2912 2920
       } while (wait_for_heatup && TEMP_BED_CONDITIONS);
2913 2921
 
2914 2922
       if (wait_for_heatup) ui.reset_status();

Loading…
Откажи
Сачувај