From 4dbc5a528fc7f47006ea4f87a45c7ae2e5bac306 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Mon, 17 Jul 2017 13:33:06 -0700 Subject: [PATCH] Disabled switches cannot be active --- avr/src/plan/jog.c | 2 ++ avr/src/switch.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/avr/src/plan/jog.c b/avr/src/plan/jog.c index 631047a..38315b6 100644 --- a/avr/src/plan/jog.c +++ b/avr/src/plan/jog.c @@ -111,6 +111,8 @@ static float _compute_axis_velocity(int axis) { // Compute target accel float accel = sqrt(jerk * fabs(Vt - V)) * (Vt < V ? -1 : 1); + // TODO apply max accel here + // Compute max delta accel float deltaAccel = jerk * SEGMENT_TIME; diff --git a/avr/src/switch.c b/avr/src/switch.c index 3508cff..489c554 100644 --- a/avr/src/switch.c +++ b/avr/src/switch.c @@ -125,8 +125,12 @@ void switch_rtc_callback() { bool switch_is_active(int index) { - // A normally open switch drives the pin low when thrown - return (switches[index].type == SW_NORMALLY_OPEN) ^ switches[index].state; + switch (switches[index].type) { + case SW_DISABLED: break; // A disabled switch cannot be active + case SW_NORMALLY_OPEN: return !switches[index].state; + case SW_NORMALLY_CLOSED: return switches[index].state; + } + return false; } -- 2.27.0