Browse Source

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 years ago
parent
commit
e4b1e8651b
1 changed files with 15 additions and 13 deletions
  1. 15
    13
      Marlin/temperature.cpp

+ 15
- 13
Marlin/temperature.cpp View File

118
   static float temp_iState_min_bed;
118
   static float temp_iState_min_bed;
119
   static float temp_iState_max_bed;
119
   static float temp_iState_max_bed;
120
 #else //PIDTEMPBED
120
 #else //PIDTEMPBED
121
-  static millis_t  previous_bed_check_ms;
121
+  static millis_t  next_bed_check_ms;
122
 #endif //PIDTEMPBED
122
 #endif //PIDTEMPBED
123
   static unsigned char soft_pwm[EXTRUDERS];
123
   static unsigned char soft_pwm[EXTRUDERS];
124
 
124
 
126
   static unsigned char soft_pwm_fan;
126
   static unsigned char soft_pwm_fan;
127
 #endif
127
 #endif
128
 #if HAS_AUTO_FAN
128
 #if HAS_AUTO_FAN
129
-  static millis_t previous_auto_fan_check_ms;
129
+  static millis_t next_auto_fan_check_ms;
130
 #endif  
130
 #endif  
131
 
131
 
132
 #ifdef PIDTEMP
132
 #ifdef PIDTEMP
205
   float max = 0, min = 10000;
205
   float max = 0, min = 10000;
206
 
206
 
207
   #if HAS_AUTO_FAN
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
   #endif
209
   #endif
210
 
210
 
211
   if (extruder >= EXTRUDERS
211
   if (extruder >= EXTRUDERS
240
       min = min(min, input);
240
       min = min(min, input);
241
 
241
 
242
       #if HAS_AUTO_FAN
242
       #if HAS_AUTO_FAN
243
-        if (ms > previous_auto_fan_check_ms + 2500) {
243
+        if (ms > next_auto_fan_check_ms) {
244
           checkExtruderAutoFans();
244
           checkExtruderAutoFans();
245
-          previous_auto_fan_check_ms = ms;
245
+          next_auto_fan_check_ms = ms + 2500;
246
         }
246
         }
247
       #endif
247
       #endif
248
 
248
 
631
   } // Extruders Loop
631
   } // Extruders Loop
632
 
632
 
633
   #if HAS_AUTO_FAN
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
       checkExtruderAutoFans();
635
       checkExtruderAutoFans();
636
-      previous_auto_fan_check_ms = ms;
636
+      next_auto_fan_check_ms = ms + 2500;
637
     }
637
     }
638
   #endif       
638
   #endif       
639
   
639
   
640
   #ifndef PIDTEMPBED
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
   #if TEMP_SENSOR_BED != 0
645
   #if TEMP_SENSOR_BED != 0
646
   
646
   
1109
 
1109
 
1110
 #ifdef HEATER_0_USES_MAX6675
1110
 #ifdef HEATER_0_USES_MAX6675
1111
   #define MAX6675_HEAT_INTERVAL 250u
1111
   #define MAX6675_HEAT_INTERVAL 250u
1112
-  millis_t previous_max6675_ms = MAX6675_HEAT_INTERVAL;
1112
+  static millis_t next_max6675_ms = 0;
1113
   int max6675_temp = 2000;
1113
   int max6675_temp = 2000;
1114
 
1114
 
1115
   static int read_max6675() {
1115
   static int read_max6675() {
1116
 
1116
 
1117
     millis_t ms = millis();
1117
     millis_t ms = millis();
1118
-    if (ms < previous_max6675_ms + MAX6675_HEAT_INTERVAL)
1118
+
1119
+    if (ms < next_max6675_ms)
1119
       return max6675_temp;
1120
       return max6675_temp;
1120
     
1121
     
1121
-    previous_max6675_ms = ms;
1122
+    next_max6675_ms = ms + MAX6675_HEAT_INTERVAL;
1123
+
1122
     max6675_temp = 0;
1124
     max6675_temp = 0;
1123
 
1125
 
1124
     #ifdef PRR
1126
     #ifdef PRR

Loading…
Cancel
Save