Browse Source

Apply grace period to thermistor failure testing (#14167)

doggyfan 6 years ago
parent
commit
e09d8811c1
1 changed files with 16 additions and 3 deletions
  1. 16
    3
      Marlin/src/module/temperature.cpp

+ 16
- 3
Marlin/src/module/temperature.cpp View File

82
   #endif
82
   #endif
83
 #endif
83
 #endif
84
 
84
 
85
+#ifndef THERMAL_PROTECTION_GRACE_PERIOD
86
+  #define THERMAL_PROTECTION_GRACE_PERIOD 0 // No grace period needed on well-behaved boards
87
+#endif
88
+
85
 Temperature thermalManager;
89
 Temperature thermalManager;
86
 
90
 
87
 /**
91
 /**
991
   #endif
995
   #endif
992
 
996
 
993
   #if HAS_THERMAL_PROTECTION
997
   #if HAS_THERMAL_PROTECTION
994
-    #ifndef THERMAL_PROTECTION_GRACE_PERIOD
995
-      #define THERMAL_PROTECTION_GRACE_PERIOD 0 // No grace period needed on well-behaved boards
996
-    #endif
997
     #if THERMAL_PROTECTION_GRACE_PERIOD > 0
998
     #if THERMAL_PROTECTION_GRACE_PERIOD > 0
998
       static millis_t grace_period = ms + THERMAL_PROTECTION_GRACE_PERIOD;
999
       static millis_t grace_period = ms + THERMAL_PROTECTION_GRACE_PERIOD;
999
       if (ELAPSED(ms, grace_period)) grace_period = 0UL;
1000
       if (ELAPSED(ms, grace_period)) grace_period = 0UL;
2166
 #endif
2167
 #endif
2167
 
2168
 
2168
 void Temperature::readings_ready() {
2169
 void Temperature::readings_ready() {
2170
+
2171
+  #if THERMAL_PROTECTION_GRACE_PERIOD > 0
2172
+    const millis_t ms = millis();
2173
+    static millis_t grace_period = ms + THERMAL_PROTECTION_GRACE_PERIOD; // NOTE: millis() == 0 on reset
2174
+    if (ELAPSED(ms, grace_period)) grace_period = 0;
2175
+  #else
2176
+    static constexpr millis_t grace_period = 0;
2177
+  #endif
2178
+
2169
   // Update the raw values if they've been read. Else we could be updating them during reading.
2179
   // Update the raw values if they've been read. Else we could be updating them during reading.
2170
   if (!temp_meas_ready) set_current_temp_raw();
2180
   if (!temp_meas_ready) set_current_temp_raw();
2171
 
2181
 
2207
     #endif // HOTENDS > 1
2217
     #endif // HOTENDS > 1
2208
   };
2218
   };
2209
 
2219
 
2220
+  // Give ADC temperature readings time to settle at boot-up before testing
2221
+  if (grace_period) return;
2222
+
2210
   for (uint8_t e = 0; e < COUNT(temp_dir); e++) {
2223
   for (uint8_t e = 0; e < COUNT(temp_dir); e++) {
2211
     const int16_t tdir = temp_dir[e], rawtemp = temp_hotend[e].raw * tdir;
2224
     const int16_t tdir = temp_dir[e], rawtemp = temp_hotend[e].raw * tdir;
2212
     const bool heater_on = (temp_hotend[e].target > 0)
2225
     const bool heater_on = (temp_hotend[e].target > 0)

Loading…
Cancel
Save