gadget-securevault/button.h

54 lines
1.1 KiB
C
Raw Permalink Normal View History

2019-10-27 07:30:03 +01:00
#ifndef BUTTON_H_INCLUDED
#define BUTTON_H_INCLUDED
void button_init(void);
int button_poll(void (*callback)(uint8_t press, int hold));
int input_get_swr(void);
#define N_BUTTONS 12
#define BUTTON_0 4
#define BUTTON_1 5
#define BUTTON_2 6
#define BUTTON_3 7
#define BUTTON_4 0
#define BUTTON_5 1
#define BUTTON_6 2
#define BUTTON_7 8
#define BUTTON_8 9
#define BUTTON_9 10
#define BUTTON_SCROLL 11
#define BUTTON_ENTER 3
static inline char bu2c(uint8_t btn)
{
switch(btn) {
case BUTTON_0:
return '0';
case BUTTON_1:
return '1';
case BUTTON_2:
return '2';
case BUTTON_3:
return '3';
case BUTTON_4:
return '4';
case BUTTON_5:
return '5';
case BUTTON_6:
return '6';
case BUTTON_7:
return '7';
case BUTTON_8:
return '8';
case BUTTON_9:
return '9';
case BUTTON_SCROLL:
return ' ';
case BUTTON_ENTER:
return '\r';
}
return 0;
}
#endif