Breaking the whole thing into modules using C preprocessor macros.
[cerebrum.git] / inputs.c
blobec54842ebdd07cf9444b87a4fd479c0d3af340a1
2 #include "input_config.h"
3 #include "inputs.h"
5 uint8_t switch_last_state = 0;
6 int switch_debounce_timeout = 0;
8 void input_setup(void){
9 //FIXME set input DDRs
12 void input_loop(void){
13 //FIXME scan inputs
14 //switch_states[0] |= !!(PINH&0x02);
15 for(int i=0; i<INPUT_COUNT; i++){
16 debounce_timeouts[i]--;
17 //A #define for the debounce time would be great
18 if(debounce_timeouts[i] == 0){
19 uint8_t new_switch_state = switch_states[i]<<1;
20 if(!(switch_states[i]^new_switch_state)){
21 uart_putc('c');
22 uart_puthex(i);
23 uart_puthex(switch_states[i]&1);
24 debounce_timeouts[i] = 0xFF;
25 switch_states[i] = new_switch_state&3;