buttons.h 859 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #ifndef _BUTTONS_H_
  3. #define _BUTTONS_H_
  4. /* time constant in ms */
  5. #define BTN_SCAN_PERIOD 10
  6. #define BTN_SCAN_PAUSE (200/BTN_SCAN_PERIOD)
  7. #define BTN_TIME_PRESSED (30/BTN_SCAN_PERIOD)
  8. #define BTN_TIME_HOLDED (500/BTN_SCAN_PERIOD)
  9. #define BTN_TIME_REPEATED (50/BTN_SCAN_PERIOD)
  10. #define BUTTON_PRESSED PAL_LOW
  11. /* type defs */
  12. typedef enum btn_num {
  13. Button1 = 0,
  14. Button2 = 1,
  15. Button_Num = 2
  16. } button_num_t;
  17. typedef enum btn_state {
  18. BTN_st_Clear = 0,
  19. BTN_st_Pressed,
  20. BTN_st_Holded,
  21. BTN_st_Released
  22. } button_state_t;
  23. /* Handler function type */
  24. typedef void (*btn_hndlr)(const button_state_t);
  25. /* function prototypes */
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. void buttons_Init(btn_hndlr ha[]);
  30. button_state_t buttons_GetState(const button_num_t btn);
  31. #ifdef __cplusplus
  32. }
  33. #endif
  34. #endif /* _BUTTONS_H_ */