0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-01-19 16:16:13 +00:00

🔧 Sanity-check hotend max / preheat temps (#25407)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
ellensp 2023-02-21 15:25:22 +13:00 committed by GitHub
parent e002f4fd38
commit 03a4378670
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 27 deletions

View file

@ -714,6 +714,7 @@
#define __RREPEAT2() _RREPEAT2 #define __RREPEAT2() _RREPEAT2
#define RREPEAT_S(S,N,OP) EVAL1024(_RREPEAT(S,SUB##S(N),OP)) #define RREPEAT_S(S,N,OP) EVAL1024(_RREPEAT(S,SUB##S(N),OP))
#define RREPEAT(N,OP) RREPEAT_S(0,N,OP) #define RREPEAT(N,OP) RREPEAT_S(0,N,OP)
#define RREPEAT_1(N,OP) RREPEAT_S(1,INCREMENT(N),OP)
#define RREPEAT2_S(S,N,OP,V...) EVAL1024(_RREPEAT2(S,SUB##S(N),OP,V)) #define RREPEAT2_S(S,N,OP,V...) EVAL1024(_RREPEAT2(S,SUB##S(N),OP,V))
#define RREPEAT2(N,OP,V...) RREPEAT2_S(0,N,OP,V) #define RREPEAT2(N,OP,V...) RREPEAT2_S(0,N,OP,V)

View file

@ -223,13 +223,12 @@
#define TEMP_SENSOR_0_IS_AD8495 1 #define TEMP_SENSOR_0_IS_AD8495 1
#elif TEMP_SENSOR_0 == -1 #elif TEMP_SENSOR_0 == -1
#define TEMP_SENSOR_0_IS_AD595 1 #define TEMP_SENSOR_0_IS_AD595 1
#elif TEMP_SENSOR_0 > 0 #elif TEMP_SENSOR_0 == 1000
#define TEMP_SENSOR_0_IS_THERMISTOR 1
#if TEMP_SENSOR_0 == 1000
#define TEMP_SENSOR_0_IS_CUSTOM 1 #define TEMP_SENSOR_0_IS_CUSTOM 1
#elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999 #elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999
#define TEMP_SENSOR_0_IS_DUMMY 1 #define TEMP_SENSOR_0_IS_DUMMY 1
#endif #elif TEMP_SENSOR_0 > 0
#define TEMP_SENSOR_0_IS_THERMISTOR 1
#else #else
#undef HEATER_0_MINTEMP #undef HEATER_0_MINTEMP
#undef HEATER_0_MAXTEMP #undef HEATER_0_MAXTEMP
@ -269,13 +268,12 @@
#define TEMP_SENSOR_1_IS_AD8495 1 #define TEMP_SENSOR_1_IS_AD8495 1
#elif TEMP_SENSOR_1 == -1 #elif TEMP_SENSOR_1 == -1
#define TEMP_SENSOR_1_IS_AD595 1 #define TEMP_SENSOR_1_IS_AD595 1
#elif TEMP_SENSOR_1 > 0 #elif TEMP_SENSOR_1 == 1000
#define TEMP_SENSOR_1_IS_THERMISTOR 1
#if TEMP_SENSOR_1 == 1000
#define TEMP_SENSOR_1_IS_CUSTOM 1 #define TEMP_SENSOR_1_IS_CUSTOM 1
#elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999 #elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999
#define TEMP_SENSOR_1_IS_DUMMY 1 #define TEMP_SENSOR_1_IS_DUMMY 1
#endif #elif TEMP_SENSOR_1 > 0
#define TEMP_SENSOR_1_IS_THERMISTOR 1
#else #else
#undef HEATER_1_MINTEMP #undef HEATER_1_MINTEMP
#undef HEATER_1_MAXTEMP #undef HEATER_1_MAXTEMP
@ -315,18 +313,72 @@
#define TEMP_SENSOR_2_IS_AD8495 1 #define TEMP_SENSOR_2_IS_AD8495 1
#elif TEMP_SENSOR_2 == -1 #elif TEMP_SENSOR_2 == -1
#define TEMP_SENSOR_2_IS_AD595 1 #define TEMP_SENSOR_2_IS_AD595 1
#elif TEMP_SENSOR_2 > 0 #elif TEMP_SENSOR_2 == 1000
#define TEMP_SENSOR_2_IS_THERMISTOR 1
#if TEMP_SENSOR_2 == 1000
#define TEMP_SENSOR_2_IS_CUSTOM 1 #define TEMP_SENSOR_2_IS_CUSTOM 1
#elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999 #elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999
#define TEMP_SENSOR_2_IS_DUMMY 1 #define TEMP_SENSOR_2_IS_DUMMY 1
#endif #elif TEMP_SENSOR_2 > 0
#define TEMP_SENSOR_2_IS_THERMISTOR 1
#else #else
#undef HEATER_2_MINTEMP #undef HEATER_2_MINTEMP
#undef HEATER_2_MAXTEMP #undef HEATER_2_MAXTEMP
#endif #endif
#if TEMP_SENSOR_3 == 1000
#define TEMP_SENSOR_3_IS_CUSTOM 1
#elif TEMP_SENSOR_3 == 998 || TEMP_SENSOR_3 == 999
#define TEMP_SENSOR_3_IS_DUMMY 1
#elif TEMP_SENSOR_3 > 0
#define TEMP_SENSOR_3_IS_THERMISTOR 1
#elif !TEMP_SENSOR_3
#undef HEATER_3_MINTEMP
#undef HEATER_3_MAXTEMP
#endif
#if TEMP_SENSOR_4 == 1000
#define TEMP_SENSOR_4_IS_CUSTOM 1
#elif TEMP_SENSOR_4 == 998 || TEMP_SENSOR_4 == 999
#define TEMP_SENSOR_4_IS_DUMMY 1
#elif TEMP_SENSOR_4 > 0
#define TEMP_SENSOR_4_IS_THERMISTOR 1
#elif !TEMP_SENSOR_4
#undef HEATER_4_MINTEMP
#undef HEATER_4_MAXTEMP
#endif
#if TEMP_SENSOR_5 == 1000
#define TEMP_SENSOR_5_IS_CUSTOM 1
#elif TEMP_SENSOR_5 == 998 || TEMP_SENSOR_5 == 999
#define TEMP_SENSOR_5_IS_DUMMY 1
#elif TEMP_SENSOR_5 > 0
#define TEMP_SENSOR_5_IS_THERMISTOR 1
#elif !TEMP_SENSOR_5
#undef HEATER_5_MINTEMP
#undef HEATER_5_MAXTEMP
#endif
#if TEMP_SENSOR_6 == 1000
#define TEMP_SENSOR_6_IS_CUSTOM 1
#elif TEMP_SENSOR_6 == 998 || TEMP_SENSOR_6 == 999
#define TEMP_SENSOR_6_IS_DUMMY 1
#elif TEMP_SENSOR_6 > 0
#define TEMP_SENSOR_6_IS_THERMISTOR 1
#elif !TEMP_SENSOR_6
#undef HEATER_6_MINTEMP
#undef HEATER_6_MAXTEMP
#endif
#if TEMP_SENSOR_7 == 1000
#define TEMP_SENSOR_7_IS_CUSTOM 1
#elif TEMP_SENSOR_7 == 998 || TEMP_SENSOR_7 == 999
#define TEMP_SENSOR_7_IS_DUMMY 1
#elif TEMP_SENSOR_7 > 0
#define TEMP_SENSOR_7_IS_THERMISTOR 1
#elif !TEMP_SENSOR_7
#undef HEATER_7_MINTEMP
#undef HEATER_7_MAXTEMP
#endif
#if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT)
#if TEMP_SENSOR_REDUNDANT == -5 #if TEMP_SENSOR_REDUNDANT == -5
#if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2) #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2)

View file

@ -149,7 +149,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
const preheat_t &pre = material_preset[m]; const preheat_t &pre = material_preset[m];
TERN_(HAS_HOTEND, if (TEST(pmask, PT_HOTEND)) thermalManager.setTargetHotend(pre.hotend_temp, e)); TERN_(HAS_HOTEND, if (TEST(pmask, PT_HOTEND)) thermalManager.setTargetHotend(pre.hotend_temp, e));
TERN_(HAS_HEATED_BED, if (TEST(pmask, PT_BED)) thermalManager.setTargetBed(pre.bed_temp)); TERN_(HAS_HEATED_BED, if (TEST(pmask, PT_BED)) thermalManager.setTargetBed(pre.bed_temp));
//TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PT_CHAMBER)) thermalManager.setTargetBed(pre.chamber_temp)); //TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PT_CHAMBER)) thermalManager.setTargetChamber(pre.chamber_temp));
TERN_(HAS_FAN, if (TEST(pmask, PT_FAN)) thermalManager.set_fan_speed(0, pre.fan_speed)); TERN_(HAS_FAN, if (TEST(pmask, PT_FAN)) thermalManager.set_fan_speed(0, pre.fan_speed));
} }
#endif #endif

