diff --git a/g2core/cycle_probing.cpp b/g2core/cycle_probing.cpp index 3f3db80f1..6bdd46324 100644 --- a/g2core/cycle_probing.cpp +++ b/g2core/cycle_probing.cpp @@ -81,9 +81,9 @@ static void _send_probe_report(void); ***********************************************************************************/ /*********************************************************************************** - * cm_probing_cycle_start() - G38.x probing cycle using contact (digital input) + * cm_straight_probe() - G38.x probing cycle using contact (digital input) * - * cm_probe_cycle_start() is the entry point for a probe cycle. It checks for + * cm_straight_probe() is the entry point for a probe cycle. It checks for * some errors, sets up the cycle, then prevents any new commands from queuing * to the planner so that the planner can move to a stop and report motion stopped. * @@ -261,6 +261,8 @@ static uint8_t _probing_start() return(_probing_exception_exit(STAT_PROBE_IS_ALREADY_TRIPPED)); } + en_clear_snapped(); + // Everything checks out. Run the probe move _probe_move(pb.target, pb.flags); pb.func = _probing_backoff; @@ -279,7 +281,7 @@ static stat_t _probing_backoff() // captured from the encoder in step space to steps to mm. The encoder snapshot // was taken by input interrupt at the time of closure. - if (pb.trip_sense == gpio_read_input(pb.probe_input)) { // exclusive or for booleans + if (en_get_snapped()) { cm->probe_state[0] = PROBE_SUCCEEDED; float contact_position[AXES]; kn_forward_kinematics(en_get_encoder_snapshot_vector(), contact_position); diff --git a/g2core/encoder.cpp b/g2core/encoder.cpp index 905a672db..9c4142b42 100644 --- a/g2core/encoder.cpp +++ b/g2core/encoder.cpp @@ -112,8 +112,15 @@ void en_take_encoder_snapshot() { en.snapshot[MOTOR_5] = en.en[MOTOR_5].encoder_steps + en.en[MOTOR_5].steps_run; en.snapshot[MOTOR_6] = en.en[MOTOR_6].encoder_steps + en.en[MOTOR_6].steps_run; */ + + en.snapped = true; } +void en_clear_snapped() { en.snapped = false; } + +bool en_get_snapped() { return en.snapped; } + + float en_get_encoder_snapshot_steps(uint8_t motor) { return (en.snapshot[motor]); } float* en_get_encoder_snapshot_vector() { return (en.snapshot); } diff --git a/g2core/encoder.h b/g2core/encoder.h index 1d1d0dc76..2c915c4a4 100644 --- a/g2core/encoder.h +++ b/g2core/encoder.h @@ -112,6 +112,7 @@ typedef struct enEncoder { // one real or virtual encoder per controlle typedef struct enEncoders { magic_t magic_start; + bool snapped; enEncoder_t en[MOTORS]; // runtime encoder structures float snapshot[MOTORS]; // snapshot vector magic_t magic_end; @@ -134,4 +135,7 @@ void en_take_encoder_snapshot(); float en_get_encoder_snapshot_steps(uint8_t motor); float* en_get_encoder_snapshot_vector(); +void en_clear_snapped(); +bool en_get_snapped(); + #endif // End of include guard: ENCODER_H_ONCE