Encapsulate probe as singleton class (#16751)

This commit is contained in:
Scott Lahteine
2020-02-01 04:21:36 -06:00
committed by GitHub
parent 43d3463d5d
commit 90b6324563
33 changed files with 341 additions and 303 deletions

View File

@@ -40,8 +40,8 @@
*/
void GcodeSuite::G30() {
const xy_pos_t pos = { parser.linearval('X', current_position.x + probe_offset_xy.x),
parser.linearval('Y', current_position.y + probe_offset_xy.y) };
const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x),
parser.linearval('Y', current_position.y + probe.offset_xy.y) };
if (!position_is_reachable_by_probe(pos)) return;
@@ -53,14 +53,14 @@ void GcodeSuite::G30() {
remember_feedrate_scaling_off();
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
const float measured_z = probe_at_point(pos, raise_after, 1);
const float measured_z = probe.probe_at_point(pos, raise_after, 1);
if (!isnan(measured_z))
SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", FIXFLOAT(measured_z));
restore_feedrate_and_scaling();
#ifdef Z_AFTER_PROBING
if (raise_after == PROBE_PT_STOW) move_z_after_probing();
if (raise_after == PROBE_PT_STOW) probe.move_z_after_probing();
#endif
report_current_position();

View File

@@ -30,11 +30,11 @@
/**
* G31: Deploy the Z probe
*/
void GcodeSuite::G31() { DEPLOY_PROBE(); }
void GcodeSuite::G31() { probe.deploy(); }
/**
* G32: Stow the Z probe
*/
void GcodeSuite::G32() { STOW_PROBE(); }
void GcodeSuite::G32() { probe.stow(); }
#endif // Z_PROBE_SLED

View File

@@ -32,7 +32,7 @@
* M401: Deploy and activate the Z probe
*/
void GcodeSuite::M401() {
DEPLOY_PROBE();
probe.deploy();
report_current_position();
}
@@ -40,9 +40,9 @@ void GcodeSuite::M401() {
* M402: Deactivate and stow the Z probe
*/
void GcodeSuite::M402() {
STOW_PROBE();
probe.stow();
#ifdef Z_AFTER_PROBING
move_z_after_probing();
probe.move_z_after_probing();
#endif
report_current_position();
}

View File

@@ -39,17 +39,17 @@ void GcodeSuite::M851() {
if (!parser.seen("XYZ")) {
SERIAL_ECHOLNPAIR_P(
#if HAS_PROBE_XY_OFFSET
PSTR(MSG_PROBE_OFFSET " X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR
PSTR(MSG_PROBE_OFFSET " X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR
#else
PSTR(MSG_PROBE_OFFSET " X0 Y0 Z")
#endif
, probe_offset.z
, probe.offset.z
);
return;
}
// Start with current offsets and modify
xyz_pos_t offs = probe_offset;
xyz_pos_t offs = probe.offset;
// Assume no errors
bool ok = true;
@@ -93,7 +93,7 @@ void GcodeSuite::M851() {
}
// Save the new offsets
if (ok) probe_offset = offs;
if (ok) probe.offset = offs;
}
#endif // HAS_BED_PROBE