Browse Source

Fix Max Temperature not enforced (#21592)

ellensp 4 years ago
parent
commit
5fb3ee6101
2 changed files with 22 additions and 20 deletions
  1. 3
    3
      Marlin/src/module/temperature.cpp
  2. 19
    17
      Marlin/src/module/thermistor/thermistors.h

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

2196
   #if HAS_HOTEND
2196
   #if HAS_HOTEND
2197
 
2197
 
2198
     #define _TEMP_MIN_E(NR) do{ \
2198
     #define _TEMP_MIN_E(NR) do{ \
2199
-      const celsius_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \
2199
+      const celsius_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \
2200
       temp_range[NR].mintemp = tmin; \
2200
       temp_range[NR].mintemp = tmin; \
2201
       while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \
2201
       while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \
2202
         temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \
2202
         temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \
2203
     }while(0)
2203
     }while(0)
2204
     #define _TEMP_MAX_E(NR) do{ \
2204
     #define _TEMP_MAX_E(NR) do{ \
2205
-      const celsius_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \
2205
+      const celsius_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, (int)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \
2206
       temp_range[NR].maxtemp = tmax; \
2206
       temp_range[NR].maxtemp = tmax; \
2207
       while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \
2207
       while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \
2208
         temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \
2208
         temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \
2209
     }while(0)
2209
     }while(0)
2210
 
2210
 
2211
-    #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_ ##N## THERMISTOR_ID && TEMP_SENSOR_ ##N## THERMISTOR_ID != 998 && TEMP_SENSOR_ ##N## THERMISTOR_ID != 999 && defined(HEATER_##N##_##M##TEMP))
2211
+    #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_ ##N## _THERMISTOR_ID && TEMP_SENSOR_ ##N## _THERMISTOR_ID != 998 && TEMP_SENSOR_ ##N## _THERMISTOR_ID != 999 && defined(HEATER_##N##_##M##TEMP))
2212
 
2212
 
2213
     #if _MINMAX_TEST(0, MIN)
2213
     #if _MINMAX_TEST(0, MIN)
2214
       _TEMP_MIN_E(0);
2214
       _TEMP_MIN_E(0);

+ 19
- 17
Marlin/src/module/thermistor/thermistors.h View File

335
 // For thermistors the highest temperature results in the lowest ADC value
335
 // For thermistors the highest temperature results in the lowest ADC value
336
 // For thermocouples the highest temperature results in the highest ADC value
336
 // For thermocouples the highest temperature results in the highest ADC value
337
 
337
 
338
-#define _TT_REV(N)    REVERSE_TEMP_SENSOR_RANGE_##N
338
+#define __TT_REV(N)   REVERSE_TEMP_SENSOR_RANGE_##N
339
+#define _TT_REV(N)    __TT_REV(N)
339
 #define TT_REV(N)     _TT_REV(TEMP_SENSOR_##N##_THERMISTOR_ID)
340
 #define TT_REV(N)     _TT_REV(TEMP_SENSOR_##N##_THERMISTOR_ID)
340
 #define _TT_REVRAW(N) !TEMP_SENSOR_##N##_IS_THERMISTOR
341
 #define _TT_REVRAW(N) !TEMP_SENSOR_##N##_IS_THERMISTOR
341
 #define TT_REVRAW(N)  (TT_REV(N) || _TT_REVRAW(N))
342
 #define TT_REVRAW(N)  (TT_REV(N) || _TT_REVRAW(N))
343
 #ifdef TEMPTABLE_0
344
 #ifdef TEMPTABLE_0
344
   #if TT_REV(0)
345
   #if TT_REV(0)
345
     #define TEMP_SENSOR_0_MINTEMP_IND 0
346
     #define TEMP_SENSOR_0_MINTEMP_IND 0
346
-    #define TEMPTABLE_0_MAXTEMP_IND HEATER_0_LEN - 1
347
+    #define TEMP_SENSOR_0_MAXTEMP_IND TEMPTABLE_0_LEN - 1
347
   #else
