Skip to content

Commit

Permalink
🐛 Fix min/max temp evaluation
Browse files Browse the repository at this point in the history
Fixes #24257
  • Loading branch information
thinkyhead committed Jun 4, 2022
1 parent 3522d53 commit 9c872b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2709,13 +2709,15 @@ void Temperature::init() {

#if HAS_HOTEND
#define _TEMP_MIN_E(NR) do{ \
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))); \
const celsius_t tmin_tmp = TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, int16_t(pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))), \
tmin = _MAX(HEATER_##NR##_MINTEMP, tmin_tmp); \
temp_range[NR].mintemp = tmin; \
while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \
temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \
}while(0)
#define _TEMP_MAX_E(NR) do{ \
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)); \
const celsius_t tmax_tmp = TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, int16_t(pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius)) - 1), \
tmax = _MIN(HEATER_##NR##_MAXTEMP, tmax_tmp); \
temp_range[NR].maxtemp = tmax; \
while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \
temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \
Expand Down

0 comments on commit 9c872b2

Please sign in to comment.