Temperature cleanup
This commit is contained in:
parent
e69e56ea52
commit
d174d610bd
@ -184,14 +184,16 @@ void Touch::touch(touch_control_t *control) {
|
||||
int8_t heater;
|
||||
heater = control->data;
|
||||
ui.clear_lcd();
|
||||
if (heater >= 0) { // HotEnd
|
||||
#if HOTENDS == 1
|
||||
MenuItem_int3::action((const char *)GET_TEXT_F(MSG_NOZZLE), &thermalManager.temp_hotend[0].target, 0, thermalManager.hotend_max_target(0), []{ thermalManager.start_watching_hotend(0); });
|
||||
#else
|
||||
MenuItemBase::itemIndex = heater;
|
||||
MenuItem_int3::action((const char *)GET_TEXT_F(MSG_NOZZLE_N), &thermalManager.temp_hotend[heater].target, 0, thermalManager.hotend_max_target(heater), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
|
||||
#endif
|
||||
}
|
||||
#if HAS_HOTEND
|
||||
if (heater >= 0) { // HotEnd
|
||||
#if HOTENDS == 1
|
||||
MenuItem_int3::action((const char *)GET_TEXT_F(MSG_NOZZLE), &thermalManager.temp_hotend[0].target, 0, thermalManager.hotend_max_target(0), []{ thermalManager.start_watching_hotend(0); });
|
||||
#else
|
||||
MenuItemBase::itemIndex = heater;
|
||||
MenuItem_int3::action((const char *)GET_TEXT_F(MSG_NOZZLE_N), &thermalManager.temp_hotend[heater].target, 0, thermalManager.hotend_max_target(heater), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
else if (heater == H_BED) {
|
||||
MenuItem_int3::action((const char *)GET_TEXT_F(MSG_BED), &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed);
|
||||
|
@ -443,11 +443,11 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0, sensor_heater_1, sensor_heater_2, sensor_heater_3, sensor_heater_4, sensor_heater_5, sensor_heater_6, sensor_heater_7);
|
||||
#endif
|
||||
|
||||
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
|
||||
#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1
|
||||
uint8_t Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 };
|
||||
#endif
|
||||
|
||||
#ifdef MILLISECONDS_PREHEAT_TIME
|
||||
#if MILLISECONDS_PREHEAT_TIME > 0
|
||||
millis_t Temperature::preheat_end_time[HOTENDS] = { 0 };
|
||||
#endif
|
||||
|
||||
@ -468,7 +468,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
#endif
|
||||
|
||||
#if ENABLED(PROBING_HEATERS_OFF)
|
||||
bool Temperature::paused;
|
||||
bool Temperature::paused_for_probing;
|
||||
#endif
|
||||
|
||||
// public:
|
||||
@ -1312,10 +1312,10 @@ void Temperature::manage_heater() {
|
||||
|
||||
#if DISABLED(PIDTEMPBED)
|
||||
if (PENDING(ms, next_bed_check_ms)
|
||||
&& TERN1(PAUSE_CHANGE_REQD, paused == last_pause_state)
|
||||
&& TERN1(PAUSE_CHANGE_REQD, paused_for_probing == last_pause_state)
|
||||
) break;
|
||||
next_bed_check_ms = ms + BED_CHECK_INTERVAL;
|
||||
TERN_(PAUSE_CHANGE_REQD, last_pause_state = paused);
|
||||
TERN_(PAUSE_CHANGE_REQD, last_pause_state = paused_for_probing);
|
||||
#endif
|
||||
|
||||
TERN_(HEATER_IDLE_HANDLER, heater_idle[IDLE_INDEX_BED].update(ms));
|
||||
@ -1950,9 +1950,30 @@ void Temperature::updateTemperaturesFromRawValues() {
|
||||
|
||||
/**
|
||||
* Initialize the temperature manager
|
||||
*
|
||||
* The manager is implemented by periodic calls to manage_heater()
|
||||
*
|
||||
* - Init (and disable) SPI thermocouples like MAX6675 and MAX31865
|
||||
* - Disable RUMBA JTAG to accommodate a thermocouple extension
|
||||
* - Read-enable thermistors with a read-enable pin
|
||||
* - Init HEATER and COOLER pins for OUTPUT in OFF state
|
||||
* - Init the FAN pins as PWM or OUTPUT
|
||||
* - Init the SPI interface for SPI thermocouples
|
||||
* - Init ADC according to the HAL
|
||||
* - Set thermistor pins to analog inputs according to the HAL
|
||||
* - Start the Temperature ISR timer
|
||||
* - Init the AUTO FAN pins as PWM or OUTPUT
|
||||
* - Wait 250ms for temperatures to settle
|
||||
* - Init temp_range[], used for catching min/maxtemp
|
||||
*/
|
||||
void Temperature::init() {
|
||||
|
||||
TERN_(PROBING_HEATERS_OFF, paused_for_probing = false);
|
||||
|
||||
#if BOTH(PIDTEMP, PID_EXTRUSION_SCALING)
|
||||
last_e_position = 0;
|
||||
#endif
|
||||
|
||||
// Init (and disable) SPI thermocouples
|
||||
#if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS)
|
||||
OUT_WRITE(MAX6675_CS_PIN, HIGH);
|
||||
@ -2003,10 +2024,6 @@ void Temperature::init() {
|
||||
OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_1_IS_MAX_TC));
|
||||
#endif
|
||||
|
||||
#if BOTH(PIDTEMP, PID_EXTRUSION_SCALING)
|
||||
last_e_position = 0;
|
||||
#endif
|
||||
|
||||
#if HAS_HEATER_0
|
||||
#ifdef BOARD_OPENDRAIN_MOSFETS
|
||||
OUT_WRITE_OD(HEATER_0_PIN, HEATER_0_INVERTING);
|
||||
@ -2262,55 +2279,8 @@ void Temperature::init() {
|
||||
while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR);
|
||||
while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR);
|
||||
#endif
|
||||
|
||||
TERN_(PROBING_HEATERS_OFF, paused = false);
|
||||
}
|
||||
|
||||
#if WATCH_HOTENDS
|
||||
/**
|
||||
* Start Heating Sanity Check for hotends that are below
|
||||
* their target temperature by a configurable margin.
|
||||
* This is called when the temperature is set. (M104, M109)
|
||||
*/
|
||||
void Temperature::start_watching_hotend(const uint8_t E_NAME) {
|
||||
const uint8_t ee = HOTEND_INDEX;
|
||||
watch_hotend[ee].restart(degHotend(ee), degTargetHotend(ee));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WATCH_BED
|
||||
/**
|
||||
* Start Heating Sanity Check for hotends that are below
|
||||
* their target temperature by a configurable margin.
|
||||
* This is called when the temperature is set. (M140, M190)
|
||||
*/
|
||||
void Temperature::start_watching_bed() {
|
||||
watch_bed.restart(degBed(), degTargetBed());
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WATCH_CHAMBER
|
||||
/**
|
||||
* Start Heating Sanity Check for chamber that is below
|
||||
* its target temperature by a configurable margin.
|
||||
* This is called when the temperature is set. (M141, M191)
|
||||
*/
|
||||
void Temperature::start_watching_chamber() {
|
||||
watch_chamber.restart(degChamber(), degTargetChamber());
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WATCH_COOLER
|
||||
/**
|
||||
* Start Cooling Sanity Check for cooler that is above
|
||||
* its target temperature by a configurable margin.
|
||||
* This is called when the temperature is set. (M143, M193)
|
||||
*/
|
||||
void Temperature::start_watching_cooler() {
|
||||
watch_cooler.restart(degCooler(), degTargetCooler());
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_THERMAL_PROTECTION
|
||||
|
||||
Temperature::tr_state_machine_t Temperature::tr_state_machine[NR_HEATER_RUNAWAY]; // = { { TRInactive, 0 } };
|
||||
@ -2473,8 +2443,8 @@ void Temperature::disable_all_heaters() {
|
||||
#if ENABLED(PROBING_HEATERS_OFF)
|
||||
|
||||
void Temperature::pause(const bool p) {
|
||||
if (p != paused) {
|
||||
paused = p;
|
||||
if (p != paused_for_probing) {
|
||||
paused_for_probing = p;
|
||||
if (p) {
|
||||
HOTEND_LOOP() heater_idle[e].expire(); // Timeout immediately
|
||||
TERN_(HAS_HEATED_BED, heater_idle[IDLE_INDEX_BED].expire()); // Timeout immediately
|
||||
@ -2759,17 +2729,16 @@ void Temperature::readings_ready() {
|
||||
const int8_t tdir = temp_dir[e];
|
||||
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
|
||||
|| TERN0(PIDTEMP, temp_hotend[e].soft_pwm_amount) > 0
|
||||
);
|
||||
if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_id_t)e);
|
||||
|
||||
const bool heater_on = (temp_hotend[e].target > 0 || TERN0(PIDTEMP, temp_hotend[e].soft_pwm_amount > 0));
|
||||
if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) {
|
||||
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
|
||||
#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1
|
||||
if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
|
||||
#endif
|
||||
min_temp_error((heater_id_t)e);
|
||||
}
|
||||
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
|
||||
#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1
|
||||
else
|
||||
consecutive_low_temperature_error[e] = 0;
|
||||
#endif
|
||||
|
@ -458,11 +458,11 @@ class Temperature {
|
||||
static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER;
|
||||
#endif
|
||||
|
||||
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
|
||||
#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1
|
||||
static uint8_t consecutive_low_temperature_error[HOTENDS];
|
||||
#endif
|
||||
|
||||
#ifdef MILLISECONDS_PREHEAT_TIME
|
||||
#if MILLISECONDS_PREHEAT_TIME > 0
|
||||
static millis_t preheat_end_time[HOTENDS];
|
||||
#endif
|
||||
|
||||
@ -471,7 +471,7 @@ class Temperature {
|
||||
#endif
|
||||
|
||||
#if ENABLED(PROBING_HEATERS_OFF)
|
||||
static bool paused;
|
||||
static bool paused_for_probing;
|
||||
#endif
|
||||
|
||||
public:
|
||||
@ -606,7 +606,7 @@ class Temperature {
|
||||
/**
|
||||
* Preheating hotends
|
||||
*/
|
||||
#ifdef MILLISECONDS_PREHEAT_TIME
|
||||
#if MILLISECONDS_PREHEAT_TIME > 0
|
||||
static inline bool is_preheating(const uint8_t E_NAME) {
|
||||
return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]);
|
||||
}
|
||||
@ -649,17 +649,11 @@ class Temperature {
|
||||
return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target);
|
||||
}
|
||||
|
||||
#if WATCH_HOTENDS
|
||||
static void start_watching_hotend(const uint8_t e=0);
|
||||
#else
|
||||
static inline void start_watching_hotend(const uint8_t=0) {}
|
||||
#endif
|
||||
|
||||
#if HAS_HOTEND
|
||||
|
||||
static void setTargetHotend(const celsius_t celsius, const uint8_t E_NAME) {
|
||||
const uint8_t ee = HOTEND_INDEX;
|
||||
#ifdef MILLISECONDS_PREHEAT_TIME
|
||||
#if MILLISECONDS_PREHEAT_TIME > 0
|
||||
if (celsius == 0)
|
||||
reset_preheat_time(ee);
|
||||
else if (temp_hotend[ee].target == 0)
|
||||
@ -698,6 +692,14 @@ class Temperature {
|
||||
return ABS(wholeDegHotend(e) - temp) < (TEMP_HYSTERESIS);
|
||||
}
|
||||
|
||||
// Start watching a Hotend to make sure it's really heating up
|
||||
static inline void start_watching_hotend(const uint8_t E_NAME) {
|
||||
UNUSED(HOTEND_INDEX);
|
||||
#if WATCH_HOTENDS
|
||||
watch_hotend[HOTEND_INDEX].restart(degHotend(HOTEND_INDEX), degTargetHotend(HOTEND_INDEX));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // HAS_HOTEND
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
@ -711,11 +713,8 @@ class Temperature {
|
||||
static inline bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; }
|
||||
static inline bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; }
|
||||
|
||||
#if WATCH_BED
|
||||
static void start_watching_bed();
|
||||
#else
|
||||
static inline void start_watching_bed() {}
|
||||
#endif
|
||||
// Start watching the Bed to make sure it's really heating up
|
||||
static inline void start_watching_bed() { TERN_(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())); }
|
||||
|
||||
static void setTargetBed(const celsius_t celsius) {
|
||||
TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on());
|
||||
@ -748,12 +747,6 @@ class Temperature {
|
||||
static bool wait_for_probe(const celsius_t target_temp, bool no_wait_for_cooling=true);
|
||||
#endif
|
||||
|
||||
#if WATCH_PROBE
|
||||
static void start_watching_probe();
|
||||
#else
|
||||
static inline void start_watching_probe() {}
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_CHAMBER
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
static inline int16_t rawChamberTemp() { return temp_chamber.raw; }
|
||||
@ -768,17 +761,13 @@ class Temperature {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if WATCH_CHAMBER
|
||||
static void start_watching_chamber();
|
||||
#else
|
||||
static inline void start_watching_chamber() {}
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_CHAMBER
|
||||
static void setTargetChamber(const celsius_t celsius) {
|
||||
temp_chamber.target = _MIN(celsius, CHAMBER_MAX_TARGET);
|
||||
start_watching_chamber();
|
||||
}
|
||||
// Start watching the Chamber to make sure it's really heating up
|
||||
static inline void start_watching_chamber() { TERN_(WATCH_CHAMBER, watch_chamber.restart(degChamber(), degTargetChamber())); }
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_COOLER
|
||||
@ -795,17 +784,13 @@ class Temperature {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if WATCH_COOLER
|
||||
static void start_watching_cooler();
|
||||
#else
|
||||
static inline void start_watching_cooler() {}
|
||||
#endif
|
||||
|
||||
#if HAS_COOLER
|
||||
static inline void setTargetCooler(const celsius_t celsius) {
|
||||
temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET);
|
||||
start_watching_cooler();
|
||||
}
|
||||
// Start watching the Cooler to make sure it's really cooling down
|
||||
static inline void start_watching_cooler() { TERN_(WATCH_COOLER, watch_cooler.restart(degCooler(), degTargetCooler())); }
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -856,7 +841,6 @@ class Temperature {
|
||||
|
||||
#if ENABLED(PROBING_HEATERS_OFF)
|
||||
static void pause(const bool p);
|
||||
static inline bool is_paused() { return paused; }
|
||||
#endif
|
||||
|
||||
#if HEATER_IDLE_HANDLER
|
||||
|
Loading…
Reference in New Issue
Block a user