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,6 +82,10 @@
82 82
   #endif
83 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 89
 Temperature thermalManager;
86 90
 
87 91
 /**
@@ -991,9 +995,6 @@ void Temperature::manage_heater() {
991 995
   #endif
992 996
 
993 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 998
     #if THERMAL_PROTECTION_GRACE_PERIOD > 0
998 999
       static millis_t grace_period = ms + THERMAL_PROTECTION_GRACE_PERIOD;
999 1000
       if (ELAPSED(ms, grace_period)) grace_period = 0UL;
@@ -2166,6 +2167,15 @@ void Temperature::set_current_temp_raw() {
2166 2167
 #endif
2167 2168
 
2168 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 2179
   // Update the raw values if they've been read. Else we could be updating them during reading.
2170 2180
   if (!temp_meas_ready) set_current_temp_raw();
2171 2181
 
@@ -2207,6 +2217,9 @@ void Temperature::readings_ready() {
2207 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 2223
   for (uint8_t e = 0; e < COUNT(temp_dir); e++) {
2211 2224
     const int16_t tdir = temp_dir[e], rawtemp = temp_hotend[e].raw * tdir;
2212 2225
     const bool heater_on = (temp_hotend[e].target > 0)

Loading…
Cancel
Save