cleanup global var and push probe mode into probe_get_state

This commit is contained in:
Elijah Insua
2014-09-22 13:29:02 -07:00
parent b89d194466
commit 5406fa939a
7 changed files with 38 additions and 35 deletions

12
probe.c
View File

@ -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);