M872 wait for probe temperature (#19344)
This commit is contained in:
@ -440,7 +440,6 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
|
||||
SHV(bias = d = (MAX_BED_POWER) >> 1, bias = d = (PID_MAX) >> 1);
|
||||
|
||||
wait_for_heatup = true; // Can be interrupted with M108
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
const float start_temp = GHV(temp_bed.celsius, temp_hotend[heater].celsius);
|
||||
LEDColor color = ONHEATINGSTART();
|
||||
@ -449,6 +448,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = false);
|
||||
|
||||
// PID Tuning loop
|
||||
wait_for_heatup = true; // Can be interrupted with M108
|
||||
while (wait_for_heatup) {
|
||||
|
||||
const millis_t ms = millis();
|
||||
@ -632,6 +632,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
}
|
||||
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
|
||||
}
|
||||
wait_for_heatup = false;
|
||||
|
||||
disable_all_heaters();
|
||||
|
||||
@ -3060,10 +3061,10 @@ void Temperature::tick() {
|
||||
printerEventLEDs.onHotendHeatingStart();
|
||||
#endif
|
||||
|
||||
float target_temp = -1.0, old_temp = 9999.0;
|
||||
bool wants_to_cool = false;
|
||||
wait_for_heatup = true;
|
||||
float target_temp = -1.0, old_temp = 9999.0;
|
||||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
||||
wait_for_heatup = true;
|
||||
do {
|
||||
// Target temperature might be changed during the loop
|
||||
if (target_temp != degTargetHotend(target_extruder)) {
|
||||
@ -3137,6 +3138,7 @@ void Temperature::tick() {
|
||||
} while (wait_for_heatup && TEMP_CONDITIONS);
|
||||
|
||||
if (wait_for_heatup) {
|
||||
wait_for_heatup = false;
|
||||
#if ENABLED(DWIN_CREALITY_LCD)
|
||||
HMI_flag.heat_flag = 0;
|
||||
duration_t elapsed = print_job_timer.duration(); // print timer
|
||||
@ -3145,9 +3147,10 @@ void Temperature::tick() {
|
||||
ui.reset_status();
|
||||
#endif
|
||||
TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onHeatingDone());
|
||||
return true;
|
||||
}
|
||||
|
||||
return wait_for_heatup;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // HAS_TEMP_HOTEND
|
||||
@ -3176,11 +3179,6 @@ void Temperature::tick() {
|
||||
#define TEMP_BED_CONDITIONS (wants_to_cool ? isCoolingBed() : isHeatingBed())
|
||||
#endif
|
||||
|
||||
float target_temp = -1, old_temp = 9999;
|
||||
bool wants_to_cool = false;
|
||||
wait_for_heatup = true;
|
||||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
||||
|
||||
#if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE)
|
||||
KEEPALIVE_STATE(NOT_BUSY);
|
||||
#endif
|
||||
@ -3190,6 +3188,10 @@ void Temperature::tick() {
|
||||
printerEventLEDs.onBedHeatingStart();
|
||||
#endif
|
||||
|
||||
bool wants_to_cool = false;
|
||||
float target_temp = -1, old_temp = 9999;
|
||||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
||||
wait_for_heatup = true;
|
||||
do {
|
||||
// Target temperature might be changed during the loop
|
||||
if (target_temp != degTargetBed()) {
|
||||
@ -3264,9 +3266,13 @@ void Temperature::tick() {
|
||||
|
||||
} while (wait_for_heatup && TEMP_BED_CONDITIONS);
|
||||
|
||||
if (wait_for_heatup) ui.reset_status();
|
||||
if (wait_for_heatup) {
|
||||
wait_for_heatup = false;
|
||||
ui.reset_status();
|
||||
return true;
|
||||
}
|
||||
|
||||
return wait_for_heatup;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Temperature::wait_for_bed_heating() {
|
||||
@ -3280,6 +3286,77 @@ void Temperature::tick() {
|
||||
|
||||
#endif // HAS_HEATED_BED
|
||||
|
||||
#if HAS_TEMP_PROBE
|
||||
|
||||
#ifndef MIN_DELTA_SLOPE_DEG_PROBE
|
||||
#define MIN_DELTA_SLOPE_DEG_PROBE 1.0
|
||||
#endif
|
||||
#ifndef MIN_DELTA_SLOPE_TIME_PROBE
|
||||
#define MIN_DELTA_SLOPE_TIME_PROBE 600
|
||||
#endif
|
||||
|
||||
bool Temperature::wait_for_probe(const float target_temp, bool no_wait_for_cooling/*=true*/) {
|
||||
|
||||
const bool wants_to_cool = isProbeAboveTemp(target_temp);
|
||||
const bool will_wait = !(wants_to_cool && no_wait_for_cooling);
|
||||
if (will_wait)
|
||||
SERIAL_ECHOLNPAIR("Waiting for probe to ", (wants_to_cool ? PSTR("cool down") : PSTR("heat up")), " to ", target_temp, " degrees.");
|
||||
|
||||
#if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE)
|
||||
KEEPALIVE_STATE(NOT_BUSY);
|
||||
#endif
|
||||
|
||||
float old_temp = 9999;
|
||||
millis_t next_temp_ms = 0, next_delta_check_ms = 0;
|
||||
wait_for_heatup = true;
|
||||
while (will_wait && wait_for_heatup) {
|
||||
|
||||
// Print Temp Reading every 10 seconds while heating up.
|
||||
millis_t now = millis();
|
||||
if (!next_temp_ms || ELAPSED(now, next_temp_ms)) {
|
||||
next_temp_ms = now + 10000UL;
|
||||
print_heater_states(active_extruder);
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
idle();
|
||||
gcode.reset_stepper_timeout(); // Keep steppers powered
|
||||
|
||||
// Break after MIN_DELTA_SLOPE_TIME_PROBE seconds if the temperature
|
||||
// did not drop at least MIN_DELTA_SLOPE_DEG_PROBE. This avoids waiting
|
||||
// forever as the probe is not actively heated.
|
||||
if (!next_delta_check_ms || ELAPSED(now, next_delta_check_ms)) {
|
||||
const float temp = degProbe(),
|
||||
delta_temp = old_temp > temp ? old_temp - temp : temp - old_temp;
|
||||
if (delta_temp < float(MIN_DELTA_SLOPE_DEG_PROBE)) {
|
||||
SERIAL_ECHOLNPGM("Timed out waiting for probe temperature.");
|
||||
break;
|
||||
}
|
||||
next_delta_check_ms = now + 1000UL * MIN_DELTA_SLOPE_TIME_PROBE;
|
||||
old_temp = temp;
|
||||
}
|
||||
|
||||
// Loop until the temperature is very close target
|
||||
if (!(wants_to_cool ? isProbeAboveTemp(target_temp) : isProbeBelowTemp(target_temp))) {
|
||||
SERIAL_ECHOLN(wants_to_cool ? PSTR("Cooldown") : PSTR("Heatup"));
|
||||
SERIAL_ECHOLNPGM(" complete, target probe temperature reached.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (wait_for_heatup) {
|
||||
wait_for_heatup = false;
|
||||
ui.reset_status();
|
||||
return true;
|
||||
}
|
||||
else if (will_wait)
|
||||
SERIAL_ECHOLNPGM("Canceled wait for probe temperature.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // HAS_TEMP_PROBE
|
||||
|
||||
#if HAS_HEATED_CHAMBER
|
||||
|
||||
#ifndef MIN_COOLING_SLOPE_DEG_CHAMBER
|
||||
@ -3300,15 +3377,14 @@ void Temperature::tick() {
|
||||
#define TEMP_CHAMBER_CONDITIONS (wants_to_cool ? isCoolingChamber() : isHeatingChamber())
|
||||
#endif
|
||||
|
||||
float target_temp = -1, old_temp = 9999;
|
||||
bool wants_to_cool = false;
|
||||
wait_for_heatup = true;
|
||||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
||||
|
||||
#if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE)
|
||||
KEEPALIVE_STATE(NOT_BUSY);
|
||||
#endif
|
||||
|
||||
bool wants_to_cool = false;
|
||||
float target_temp = -1, old_temp = 9999;
|
||||
millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
||||
wait_for_heatup = true;
|
||||
do {
|
||||
// Target temperature might be changed during the loop
|
||||
if (target_temp != degTargetChamber()) {
|
||||
@ -3367,9 +3443,13 @@ void Temperature::tick() {
|
||||
}
|
||||
} while (wait_for_heatup && TEMP_CHAMBER_CONDITIONS);
|
||||
|
||||
if (wait_for_heatup) ui.reset_status();
|
||||
if (wait_for_heatup) {
|
||||
wait_for_heatup = false;
|
||||
ui.reset_status();
|
||||
return true;
|
||||
}
|
||||
|
||||
return wait_for_heatup;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // HAS_HEATED_CHAMBER
|
||||
|
@ -654,6 +654,9 @@ class Temperature {
|
||||
FORCE_INLINE static int16_t rawProbeTemp() { return temp_probe.raw; }
|
||||
#endif
|
||||
FORCE_INLINE static float degProbe() { return temp_probe.celsius; }
|
||||
FORCE_INLINE static bool isProbeBelowTemp(const float target_temp) { return temp_probe.celsius < target_temp; }
|
||||
FORCE_INLINE static bool isProbeAboveTemp(const float target_temp) { return temp_probe.celsius > target_temp; }
|
||||
static bool wait_for_probe(const float target_temp, bool no_wait_for_cooling=true);
|
||||
#endif
|
||||
|
||||
#if WATCH_PROBE
|
||||
|
Reference in New Issue
Block a user