Buildbotics CNC Controller Firmware Change Log
==============================================
+## v0.3.16
+ - Fixed switch debounce bug.
+
## v0.3.15
- Suppress warning missing config.json warning after config reset.
- Fixed EStop reboot loop.
{
"name": "bbctrl",
- "version": "0.3.15",
+ "version": "0.3.16",
"homepage": "http://buildbotics.com/",
"repository": "https://github.com/buildbotics/bbctrl-firmware",
"license": "GPL-3.0+",
#include "config.h"
#include <stdbool.h>
+#include <stdio.h>
typedef struct {
// Debounce switch
bool state = IN_PIN(s->pin);
- if (state == s->state) s->debounce = 0;
+ if (state == s->state && s->initialized) s->debounce = 0;
else if ((state && ++s->debounce == SWITCH_DEBOUNCE) ||
(!state && --s->debounce == -SWITCH_DEBOUNCE)) {
s->state = state;
bool switch_is_active(switch_id_t sw) {
- if (sw < 0 || num_switches <= sw) return false;
-
- if (!switches[sw].initialized) return false;
+ if (sw < 0 || num_switches <= sw || !switches[sw].initialized) return false;
// NOTE, switch inputs are active lo
switch (switches[sw].type) {
- case SW_DISABLED: break; // A disabled switch cannot be active
- case SW_NORMALLY_OPEN: return !switches[sw].state;
+ case SW_DISABLED: break; // A disabled switch cannot be active
+ case SW_NORMALLY_OPEN: return !switches[sw].state;
case SW_NORMALLY_CLOSED: return switches[sw].state;
}
+
return false;
}
for motor in range(6):
if not ('%dan' % motor) in self.vars: continue
motor_axis = 'xyzabc'[self.vars['%dan' % motor]]
- if motor_axis == axis.lower() and self.vars['%dpm' % motor]:
+ if motor_axis == axis.lower() and self.vars.get('%dpm' % motor, 0):
return motor