buttons.h 872 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #ifndef _BUTTONS_H_
  3. #define _BUTTONS_H_
  4. /* Events */
  5. #define EVT_BTN1_PRS EVENT_MASK(0)
  6. #define EVT_BTN2_PRS EVENT_MASK(1)
  7. #define EVT_BTN3_PRS EVENT_MASK(2)
  8. #define EVT_BTN4_PRS EVENT_MASK(3)
  9. /* time constant in ms */
  10. #define BTN_SCAN_PERIOD 10
  11. #define BTN_SCAN_PAUSE 200
  12. #define BTN_TIME_PRESSED 30
  13. #define BTN_TIME_HOLDED 500
  14. #define BTN_TIME_REPEATED 50
  15. #define BUTTON_NUMS 4
  16. /* type defs */
  17. typedef enum btn_num {
  18. Button1 = 0,
  19. Button2 = 1,
  20. Button3 = 2,
  21. Button4 = 3
  22. } button_num_t;
  23. typedef enum btn_state {
  24. BTN_st_Clear = 0,
  25. BTN_st_Pressed,
  26. BTN_st_Holded,
  27. BTN_st_Released
  28. } button_state_t;
  29. /* function prototypes */
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. void buttons_Init(thread_t * thread);
  34. button_state_t buttons_GetState(const button_num_t btn);
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif /* _BUTTONS_H_ */