12345678910111213141516171819202122232425262728293031323334353637383940 |
- #pragma once
- #ifndef _BUTTONS_H_
- #define _BUTTONS_H_
- /* time constant in ms */
- #define BTN_SCAN_PERIOD 10
- #define BTN_SCAN_PAUSE (200/BTN_SCAN_PERIOD)
- #define BTN_TIME_PRESSED (30/BTN_SCAN_PERIOD)
- #define BTN_TIME_HOLDED (500/BTN_SCAN_PERIOD)
- #define BTN_TIME_REPEATED (50/BTN_SCAN_PERIOD)
- #define BUTTON_PRESSED PAL_LOW
- /* type defs */
- typedef enum btn_num {
- Button1 = 0,
- Button2 = 1,
- Button_Num = 2
- } button_num_t;
- typedef enum btn_state {
- BTN_st_Clear = 0,
- BTN_st_Pressed,
- BTN_st_Holded,
- BTN_st_Released
- } button_state_t;
- /* Handler function type */
- typedef void (*btn_hndlr)(const button_state_t);
- /* function prototypes */
- #ifdef __cplusplus
- extern "C" {
- #endif
- void buttons_Init(btn_hndlr ha[]);
- button_state_t buttons_GetState(const button_num_t btn);
- #ifdef __cplusplus
- }
- #endif
- #endif /* _BUTTONS_H_ */
|