Browse Source

Fix mintemp/maxtemp monitoring for thermocouples

Scott Lahteine 6 years ago
parent
commit
c28e08c849
1 changed files with 24 additions and 17 deletions
  1. 24
    17
      Marlin/src/module/temperature.cpp

+ 24
- 17
Marlin/src/module/temperature.cpp View File

2194
     temp_chamber.acc = 0;
2194
     temp_chamber.acc = 0;
2195
   #endif
2195
   #endif
2196
 
2196
 
2197
-  int constexpr temp_dir[] = {
2197
+  static constexpr int8_t temp_dir[] = {
2198
     #if ENABLED(HEATER_0_USES_MAX6675)
2198
     #if ENABLED(HEATER_0_USES_MAX6675)
2199
-       0
2199
+      0
2200
     #else
2200
     #else
2201
       TEMPDIR(0)
2201
       TEMPDIR(0)
2202
     #endif
2202
     #endif
2203
     #if HOTENDS > 1
2203
     #if HOTENDS > 1
2204
-      , TEMPDIR(1)
2204
+      #if ENABLED(HEATER_1_USES_MAX6675)
2205
+        , 0
2206
+      #else
2207
+        , TEMPDIR(1)
2208
+      #endif
2205
       #if HOTENDS > 2
2209
       #if HOTENDS > 2
2206
         , TEMPDIR(2)
2210
         , TEMPDIR(2)
2207
         #if HOTENDS > 3
2211
         #if HOTENDS > 3
2221
   if (grace_period) return;
2225
   if (grace_period) return;
2222
 
2226
 
2223
   for (uint8_t e = 0; e < COUNT(temp_dir); e++) {
2227
   for (uint8_t e = 0; e < COUNT(temp_dir); e++) {
2224
-    const int16_t tdir = temp_dir[e], rawtemp = temp_hotend[e].raw * tdir;
2225
-    const bool heater_on = (temp_hotend[e].target > 0)
2226
-      #if ENABLED(PIDTEMP)
2227
-        || (temp_hotend[e].soft_pwm_amount > 0)
2228
-      #endif
2229
-    ;
2230
-    if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error(e);
2231
-    if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) {
2228
+    const int8_t tdir = temp_dir[e];
2229
+    if (tdir) {
2230
+      const int16_t rawtemp = temp_hotend[e].raw * tdir; // normal direction, +rawtemp, else -rawtemp
2231
+      const bool heater_on = (temp_hotend[e].target > 0
2232
+        #if ENABLED(PIDTEMP)
2233
+          || temp_hotend[e].soft_pwm_amount > 0
2234
+        #endif
2235
+      );
2236
+      if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error(e);
2237
+      if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) {
2238
+        #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
2239
+          if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
2240
+        #endif
2241
+          min_temp_error(e);
2242
+      }
2232
       #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
2243
       #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
2233
-        if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
2244
+        else
2245
+          consecutive_low_temperature_error[e] = 0;
2234
       #endif
2246
       #endif
2235
-          min_temp_error(e);
2236
     }
2247
     }
2237
-    #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
2238
-      else
2239
-        consecutive_low_temperature_error[e] = 0;
2240
-    #endif
2241
   }
2248
   }
2242
 
2249
 
2243
   #if HAS_HEATED_BED
2250
   #if HAS_HEATED_BED

Loading…
Cancel
Save