General G76 cleanup
This commit is contained in:
parent
a75a25cd7c
commit
bfbd976c09
|
@ -92,10 +92,8 @@ void GcodeSuite::G76() {
|
||||||
set_bltouch_deployed(false);
|
set_bltouch_deployed(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool do_bed_cal = parser.boolval('B'),
|
bool do_bed_cal = parser.boolval('B'), do_probe_cal = parser.boolval('P');
|
||||||
do_probe_cal = parser.boolval('P');
|
if (!do_bed_cal && !do_probe_cal) do_bed_cal = do_probe_cal = true;
|
||||||
if (!do_bed_cal && !do_probe_cal)
|
|
||||||
do_bed_cal = do_probe_cal = true;
|
|
||||||
|
|
||||||
// Synchronize with planner
|
// Synchronize with planner
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
|
@ -133,10 +131,8 @@ void GcodeSuite::G76() {
|
||||||
uint16_t target_bed = temp_comp.cali_info_init[TSI_BED].start_temp,
|
uint16_t target_bed = temp_comp.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 printer to cool down.");
|
SERIAL_ECHOLNPGM("Waiting for cooling.");
|
||||||
while (thermalManager.degBed() > target_bed
|
while (thermalManager.degBed() > target_bed || thermalManager.degProbe() > target_probe) {
|
||||||
|| thermalManager.degProbe() > target_probe
|
|
||||||
) {
|
|
||||||
idle_no_sleep();
|
idle_no_sleep();
|
||||||
const millis_t ms = millis();
|
const millis_t ms = millis();
|
||||||
if (ELAPSED(ms, next_temp_report)) {
|
if (ELAPSED(ms, next_temp_report)) {
|
||||||
|
@ -151,16 +147,16 @@ void GcodeSuite::G76() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool timeout = false;
|
bool timeout = false;
|
||||||
while (true) {
|
for (;;) {
|
||||||
thermalManager.setTargetBed(target_bed);
|
thermalManager.setTargetBed(target_bed);
|
||||||
|
|
||||||
SERIAL_ECHOLNPAIR("Target Bed: ", target_bed, "; Probe: ", target_probe);
|
SERIAL_ECHOLNPAIR("Target Bed:", target_bed, " Probe:", target_probe);
|
||||||
|
|
||||||
// Park nozzle
|
// Park nozzle
|
||||||
do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);
|
do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);
|
||||||
|
|
||||||
// Wait for heatbed to reach target temp and probe to cool below target temp
|
// Wait for heatbed to reach target temp and probe to cool below target temp
|
||||||
SERIAL_ECHOLNPGM("Waiting for bed and probe to reach target temp.");
|
SERIAL_ECHOLNPGM("Waiting for bed / probe to reach target.");
|
||||||
const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
|
const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
|
||||||
while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1 || thermalManager.degProbe() > target_probe) {
|
while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1 || thermalManager.degProbe() > target_probe) {
|
||||||
idle_no_sleep();
|
idle_no_sleep();
|
||||||
|
@ -179,7 +175,7 @@ void GcodeSuite::G76() {
|
||||||
if (timeout) break;
|
if (timeout) break;
|
||||||
|
|
||||||
// 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
|
||||||
destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5);
|
destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y);
|
||||||
do_blocking_move_to(destination);
|
do_blocking_move_to(destination);
|
||||||
SERIAL_ECHOLNPGM("Waiting for probe heating.");
|
SERIAL_ECHOLNPGM("Waiting for probe heating.");
|
||||||
while (thermalManager.degProbe() < target_probe) {
|
while (thermalManager.degProbe() < target_probe) {
|
||||||
|
@ -197,15 +193,12 @@ void GcodeSuite::G76() {
|
||||||
|
|
||||||
// Do a single probe at the current position
|
// Do a single probe at the current position
|
||||||
remember_feedrate_scaling_off();
|
remember_feedrate_scaling_off();
|
||||||
const float measured_z = probe.probe_at_point(
|
const xy_pos_t probe_xy = destination + probe.offset_xy;
|
||||||
destination.x + probe.offset_xy.x,
|
const float measured_z = probe.probe_at_point(probe_xy, PROBE_PT_NONE);
|
||||||
destination.y + probe.offset_xy.y,
|
|
||||||
PROBE_PT_NONE
|
|
||||||
);
|
|
||||||
restore_feedrate_and_scaling();
|
restore_feedrate_and_scaling();
|
||||||
|
|
||||||
if (isnan(measured_z)) {
|
if (isnan(measured_z)) {
|
||||||
SERIAL_ECHOLNPGM("!Received NAN measurement - aborting.");
|
SERIAL_ECHOLNPGM("!Received NAN. Aborting.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -224,7 +217,7 @@ void GcodeSuite::G76() {
|
||||||
if (temp_comp.finish_calibration(TSI_BED))
|
if (temp_comp.finish_calibration(TSI_BED))
|
||||||
SERIAL_ECHOLNPGM("Successfully calibrated bed.");
|
SERIAL_ECHOLNPGM("Successfully calibrated bed.");
|
||||||
else
|
else
|
||||||
SERIAL_ECHOLNPGM("!Failed to calibrated bed - reset calibration values.");
|
SERIAL_ECHOLNPGM("!Failed to calibrate bed. Values reset.");
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
thermalManager.setTargetBed(0);
|
thermalManager.setTargetBed(0);
|
||||||
|
@ -243,9 +236,11 @@ void GcodeSuite::G76() {
|
||||||
do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);
|
do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);
|
||||||
|
|
||||||
// Initialize temperatures
|
// Initialize temperatures
|
||||||
uint16_t target_bed = temp_comp.probe_calib_bed_temp,
|
const uint16_t target_bed = temp_comp.probe_calib_bed_temp;
|
||||||
target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp;
|
|
||||||
thermalManager.setTargetBed(target_bed);
|
thermalManager.setTargetBed(target_bed);
|
||||||
|
|
||||||
|
uint16_t target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp;
|
||||||
|
|
||||||
SERIAL_ECHOLNPGM("Waiting for bed and probe temperature.");
|
SERIAL_ECHOLNPGM("Waiting for bed and probe temperature.");
|
||||||
while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1f
|
while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1f
|
||||||
|| thermalManager.degProbe() > target_probe
|
|| thermalManager.degProbe() > target_probe
|
||||||
|
@ -264,16 +259,12 @@ void GcodeSuite::G76() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool timeout = false;
|
bool timeout = false;
|
||||||
while (true) {
|
for (;;) {
|
||||||
// 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
|
||||||
destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5);
|
destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y);
|
||||||
do_blocking_move_to(destination);
|
do_blocking_move_to(destination);
|
||||||
|
|
||||||
SERIAL_ECHOLNPAIR(
|
SERIAL_ECHOLNPAIR("Waiting for probe heating. Bed:", target_bed, " Probe:", target_probe);
|
||||||
"Bed temp: ", target_bed,
|
|
||||||
"; Probe temp: ", target_probe,
|
|
||||||
" Waiting for probe heating."
|
|
||||||
);
|
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -284,7 +275,7 @@ void GcodeSuite::G76() {
|
||||||
next_temp_report = ms + 1000;
|
next_temp_report = ms + 1000;
|
||||||
}
|
}
|
||||||
if (ELAPSED(ms, probe_timeout_ms)) {
|
if (ELAPSED(ms, probe_timeout_ms)) {
|
||||||
SERIAL_ECHOLNPGM("!Probe heating aborted due to timeout.");
|
SERIAL_ECHOLNPGM("!Probe heating timed out.");
|
||||||
timeout = true;
|
timeout = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -298,11 +289,8 @@ void GcodeSuite::G76() {
|
||||||
|
|
||||||
// Do a single probe
|
// Do a single probe
|
||||||
remember_feedrate_scaling_off();
|
remember_feedrate_scaling_off();
|
||||||
const float measured_z = probe.probe_at_point(
|
const xy_pos_t probe_xy = destination + probe.offset_xy;
|
||||||
destination.x + probe.offset_xy.x,
|
const float measured_z = probe.probe_at_point(probe_xy, PROBE_PT_NONE);
|
||||||
destination.y + probe.offset_xy.y,
|
|
||||||
PROBE_PT_NONE
|
|
||||||
);
|
|
||||||
restore_feedrate_and_scaling();
|
restore_feedrate_and_scaling();
|
||||||
|
|
||||||
if (isnan(measured_z)) {
|
if (isnan(measured_z)) {
|
||||||
|
@ -323,9 +311,10 @@ 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_ECHOLNPGM("Successfully calibrated probe.");
|
SERIAL_ECHOPGM("Successfully calibrated");
|
||||||
else
|
else
|
||||||
SERIAL_ECHOLNPGM("!Failed to calibrated probe.");
|
SERIAL_ECHOPGM("!Failed to calibrate");
|
||||||
|
SERIAL_ECHOLNPGM(" probe.");
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
thermalManager.setTargetBed(0);
|
thermalManager.setTargetBed(0);
|
||||||
|
|
Loading…
Reference in a new issue