buttons.h 853 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. /* type defs */
  11. typedef enum btn_num {
  12. Button1 = 0,
  13. Button2 = 1,
  14. Button3 = 2,
  15. Button4 = 3,
  16. Button_Num = 4
  17. } button_num_t;
  18. typedef enum btn_state {
  19. BTN_st_Clear = 0,
  20. BTN_st_Pressed,
  21. BTN_st_Holded,
  22. BTN_st_Released
  23. } button_state_t;
  24. /* Handler function type */
  25. typedef void (*btn_hndlr)(const button_state_t);
  26. /* function prototypes */
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. void buttons_Init(btn_hndlr ha[]);
  31. button_state_t buttons_GetState(const button_num_t btn);
  32. #ifdef __cplusplus
  33. }
  34. #endif
  35. #endif /* _BUTTONS_H_ */