Optimize some G76 strings

2.0.x
Scott Lahteine 4 years ago
parent 8690f4862d
commit 7c7d28345e

@ -91,6 +91,12 @@
* - `B` - Run bed temperature calibration. * - `B` - Run bed temperature calibration.
* - `P` - Run probe temperature calibration. * - `P` - Run probe temperature calibration.
*/ */
static void say_waiting_for() { SERIAL_ECHOPGM("Waiting for "); }
static void say_waiting_for_probe_heating() { say_waiting_for(); SERIAL_ECHOLNPGM("probe heating."); }
static void say_successfully_calibrated() { SERIAL_ECHOPGM("Successfully calibrated"); }
static void say_failed_to_calibrate() { SERIAL_ECHOPGM("!Failed to calibrate"); }
void GcodeSuite::G76() { void GcodeSuite::G76() {
// Check if heated bed is available and z-homing is done with probe // Check if heated bed is available and z-homing is done with probe
#if TEMP_SENSOR_BED == 0 || !(HOMING_Z_WITH_PROBE) #if TEMP_SENSOR_BED == 0 || !(HOMING_Z_WITH_PROBE)
@ -108,7 +114,7 @@ void GcodeSuite::G76() {
}; };
auto wait_for_temps = [&](const float tb, const float tp, millis_t &ntr, const millis_t timeout=0) { auto wait_for_temps = [&](const float tb, const float tp, millis_t &ntr, const millis_t timeout=0) {
SERIAL_ECHOLNPGM("Waiting for bed and probe temperature."); say_waiting_for(); SERIAL_ECHOLNPGM("bed and probe temperature.");
while (fabs(thermalManager.degBed() - tb) > 0.1f || thermalManager.degProbe() > tp) while (fabs(thermalManager.degBed() - tb) > 0.1f || thermalManager.degProbe() > tp)
if (report_temps(ntr, timeout)) return true; if (report_temps(ntr, timeout)) return true;
return false; return false;
@ -184,7 +190,7 @@ void GcodeSuite::G76() {
uint16_t target_bed = cali_info_init[TSI_BED].start_temp, uint16_t target_bed = cali_info_init[TSI_BED].start_temp,
target_probe = temp_comp.bed_calib_probe_temp; target_probe = temp_comp.bed_calib_probe_temp;
SERIAL_ECHOLNPGM("Waiting for cooling."); say_waiting_for(); SERIAL_ECHOLNPGM(" cooling.");
while (thermalManager.degBed() > target_bed || thermalManager.degProbe() > target_probe) while (thermalManager.degBed() > target_bed || thermalManager.degProbe() > target_probe)
report_temps(next_temp_report); report_temps(next_temp_report);
@ -207,7 +213,8 @@ void GcodeSuite::G76() {
// Move the nozzle to the probing point and wait for the probe to reach target temp // Move the nozzle to the probing point and wait for the probe to reach target temp
do_blocking_move_to(noz_pos_xyz); do_blocking_move_to(noz_pos_xyz);
SERIAL_ECHOLNPGM("Waiting for probe heating."); say_waiting_for_probe_heating();
SERIAL_EOL();
while (thermalManager.degProbe() < target_probe) while (thermalManager.degProbe() < target_probe)
report_temps(next_temp_report); report_temps(next_temp_report);
@ -216,10 +223,14 @@ void GcodeSuite::G76() {
} }
SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
if (temp_comp.finish_calibration(TSI_BED)) if (temp_comp.finish_calibration(TSI_BED)) {
SERIAL_ECHOLNPGM("Successfully calibrated bed."); say_successfully_calibrated();
else SERIAL_ECHOLNPGM(" bed.");
SERIAL_ECHOLNPGM("!Failed to calibrate bed. Values reset."); }
else {
say_failed_to_calibrate();
SERIAL_ECHOLNPGM(" bed. Values reset.");
}
// Cleanup // Cleanup
thermalManager.setTargetBed(0); thermalManager.setTargetBed(0);
@ -254,7 +265,8 @@ void GcodeSuite::G76() {
// Move probe to probing point and wait for it to reach target temperature // Move probe to probing point and wait for it to reach target temperature
do_blocking_move_to(noz_pos_xyz); do_blocking_move_to(noz_pos_xyz);
SERIAL_ECHOLNPAIR("Waiting for probe heating. Bed:", target_bed, " Probe:", target_probe); say_waiting_for_probe_heating();
SERIAL_ECHOLNPAIR(" Bed:", target_bed, " Probe:", target_probe);
const millis_t probe_timeout_ms = millis() + 900UL * 1000UL; const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
while (thermalManager.degProbe() < target_probe) { while (thermalManager.degProbe() < target_probe) {
if (report_temps(next_temp_report, probe_timeout_ms)) { if (report_temps(next_temp_report, probe_timeout_ms)) {
@ -271,9 +283,9 @@ void GcodeSuite::G76() {
SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
if (temp_comp.finish_calibration(TSI_PROBE)) if (temp_comp.finish_calibration(TSI_PROBE))
SERIAL_ECHOPGM("Successfully calibrated"); say_successfully_calibrated();
else else
SERIAL_ECHOPGM("!Failed to calibrate"); say_failed_to_calibrate();
SERIAL_ECHOLNPGM(" probe."); SERIAL_ECHOLNPGM(" probe.");
// Cleanup // Cleanup

Loading…
Cancel
Save