From: Joseph Coffland Date: Mon, 17 Jul 2017 20:33:06 +0000 (-0700) Subject: Disabled switches cannot be active X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=4dbc5a528fc7f47006ea4f87a45c7ae2e5bac306;p=bbctrl-firmware Disabled switches cannot be active --- 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; }