Apply TERN to compact code (#17619)
This commit is contained in:
@ -236,15 +236,9 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
|
||||
#ifdef BED_MAXTEMP
|
||||
int16_t Temperature::maxtemp_raw_BED = HEATER_BED_RAW_HI_TEMP;
|
||||
#endif
|
||||
#if WATCH_BED
|
||||
bed_watch_t Temperature::watch_bed; // = { 0 }
|
||||
#endif
|
||||
#if DISABLED(PIDTEMPBED)
|
||||
millis_t Temperature::next_bed_check_ms;
|
||||
#endif
|
||||
#if HEATER_IDLE_HANDLER
|
||||
hotend_idle_t Temperature::bed_idle; // = { 0 }
|
||||
#endif
|
||||
TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 }
|
||||
TERN(PIDTEMPBED,, millis_t Temperature::next_bed_check_ms);
|
||||
TERN_(HEATER_IDLE_HANDLER, hotend_idle_t Temperature::bed_idle); // = { 0 }
|
||||
#endif // HAS_HEATED_BED
|
||||
|
||||
#if HAS_TEMP_CHAMBER
|
||||
@ -403,15 +397,11 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
bool heated = false;
|
||||
#endif
|
||||
|
||||
#if HAS_AUTO_FAN
|
||||
next_auto_fan_check_ms = next_temp_ms + 2500UL;
|
||||
#endif
|
||||
TERN_(HAS_AUTO_FAN, next_auto_fan_check_ms = next_temp_ms + 2500UL);
|
||||
|
||||
if (target > GHV(BED_MAXTEMP - 10, temp_range[heater].maxtemp - 15)) {
|
||||
SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH);
|
||||
#endif
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -427,9 +417,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
LEDColor color = ONHEATINGSTART();
|
||||
#endif
|
||||
|
||||
#if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING)
|
||||
adaptive_fan_slowing = false;
|
||||
#endif
|
||||
TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = false);
|
||||
|
||||
// PID Tuning loop
|
||||
while (wait_for_heatup) {
|
||||
@ -525,9 +513,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
#endif
|
||||
if (current_temp > target + MAX_OVERSHOOT_PID_AUTOTUNE) {
|
||||
SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH);
|
||||
#endif
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -562,9 +548,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
#define MAX_CYCLE_TIME_PID_AUTOTUNE 20L
|
||||
#endif
|
||||
if (((ms - t1) + (ms - t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) {
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT);
|
||||
#endif
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT));
|
||||
SERIAL_ECHOLNPGM(STR_PID_TIMEOUT);
|
||||
break;
|
||||
}
|
||||
@ -610,12 +594,9 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
printerEventLEDs.onPidTuningDone(color);
|
||||
#endif
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onPidTuning(ExtUI::result_t::PID_DONE);
|
||||
#endif
|
||||
TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color));
|
||||
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE));
|
||||
|
||||
goto EXIT_M303;
|
||||
}
|
||||
@ -624,17 +605,12 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
|
||||
disable_all_heaters();
|
||||
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
printerEventLEDs.onPidTuningDone(color);
|
||||
#endif
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onPidTuning(ExtUI::result_t::PID_DONE);
|
||||
#endif
|
||||
TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color));
|
||||
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE));
|
||||
|
||||
EXIT_M303:
|
||||
#if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING)
|
||||
adaptive_fan_slowing = true;
|
||||
#endif
|
||||
TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -653,11 +629,7 @@ int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) {
|
||||
case H_CHAMBER: return temp_chamber.soft_pwm_amount;
|
||||
#endif
|
||||
default:
|
||||
return (0
|
||||
#if HAS_HOTEND
|
||||
+ temp_hotend[heater_id].soft_pwm_amount
|
||||
#endif
|
||||
);
|
||||
return TERN0(HAS_HOTEND, temp_hotend[heater_id].soft_pwm_amount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -771,19 +743,16 @@ void Temperature::_temp_error(const heater_ind_t heater, PGM_P const serial_msg,
|
||||
|
||||
static uint8_t killed = 0;
|
||||
|
||||
if (IsRunning()
|
||||
#if BOGUS_TEMPERATURE_GRACE_PERIOD
|
||||
&& killed == 2
|
||||
#endif
|
||||
) {
|
||||
if (IsRunning() && TERN1(BOGUS_TEMPERATURE_GRACE_PERIOD, killed == 2)) {
|
||||
SERIAL_ERROR_START();
|
||||
serialprintPGM(serial_msg);
|
||||
SERIAL_ECHOPGM(STR_STOPPED_HEATER);
|
||||
if (heater >= 0) SERIAL_ECHO((int)heater);
|
||||
#if HAS_HEATED_CHAMBER
|
||||
else if (heater == H_CHAMBER) SERIAL_ECHOPGM(STR_HEATER_CHAMBER);
|
||||
#endif
|
||||
else SERIAL_ECHOPGM(STR_HEATER_BED);
|
||||
if (heater >= 0)
|
||||
SERIAL_ECHO((int)heater);
|
||||
else if (TERN0(HAS_HEATED_CHAMBER, heater == H_CHAMBER))
|
||||
SERIAL_ECHOPGM(STR_HEATER_CHAMBER);
|
||||
else
|
||||
SERIAL_ECHOPGM(STR_HEATER_BED);
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
@ -839,9 +808,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) {
|
||||
|
||||
if (temp_hotend[ee].target == 0
|
||||
|| pid_error < -(PID_FUNCTIONAL_RANGE)
|
||||
#if HEATER_IDLE_HANDLER
|
||||
|| hotend_idle[ee].timed_out
|
||||
#endif
|
||||
|| TERN0(HEATER_IDLE_HANDLER, hotend_idle[ee].timed_out)
|
||||
) {
|
||||
pid_output = 0;
|
||||
pid_reset[ee] = true;
|
||||
@ -1015,9 +982,8 @@ void Temperature::manage_heater() {
|
||||
if (!inited) return watchdog_refresh();
|
||||
#endif
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
if (emergency_parser.killed_by_M112) kill(M112_KILL_STR, nullptr, true);
|
||||
#endif
|
||||
if (TERN0(EMERGENCY_PARSER, emergency_parser.killed_by_M112))
|
||||
kill(M112_KILL_STR, nullptr, true);
|
||||
|
||||
if (!raw_temps_ready) return;
|
||||
|
||||
@ -1043,9 +1009,7 @@ void Temperature::manage_heater() {
|
||||
_temp_error((heater_ind_t)e, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY));
|
||||
#endif
|
||||
|
||||
#if HEATER_IDLE_HANDLER
|
||||
hotend_idle[e].update(ms);
|
||||
#endif
|
||||
TERN_(HEATER_IDLE_HANDLER, hotend_idle[e].update(ms));
|
||||
|
||||
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
||||
// Check for thermal runaway
|
||||
@ -1106,7 +1070,10 @@ void Temperature::manage_heater() {
|
||||
}
|
||||
#endif // WATCH_BED
|
||||
|
||||
#define PAUSE_CHANGE_REQD BOTH(PROBING_HEATERS_OFF, BED_LIMIT_SWITCHING)
|
||||
#if BOTH(PROBING_HEATERS_OFF, BED_LIMIT_SWITCHING)
|
||||
#define PAUSE_CHANGE_REQD 1
|
||||
#endif
|
||||
|
||||
#if PAUSE_CHANGE_REQD
|
||||
static bool last_pause_state;
|
||||
#endif
|
||||
@ -1115,23 +1082,15 @@ void Temperature::manage_heater() {
|
||||
|
||||
#if DISABLED(PIDTEMPBED)
|
||||
if (PENDING(ms, next_bed_check_ms)
|
||||
#if PAUSE_CHANGE_REQD
|
||||
&& paused == last_pause_state
|
||||
#endif
|
||||
&& TERN1(PAUSE_CHANGE_REQD, paused == last_pause_state)
|
||||
) break;
|
||||
next_bed_check_ms = ms + BED_CHECK_INTERVAL;
|
||||
#if PAUSE_CHANGE_REQD
|
||||
last_pause_state = paused;
|
||||
#endif
|
||||
TERN_(PAUSE_CHANGE_REQD, last_pause_state = paused);
|
||||
#endif
|
||||
|
||||
#if HEATER_IDLE_HANDLER
|
||||
bed_idle.update(ms);
|
||||
#endif
|
||||
TERN_(HEATER_IDLE_HANDLER, bed_idle.update(ms));
|
||||
|
||||
#if HAS_THERMALLY_PROTECTED_BED
|
||||
thermal_runaway_protection(tr_state_machine_bed, temp_bed.celsius, temp_bed.target, H_BED, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS);
|
||||
#endif
|
||||
TERN_(HAS_THERMALLY_PROTECTED_BED, thermal_runaway_protection(tr_state_machine_bed, temp_bed.celsius, temp_bed.target, H_BED, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS));
|
||||
|
||||
#if HEATER_IDLE_HANDLER
|
||||
if (bed_idle.timed_out) {
|
||||
@ -1207,9 +1166,7 @@ void Temperature::manage_heater() {
|
||||
WRITE_HEATER_CHAMBER(LOW);
|
||||
}
|
||||
|
||||
#if ENABLED(THERMAL_PROTECTION_CHAMBER)
|
||||
thermal_runaway_protection(tr_state_machine_chamber, temp_chamber.celsius, temp_chamber.target, H_CHAMBER, THERMAL_PROTECTION_CHAMBER_PERIOD, THERMAL_PROTECTION_CHAMBER_HYSTERESIS);
|
||||
#endif
|
||||
TERN_(THERMAL_PROTECTION_CHAMBER, thermal_runaway_protection(tr_state_machine_chamber, temp_chamber.celsius, temp_chamber.target, H_CHAMBER, THERMAL_PROTECTION_CHAMBER_PERIOD, THERMAL_PROTECTION_CHAMBER_HYSTERESIS));
|
||||
}
|
||||
|
||||
// TODO: Implement true PID pwm
|
||||
@ -1302,36 +1259,16 @@ void Temperature::manage_heater() {
|
||||
SERIAL_ECHOPAIR_F(" C", t.sh_c_coeff, 9);
|
||||
SERIAL_ECHOPGM(" ; ");
|
||||
serialprintPGM(
|
||||
#if ENABLED(HEATER_0_USER_THERMISTOR)
|
||||
t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :
|
||||
#endif
|
||||
#if ENABLED(HEATER_1_USER_THERMISTOR)
|
||||
t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :
|
||||
#endif
|
||||
#if ENABLED(HEATER_2_USER_THERMISTOR)
|
||||
t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :
|
||||
#endif
|
||||
#if ENABLED(HEATER_3_USER_THERMISTOR)
|
||||
t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :
|
||||
#endif
|
||||
#if ENABLED(HEATER_4_USER_THERMISTOR)
|
||||
t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :
|
||||
#endif
|
||||
#if ENABLED(HEATER_5_USER_THERMISTOR)
|
||||
t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :
|
||||
#endif
|
||||
#if ENABLED(HEATER_6_USER_THERMISTOR)
|
||||
t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :
|
||||
#endif
|
||||
#if ENABLED(HEATER_7_USER_THERMISTOR)
|
||||
t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :
|
||||
#endif
|
||||
#if ENABLED(HEATER_BED_USER_THERMISTOR)
|
||||
t_index == CTI_BED ? PSTR("BED") :
|
||||
#endif
|
||||
#if ENABLED(HEATER_CHAMBER_USER_THERMISTOR)
|
||||
t_index == CTI_CHAMBER ? PSTR("CHAMBER") :
|
||||
#endif
|
||||
TERN_(HEATER_0_USER_THERMISTOR, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :)
|
||||
TERN_(HEATER_1_USER_THERMISTOR, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :)
|
||||
TERN_(HEATER_2_USER_THERMISTOR, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :)
|
||||
TERN_(HEATER_3_USER_THERMISTOR, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :)
|
||||
TERN_(HEATER_4_USER_THERMISTOR, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :)
|
||||
TERN_(HEATER_5_USER_THERMISTOR, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :)
|
||||
TERN_(HEATER_6_USER_THERMISTOR, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :)
|
||||
TERN_(HEATER_7_USER_THERMISTOR, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :)
|
||||
TERN_(HEATER_BED_USER_THERMISTOR, t_index == CTI_BED ? PSTR("BED") :)
|
||||
TERN_(HEATER_CHAMBER_USER_THERMISTOR, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :)
|
||||
nullptr
|
||||
);
|
||||
SERIAL_EOL();
|
||||
@ -1387,12 +1324,7 @@ void Temperature::manage_heater() {
|
||||
// Derived from RepRap FiveD extruder::getTemperature()
|
||||
// For hot end temperature measurement.
|
||||
float Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) {
|
||||
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
||||
if (e > HOTENDS)
|
||||
#else
|
||||
if (e >= HOTENDS)
|
||||
#endif
|
||||
{
|
||||
if (e > HOTENDS - DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)) {
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ECHO((int)e);
|
||||
SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER_NUM);
|
||||
@ -1577,21 +1509,11 @@ void Temperature::updateTemperaturesFromRawValues() {
|
||||
#if HAS_HOTEND
|
||||
HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e);
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw);
|
||||
#endif
|
||||
#if HAS_TEMP_CHAMBER
|
||||
temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw);
|
||||
#endif
|
||||
#if HAS_TEMP_PROBE
|
||||
temp_probe.celsius = analog_to_celsius_probe(temp_probe.raw);
|
||||
#endif
|
||||
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
||||
redundant_temperature = analog_to_celsius_hotend(redundant_temperature_raw, 1);
|
||||
#endif
|
||||
#if ENABLED(FILAMENT_WIDTH_SENSOR)
|
||||
filwidth.update_measured_mm();
|
||||
#endif
|
||||
TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw));
|
||||
TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw));
|
||||
TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.raw));
|
||||
TERN_(TEMP_SENSOR_1_AS_REDUNDANT, redundant_temperature = analog_to_celsius_hotend(redundant_temperature_raw, 1));
|
||||
TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm());
|
||||
|
||||
// Reset the watchdog on good temperature measurement
|
||||
watchdog_refresh();
|
||||
@ -1637,9 +1559,7 @@ void Temperature::updateTemperaturesFromRawValues() {
|
||||
*/
|
||||
void Temperature::init() {
|
||||
|
||||
#if ENABLED(MAX6675_IS_MAX31865)
|
||||
max31865.begin(MAX31865_2WIRE); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
|
||||
#endif
|
||||
TERN_(MAX6675_IS_MAX31865, max31865.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
|
||||
|
||||
#if EARLY_WATCHDOG
|
||||
// Flag that the thermalManager should be running
|
||||
@ -1931,9 +1851,7 @@ void Temperature::init() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(PROBING_HEATERS_OFF)
|
||||
paused = false;
|
||||
#endif
|
||||
TERN_(PROBING_HEATERS_OFF, paused = false);
|
||||
}
|
||||
|
||||
#if WATCH_HOTENDS
|
||||
@ -2004,9 +1922,7 @@ void Temperature::init() {
|
||||
#if HEATER_IDLE_HANDLER
|
||||
// If the heater idle timeout expires, restart
|
||||
if ((heater_id >= 0 && hotend_idle[heater_id].timed_out)
|
||||
#if HAS_HEATED_BED
|
||||
|| (heater_id < 0 && bed_idle.timed_out)
|
||||
#endif
|
||||
|| TERN0(HAS_HEATED_BED, (heater_id < 0 && bed_idle.timed_out))
|
||||
) {
|
||||
sm.state = TRInactive;
|
||||
tr_target_temperature[heater_index] = 0;
|
||||
@ -2065,26 +1981,16 @@ void Temperature::init() {
|
||||
|
||||
void Temperature::disable_all_heaters() {
|
||||
|
||||
#if ENABLED(AUTOTEMP)
|
||||
planner.autotemp_enabled = false;
|
||||
#endif
|
||||
TERN_(AUTOTEMP, planner.autotemp_enabled = false);
|
||||
|
||||
#if HAS_HOTEND
|
||||
HOTEND_LOOP() setTargetHotend(0, e);
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
setTargetBed(0);
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_CHAMBER
|
||||
setTargetChamber(0);
|
||||
#endif
|
||||
TERN_(HAS_HEATED_BED, setTargetBed(0));
|
||||
TERN_(HAS_HEATED_CHAMBER, setTargetChamber(0));
|
||||
|
||||
// Unpause and reset everything
|
||||
#if ENABLED(PROBING_HEATERS_OFF)
|
||||
pause(false);
|
||||
#endif
|
||||
TERN_(PROBING_HEATERS_OFF, pause(false));
|
||||
|
||||
#define DISABLE_HEATER(N) { \
|
||||
setTargetHotend(0, N); \
|
||||
@ -2115,13 +2021,8 @@ void Temperature::disable_all_heaters() {
|
||||
#if HAS_HOTEND
|
||||
HOTEND_LOOP() if (degTargetHotend(e) > (EXTRUDE_MINTEMP) / 2) return true;
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
if (degTargetBed() > BED_MINTEMP) return true;
|
||||
#endif
|
||||
#if HAS_HEATED_CHAMBER
|
||||
if (degTargetChamber() > CHAMBER_MINTEMP) return true;
|
||||
#endif
|
||||
return false;
|
||||
return TERN0(HAS_HEATED_BED, degTargetBed() > BED_MINTEMP)
|
||||
|| TERN0(HAS_HEATED_CHAMBER, degTargetChamber() > CHAMBER_MINTEMP);
|
||||
}
|
||||
|
||||
void Temperature::check_timer_autostart(const bool can_start, const bool can_stop) {
|
||||
@ -2143,16 +2044,12 @@ void Temperature::disable_all_heaters() {
|
||||
if (p != paused) {
|
||||
paused = p;
|
||||
if (p) {
|
||||
HOTEND_LOOP() hotend_idle[e].expire(); // timeout immediately
|
||||
#if HAS_HEATED_BED
|
||||
bed_idle.expire(); // timeout immediately
|
||||
#endif
|
||||
HOTEND_LOOP() hotend_idle[e].expire(); // Timeout immediately
|
||||
TERN_(HAS_HEATED_BED, bed_idle.expire()); // Timeout immediately
|
||||
}
|
||||
else {
|
||||
HOTEND_LOOP() reset_hotend_idle_timer(e);
|
||||
#if HAS_HEATED_BED
|
||||
reset_bed_idle_timer();
|
||||
#endif
|
||||
TERN_(HAS_HEATED_BED, reset_bed_idle_timer());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2303,46 +2200,19 @@ void Temperature::update_raw_temperatures() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_ADC_2
|
||||
temp_hotend[2].update();
|
||||
#endif
|
||||
#if HAS_TEMP_ADC_3
|
||||
temp_hotend[3].update();
|
||||
#endif
|
||||
#if HAS_TEMP_ADC_4
|
||||
temp_hotend[4].update();
|
||||
#endif
|
||||
#if HAS_TEMP_ADC_5
|
||||
temp_hotend[5].update();
|
||||
#endif
|
||||
#if HAS_TEMP_ADC_6
|
||||
temp_hotend[6].update();
|
||||
#endif
|
||||
#if HAS_TEMP_ADC_7
|
||||
temp_hotend[7].update();
|
||||
#endif
|
||||
TERN_(HAS_TEMP_ADC_2, temp_hotend[2].update());
|
||||
TERN_(HAS_TEMP_ADC_3, temp_hotend[3].update());
|
||||
TERN_(HAS_TEMP_ADC_4, temp_hotend[4].update());
|
||||
TERN_(HAS_TEMP_ADC_5, temp_hotend[5].update());
|
||||
TERN_(HAS_TEMP_ADC_6, temp_hotend[6].update());
|
||||
TERN_(HAS_TEMP_ADC_7, temp_hotend[7].update());
|
||||
TERN_(HAS_HEATED_BED, temp_bed.update());
|
||||
TERN_(HAS_TEMP_CHAMBER, temp_chamber.update());
|
||||
TERN_(HAS_TEMP_PROBE, temp_probe.update());
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
temp_bed.update();
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_CHAMBER
|
||||
temp_chamber.update();
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_PROBE
|
||||
temp_probe.update();
|
||||
#endif
|
||||
|
||||
#if HAS_JOY_ADC_X
|
||||
joystick.x.update();
|
||||
#endif
|
||||
#if HAS_JOY_ADC_Y
|
||||
joystick.y.update();
|
||||
#endif
|
||||
#if HAS_JOY_ADC_Z
|
||||
joystick.z.update();
|
||||
#endif
|
||||
TERN_(HAS_JOY_ADC_X, joystick.x.update());
|
||||
TERN_(HAS_JOY_ADC_Y, joystick.y.update());
|
||||
TERN_(HAS_JOY_ADC_Z, joystick.z.update());
|
||||
|
||||
raw_temps_ready = true;
|
||||
}
|
||||
@ -2353,38 +2223,20 @@ void Temperature::readings_ready() {
|
||||
if (!raw_temps_ready) update_raw_temperatures();
|
||||
|
||||
// Filament Sensor - can be read any time since IIR filtering is used
|
||||
#if ENABLED(FILAMENT_WIDTH_SENSOR)
|
||||
filwidth.reading_ready();
|
||||
#endif
|
||||
TERN_(FILAMENT_WIDTH_SENSOR, filwidth.reading_ready());
|
||||
|
||||
#if HAS_HOTEND
|
||||
HOTEND_LOOP() temp_hotend[e].reset();
|
||||
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
||||
temp_hotend[1].reset();
|
||||
#endif
|
||||
TERN_(TEMP_SENSOR_1_AS_REDUNDANT, temp_hotend[1].reset());
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
temp_bed.reset();
|
||||
#endif
|
||||
TERN_(HAS_HEATED_BED, temp_bed.reset());
|
||||
TERN_(HAS_TEMP_CHAMBER, temp_chamber.reset());
|
||||
TERN_(HAS_TEMP_PROBE, temp_probe.reset());
|
||||
|
||||
#if HAS_TEMP_CHAMBER
|
||||
temp_chamber.reset();
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_PROBE
|
||||
temp_probe.reset();
|
||||
#endif
|
||||
|
||||
#if HAS_JOY_ADC_X
|
||||
joystick.x.reset();
|
||||
#endif
|
||||
#if HAS_JOY_ADC_Y
|
||||
joystick.y.reset();
|
||||
#endif
|
||||
#if HAS_JOY_ADC_Z
|
||||
joystick.z.reset();
|
||||
#endif
|
||||
TERN_(HAS_JOY_ADC_X, joystick.x.reset());
|
||||
TERN_(HAS_JOY_ADC_Y, joystick.y.reset());
|
||||
TERN_(HAS_JOY_ADC_Z, joystick.z.reset());
|
||||
|
||||
#if HAS_HOTEND
|
||||
|
||||
@ -2412,9 +2264,7 @@ void Temperature::readings_ready() {
|
||||
if (tdir) {
|
||||
const int16_t rawtemp = temp_hotend[e].raw * tdir; // normal direction, +rawtemp, else -rawtemp
|
||||
const bool heater_on = (temp_hotend[e].target > 0
|
||||
#if ENABLED(PIDTEMP)
|
||||
|| temp_hotend[e].soft_pwm_amount > 0
|
||||
#endif
|
||||
|| TERN0(PIDTEMP, temp_hotend[e].soft_pwm_amount) > 0
|
||||
);
|
||||
if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_ind_t)e);
|
||||
if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) {
|
||||
@ -2438,10 +2288,8 @@ void Temperature::readings_ready() {
|
||||
#else
|
||||
#define BEDCMP(A,B) ((A)>=(B))
|
||||
#endif
|
||||
const bool bed_on = (temp_bed.target > 0)
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
|| (temp_bed.soft_pwm_amount > 0)
|
||||
#endif
|
||||
const bool bed_on = temp_bed.target > 0
|
||||
|| TERN0(PIDTEMPBED, temp_bed.soft_pwm_amount) > 0
|
||||
;
|
||||
if (BEDCMP(temp_bed.raw, maxtemp_raw_BED)) max_temp_error(H_BED);
|
||||
if (bed_on && BEDCMP(mintemp_raw_BED, temp_bed.raw)) min_temp_error(H_BED);
|
||||
@ -2774,10 +2622,8 @@ void Temperature::tick() {
|
||||
#if HAS_HOTEND
|
||||
HOTEND_LOOP() soft_pwm_hotend[e].dec();
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
soft_pwm_bed.dec();
|
||||
#endif
|
||||
} // ((pwm_count >> SOFT_PWM_SCALE) & 0x3F) == 0
|
||||
TERN_(HAS_HEATED_BED, soft_pwm_bed.dec());
|
||||
}
|
||||
|
||||
#endif // SLOW_PWM_HEATERS
|
||||
|
||||
@ -3218,9 +3064,7 @@ void Temperature::tick() {
|
||||
|
||||
if (wait_for_heatup) {
|
||||
ui.reset_status();
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
printerEventLEDs.onHeatingDone();
|
||||
#endif
|
||||
TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onHeatingDone());
|
||||
}
|
||||
|
||||
return wait_for_heatup;
|
||||
|
Reference in New Issue
Block a user