1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| #include "bsp_key.h"
struct Button btn1; struct Button btn2;
void GPIO_KEY_Init(void) { }
uint8_t read_button1_GPIO() { return HAL_GPIO_ReadPin(xxx1_GPIO_Port, xxx1_Pin); }
uint8_t read_button2_GPIO() { return HAL_GPIO_ReadPin(xxx2_GPIO_Port, xxx2_Pin); }
void MultiButton_Init(void) { button_init(&btn1, read_button1_GPIO, 0); button_init(&btn2, read_button2_GPIO, 0);
button_attach(&btn1, PRESS_DOWN, BTN1_PRESS_DOWN_Handler); button_attach(&btn1, PRESS_UP, BTN1_PRESS_UP_Handler); button_attach(&btn1, PRESS_REPEAT, BTN1_PRESS_REPEAT_Handler); button_attach(&btn1, SINGLE_CLICK, BTN1_SINGLE_Click_Handler); button_attach(&btn1, DOUBLE_CLICK, BTN1_DOUBLE_Click_Handler); button_attach(&btn1, LONG_PRESS_START, BTN1_LONG_PRESS_START_Handler); button_attach(&btn1, LONG_PRESS_HOLD, BTN1_LONG_PRESS_HOLD_Handler);
button_attach(&btn2, PRESS_DOWN, BTN2_PRESS_DOWN_Handler); button_attach(&btn2, PRESS_UP, BTN2_PRESS_UP_Handler); button_attach(&btn2, PRESS_REPEAT, BTN2_PRESS_REPEAT_Handler); button_attach(&btn2, SINGLE_CLICK, BTN2_SINGLE_Click_Handler); button_attach(&btn2, DOUBLE_CLICK, BTN2_DOUBLE_Click_Handler); button_attach(&btn2, LONG_PRESS_START, BTN2_LONG_PRESS_START_Handler); button_attach(&btn2, LONG_PRESS_HOLD, BTN2_LONG_PRESS_HOLD_Handler); button_start(&btn1); button_start(&btn2); }
void BTN1_PRESS_DOWN_Handler(void* btn) { }
void BTN1_PRESS_UP_Handler(void* btn) { }
|