瀏覽代碼

next_ vars faster than previous_

- Change some `previous_` time vars to `next_` so an add only happens
at intervals
- Fix `HEATER_0_USES_MAX6675` polling too frequently, or not at all
Scott Lahteine 10 年之前
父節點
當前提交
e4b1e8651b
共有 1 個文件被更改,包括 15 次插入13 次删除
  1. 15
    13
      Marlin/temperature.cpp

+ 15
- 13
Marlin/temperature.cpp 查看文件

@@ -118,7 +118,7 @@ static volatile bool temp_meas_ready = false;
118 118
   static float temp_iState_min_bed;
119 119
   static float temp_iState_max_bed;
120 120
 #else //PIDTEMPBED
121
-  static millis_t  previous_bed_check_ms;
121
+  static millis_t  next_bed_check_ms;
122 122
 #endif //PIDTEMPBED
123 123
   static unsigned char soft_pwm[EXTRUDERS];
124 124
 
@@ -126,7 +126,7 @@ static volatile bool temp_meas_ready = false;
126 126
   static unsigned char soft_pwm_fan;
127 127
 #endif
128 128
 #if HAS_AUTO_FAN
129
-  static millis_t previous_auto_fan_check_ms;
129
+  static millis_t next_auto_fan_check_ms;
130 130
 #endif  
131 131
 
132 132
 #ifdef PIDTEMP
@@ -205,7 +205,7 @@ void PID_autotune(float temp, int extruder, int ncycles)
205 205
   float max = 0, min = 10000;
206 206
 
207 207
   #if HAS_AUTO_FAN
208
-    millis_t previous_auto_fan_check_ms = temp_ms;
208
+    millis_t next_auto_fan_check_ms = temp_ms + 2500;
209 209
   #endif
210 210
 
211 211
   if (extruder >= EXTRUDERS
@@ -240,9 +240,9 @@ void PID_autotune(float temp, int extruder, int ncycles)
240 240
       min = min(min, input);
241 241
 
242 242
       #if HAS_AUTO_FAN
243
-        if (ms > previous_auto_fan_check_ms + 2500) {
243
+        if (ms > next_auto_fan_check_ms) {
244 244
           checkExtruderAutoFans();
245
-          previous_auto_fan_check_ms = ms;
245
+          next_auto_fan_check_ms = ms + 2500;
246 246
         }
247 247
       #endif
248 248
 
@@ -631,16 +631,16 @@ void manage_heater() {
631 631
   } // Extruders Loop
632 632
 
633 633
   #if HAS_AUTO_FAN
634
-    if (ms > previous_auto_fan_check_ms + 2500) { // only need to check fan state very infrequently
634
+    if (ms > next_auto_fan_check_ms) { // only need to check fan state very infrequently
635 635
       checkExtruderAutoFans();
636
-      previous_auto_fan_check_ms = ms;
636
+      next_auto_fan_check_ms = ms + 2500;
637 637
     }
638 638
   #endif       
639 639
   
640 640
   #ifndef PIDTEMPBED
641
-    if (ms < previous_bed_check_ms + BED_CHECK_INTERVAL) return;
642
-    previous_bed_check_ms = ms;
643
-  #endif //PIDTEMPBED
641
+    if (ms < previous_bed_check_ms) return;
642
+    next_bed_check_ms = ms + BED_CHECK_INTERVAL;
643
+  #endif
644 644
 
645 645
   #if TEMP_SENSOR_BED != 0
646 646
   
@@ -1109,16 +1109,18 @@ void disable_heater() {
1109 1109
 
1110 1110
 #ifdef HEATER_0_USES_MAX6675
1111 1111
   #define MAX6675_HEAT_INTERVAL 250u
1112
-  millis_t previous_max6675_ms = MAX6675_HEAT_INTERVAL;
1112
+  static millis_t next_max6675_ms = 0;
1113 1113
   int max6675_temp = 2000;
1114 1114
 
1115 1115
   static int read_max6675() {
1116 1116
 
1117 1117
     millis_t ms = millis();
1118
-    if (ms < previous_max6675_ms + MAX6675_HEAT_INTERVAL)
1118
+
1119
+    if (ms < next_max6675_ms)
1119 1120
       return max6675_temp;
1120 1121
     
1121
-    previous_max6675_ms = ms;
1122
+    next_max6675_ms = ms + MAX6675_HEAT_INTERVAL;
1123
+
1122 1124
     max6675_temp = 0;
1123 1125
 
1124 1126
     #ifdef PRR

Loading…
取消
儲存