348
   #else
348
-    #define TEMPTABLE_0_MINTEMP_IND HEATER_0_LEN - 1
349
+    #define TEMP_SENSOR_0_MINTEMP_IND TEMPTABLE_0_LEN - 1
349
     #define TEMP_SENSOR_0_MAXTEMP_IND 0
350
     #define TEMP_SENSOR_0_MAXTEMP_IND 0
350
   #endif
351
   #endif
351
 #endif
352
 #endif
352
 #ifdef TEMPTABLE_1
353
 #ifdef TEMPTABLE_1
353
   #if TT_REV(1)
354
   #if TT_REV(1)
354
     #define TEMP_SENSOR_1_MINTEMP_IND 0
355
     #define TEMP_SENSOR_1_MINTEMP_IND 0
355
-    #define TEMPTABLE_1_MAXTEMP_IND HEATER_1_LEN - 1
356
+    #define TEMP_SENSOR_1_MAXTEMP_IND TEMPTABLE_1_LEN - 1
356
   #else
357
   #else
357
-    #define TEMPTABLE_1_MINTEMP_IND HEATER_1_LEN - 1
358
+    #define TEMP_SENSOR_1_MINTEMP_IND TEMPTABLE_1_LEN - 1
358
     #define TEMP_SENSOR_1_MAXTEMP_IND 0
359
     #define TEMP_SENSOR_1_MAXTEMP_IND 0
359
   #endif
360
   #endif
360
 #endif
361
 #endif
361
 #ifdef TEMPTABLE_2
362
 #ifdef TEMPTABLE_2
362
   #if TT_REV(2)
363
   #if TT_REV(2)
363
     #define TEMP_SENSOR_2_MINTEMP_IND 0
364
     #define TEMP_SENSOR_2_MINTEMP_IND 0
364
-    #define TEMPTABLE_2_MAXTEMP_IND HEATER_2_LEN - 1
365
+    #define TEMP_SENSOR_2_MAXTEMP_IND TEMPTABLE_2_LEN - 1
365
   #else
366
   #else
366
-    #define TEMPTABLE_2_MINTEMP_IND HEATER_2_LEN - 1
367
+    #define TEMP_SENSOR_2_MINTEMP_IND TEMPTABLE_2_LEN - 1
367
     #define TEMP_SENSOR_2_MAXTEMP_IND 0
368
     #define TEMP_SENSOR_2_MAXTEMP_IND 0
368
   #endif
369
   #endif
369
 #endif
370
 #endif
370
 #ifdef TEMPTABLE_3
371
 #ifdef TEMPTABLE_3
371
   #if TT_REV(3)
372
   #if TT_REV(3)
372
     #define TEMP_SENSOR_3_MINTEMP_IND 0
373
     #define TEMP_SENSOR_3_MINTEMP_IND 0
373
-    #define TEMPTABLE_3_MAXTEMP_IND HEATER_3_LEN - 1
374
+    #define TEMP_SENSOR_3_MAXTEMP_IND TEMPTABLE_3_LEN - 1
374
   #else
375
   #else
375
-    #define TEMPTABLE_3_MINTEMP_IND HEATER_3_LEN - 1
376
+    #define TEMP_SENSOR_3_MINTEMP_IND TEMPTABLE_3_LEN - 1
376
     #define TEMP_SENSOR_3_MAXTEMP_IND 0
377
     #define TEMP_SENSOR_3_MAXTEMP_IND 0
377
   #endif
378
   #endif
378
 #endif
379
 #endif
379
 #ifdef TEMPTABLE_4
380
 #ifdef TEMPTABLE_4
380
   #if TT_REV(4)
381
   #if TT_REV(4)
381
     #define TEMP_SENSOR_4_MINTEMP_IND 0
382
     #define TEMP_SENSOR_4_MINTEMP_IND 0
382
-    #define TEMPTABLE_4_MAXTEMP_IND HEATER_4_LEN - 1
383
+    #define TEMP_SENSOR_4_MAXTEMP_IND TEMPTABLE_4_LEN - 1
383
   #else
