Disabled switches cannot be active
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Mon, 17 Jul 2017 20:33:06 +0000 (13:33 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Mon, 17 Jul 2017 20:35:58 +0000 (13:35 -0700)
avr/src/plan/jog.c
avr/src/switch.c

index 631047a6868a8b8b4b2e86ac5c2866fd85cb5329..38315b68acb8528dc7d2f9c50b75aef9e1c37927 100644 (file)
@@ -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;
 
index 3508cffc71980a27d7816e546ecdd34a5c35902e..489c5548e0e4ccda94aff0c745eea0c652070d5f 100644 (file)
@@ -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;
 }