gadget-securevault/button.h
Daniele Lacamera dee9335db4 Initial import
2019-11-02 12:59:53 +01:00

53 lines
1.1 KiB
C

#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