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,19 +2196,19 @@ void Temperature::init() {
2196 2196
   #if HAS_HOTEND
2197 2197
 
2198 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 2200
       temp_range[NR].mintemp = tmin; \
2201 2201
       while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \
2202 2202
         temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \
2203 2203
     }while(0)
2204 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 2206
       temp_range[NR].maxtemp = tmax; \
2207 2207
       while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \
2208 2208
         temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \
2209 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 2213
     #if _MINMAX_TEST(0, MIN)
2214 2214
       _TEMP_MIN_E(0);

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

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

Loading…
Cancel
Save