1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #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)
- /* type defs */
- typedef enum btn_num {
- Button1 = 0,
- Button2 = 1,
- Button3 = 2,
- Button4 = 3,
- Button_Num = 4
- } 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_ */
|