View file

@ -317,8 +317,22 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
#if HAS_HOTEND #if HAS_HOTEND
hotend_info_t Temperature::temp_hotend[HOTENDS]; hotend_info_t Temperature::temp_hotend[HOTENDS];
#define _HMT(N) HEATER_##N##_MAXTEMP,
const celsius_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); const celsius_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
// Sanity-check max readable temperatures
#define CHECK_MAXTEMP_(N,M,S) static_assert( \
S >= 998 || M <= _MAX(TT_NAME(S)[0].celsius, TT_NAME(S)[COUNT(TT_NAME(S)) - 1].celsius) - HOTEND_OVERSHOOT, \
"HEATER_" STRINGIFY(N) "_MAXTEMP (" STRINGIFY(M) ") is too high for thermistor_" STRINGIFY(S) ".h with HOTEND_OVERSHOOT=" STRINGIFY(HOTEND_OVERSHOOT) ".");
#define CHECK_MAXTEMP(N) TERN(TEMP_SENSOR_##N##_IS_THERMISTOR, CHECK_MAXTEMP_, CODE_0)(N, HEATER_##N##_MAXTEMP, TEMP_SENSOR_##N)
REPEAT(HOTENDS, CHECK_MAXTEMP)
#if HAS_PREHEAT
#define CHECK_PREHEAT__(N,P,T,M) static_assert(T <= M - HOTEND_OVERSHOOT, "PREHEAT_" STRINGIFY(P) "_TEMP_HOTEND (" STRINGIFY(T) ") must be less than HEATER_" STRINGIFY(N) "_MAXTEMP (" STRINGIFY(M) ") - " STRINGIFY(HOTEND_OVERSHOOT) ".");
#define CHECK_PREHEAT_(N,P) CHECK_PREHEAT__(N, P, PREHEAT_##P##_TEMP_HOTEND, HEATER_##N##_MAXTEMP);
#define CHECK_PREHEAT(P) REPEAT2(HOTENDS, CHECK_PREHEAT_, P);
RREPEAT_1(PREHEAT_COUNT, CHECK_PREHEAT)
#endif
#endif #endif
#if HAS_TEMP_REDUNDANT #if HAS_TEMP_REDUNDANT