Added a refactoring todo, re-added the debounce timeout in input.c
[cerebrum.git] / input.c
blob1c540ca109d8d0b64fda4c3232df21abdf9a36e0
2 #include "input.h"
3 #ifdef HAS_INPUT_SUPPORT
5 void input_setup(void){
8 void input_loop(void){
9 input_scan_inputs();
10 for(int i=0; i<INPUT_COUNT; i++){
11 //A #define for the debounce time would be great
12 if(debounce_timeouts[i] == 0){
13 if(switch_states[i]&1 ^ switch_states[i]>>1){
14 uart_putc('c');
15 uart_puthex(i);
16 uart_puthex(switch_states[i]&1);
17 uart_putc('\n');
18 debounce_timeouts[i] = 0xF0;
19 switch_states[i] = (switch_states[i]<<1)&3;
21 switch_states[i] &= 0xFE;
22 }else{
23 debounce_timeouts[i]--;
28 uint8_t debounce_timeouts[INPUT_COUNT];
29 uint8_t switch_states[INPUT_COUNT];
31 #else//HAS_INPUT_SUPPORT
33 void input_setup(){}
34 void input_loop(){}
36 #endif//HAS_INPUT_SUPPORT