cleanup global var and push probe mode into probe_get_state
This commit is contained in:
12
probe.c
12
probe.c
@ -37,22 +37,22 @@ void probe_init()
|
||||
PROBE_PORT |= PROBE_MASK; // Enable internal pull-up resistors. Normal high operation.
|
||||
probe_invert_mask = PROBE_MASK;
|
||||
}
|
||||
|
||||
sys.probe_away = false;
|
||||
}
|
||||
|
||||
|
||||
// Returns the probe pin state. Triggered = true. Called by gcode parser and probe state monitor.
|
||||
uint8_t probe_get_state() { return((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask); }
|
||||
|
||||
uint8_t probe_get_state(uint8_t mode) {
|
||||
mode = ((mode >> PROBE_AWAY_BIT) & 1) << PROBE_BIT;
|
||||
return mode ^ ((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask);
|
||||
}
|
||||
|
||||
// Monitors probe pin state and records the system position when detected. Called by the
|
||||
// stepper ISR per ISR tick.
|
||||
// NOTE: This function must be extremely efficient as to not bog down the stepper ISR.
|
||||
void probe_state_monitor()
|
||||
{
|
||||
if (sys.probe_state == PROBE_ACTIVE) {
|
||||
if ((sys.probe_away << PROBE_BIT) ^ probe_get_state()) {
|
||||
if (sys.probe_state != PROBE_OFF) {
|
||||
if (probe_get_state(sys.probe_state)) {
|
||||
sys.probe_state = PROBE_OFF;
|
||||
memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS);
|
||||
bit_true(sys.execute, EXEC_FEED_HOLD);
|
||||
|
Reference in New Issue
Block a user