Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Fix preheat tests (nested macro limit ~256)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 7, 2023
1 parent 7afd823 commit 1748abd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
4 changes: 3 additions & 1 deletion Marlin/src/core/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,9 @@
#define DEFER4(M) M EMPTY EMPTY EMPTY EMPTY()()()()

// Force define expansion
#define EVAL(V...) EVAL16(V)
#define EVAL EVAL16
#define EVAL4096(V...) EVAL2048(EVAL2048(V))
#define EVAL2048(V...) EVAL1024(EVAL1024(V))
#define EVAL1024(V...) EVAL512(EVAL512(V))
#define EVAL512(V...) EVAL256(EVAL256(V))
#define EVAL256(V...) EVAL128(EVAL128(V))
Expand Down
41 changes: 35 additions & 6 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);

#if HAS_HOTEND
hotend_info_t Temperature::temp_hotend[HOTENDS];
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);
constexpr celsius_t Temperature::hotend_maxtemp[HOTENDS];

// Sanity-check max readable temperatures
#define CHECK_MAXTEMP_(N,M,S) static_assert( \
Expand All @@ -328,12 +328,41 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);

#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
#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)
#if PREHEAT_COUNT >= 1
CHECK_PREHEAT(1)
#endif
#if PREHEAT_COUNT >= 2
CHECK_PREHEAT(2)
#endif
#if PREHEAT_COUNT >= 3
CHECK_PREHEAT(3)
#endif
#if PREHEAT_COUNT >= 4
CHECK_PREHEAT(4)
#endif
#if PREHEAT_COUNT >= 5
CHECK_PREHEAT(5)
#endif
#if PREHEAT_COUNT >= 6
CHECK_PREHEAT(6)
#endif
#if PREHEAT_COUNT >= 7
CHECK_PREHEAT(7)
#endif
#if PREHEAT_COUNT >= 8
CHECK_PREHEAT(8)
#endif
#if PREHEAT_COUNT >= 9
CHECK_PREHEAT(9)
#endif
#if PREHEAT_COUNT >= 10
CHECK_PREHEAT(10)
#endif
#endif // HAS_PREHEAT

#endif
#endif // HAS_HOTEND

#if HAS_TEMP_REDUNDANT
redundant_info_t Temperature::temp_redundant;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ class Temperature {

#if HAS_HOTEND
static hotend_info_t temp_hotend[HOTENDS];
static const celsius_t hotend_maxtemp[HOTENDS];
static constexpr celsius_t 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);
static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); }
#endif

Expand Down

0 comments on commit 1748abd

Please sign in to comment.