384
   #else
384
-    #define TEMPTABLE_4_MINTEMP_IND HEATER_4_LEN - 1
385
+    #define TEMP_SENSOR_4_MINTEMP_IND TEMPTABLE_4_LEN - 1
385
     #define TEMP_SENSOR_4_MAXTEMP_IND 0
386
     #define TEMP_SENSOR_4_MAXTEMP_IND 0
386
   #endif
387
   #endif
387
 #endif
388
 #endif
388
 #ifdef TEMPTABLE_5
389
 #ifdef TEMPTABLE_5
389
   #if TT_REV(5)
390
   #if TT_REV(5)
390
     #define TEMP_SENSOR_5_MINTEMP_IND 0
391
     #define TEMP_SENSOR_5_MINTEMP_IND 0
391
-    #define TEMPTABLE_5_MAXTEMP_IND HEATER_5_LEN - 1
392
+    #define TEMP_SENSOR_5_MAXTEMP_IND TEMPTABLE_5_LEN - 1
392
   #else
393
   #else
393
-    #define TEMPTABLE_5_MINTEMP_IND HEATER_5_LEN - 1
394
+    #define TEMP_SENSOR_5_MINTEMP_IND TEMPTABLE_5_LEN - 1
394
     #define TEMP_SENSOR_5_MAXTEMP_IND 0
395
     #define TEMP_SENSOR_5_MAXTEMP_IND 0
395
   #endif
396
   #endif
396
 #endif
397
 #endif
397
 #ifdef TEMPTABLE_6
398
 #ifdef TEMPTABLE_6
398
   #if TT_REV(6)
399
   #if TT_REV(6)
399
     #define TEMP_SENSOR_6_MINTEMP_IND 0
400
     #define TEMP_SENSOR_6_MINTEMP_IND 0
400
-    #define TEMPTABLE_6_MAXTEMP_IND HEATER_6_LEN - 1
401
+    #define TEMP_SENSOR_6_MAXTEMP_IND TEMPTABLE_6_LEN - 1
401
   #else
402
   #else
402
-    #define TEMPTABLE_6_MINTEMP_IND HEATER_6_LEN - 1
403
+    #define TEMP_SENSOR_6_MINTEMP_IND TEMPTABLE_6_LEN - 1
403
     #define TEMP_SENSOR_6_MAXTEMP_IND 0
404
     #define TEMP_SENSOR_6_MAXTEMP_IND 0
404
   #endif
405
   #endif
405
 #endif
406
 #endif
406
 #ifdef TEMPTABLE_7
407
 #ifdef TEMPTABLE_7
407
   #if TT_REV(7)
408
   #if TT_REV(7)
408
     #define TEMP_SENSOR_7_MINTEMP_IND 0
409
     #define TEMP_SENSOR_7_MINTEMP_IND 0
409
-    #define TEMPTABLE_7_MAXTEMP_IND HEATER_7_LEN - 1
410
+    #define TEMP_SENSOR_7_MAXTEMP_IND TEMPTABLE_7_LEN - 1
410
   #else
411
   #else
411
-    #define TEMPTABLE_7_MINTEMP_IND HEATER_7_LEN - 1
412
+    #define TEMP_SENSOR_7_MINTEMP_IND TEMPTABLE_7_LEN - 1
412
     #define TEMP_SENSOR_7_MAXTEMP_IND 0
413
     #define TEMP_SENSOR_7_MAXTEMP_IND 0
413
   #endif
414
   #endif
414
 #endif
415
 #endif
522
   #endif
523
   #endif
523
 #endif
524
 #endif
524
 
525
 
526
+#undef __TT_REV
525
 #undef _TT_REV
527
 #undef _TT_REV
526
 #undef TT_REV
528
 #undef TT_REV
527
 #undef _TT_REVRAW
529
 #undef _TT_REVRAW

Loading…
Cancel
Save