event.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #if !defined(_EVENT_H_)
  3. #define _EVENT_H_
  4. #include <stm32f10x.h>
  5. #define EV_KEY_TOUCH 0x0100
  6. #define EV_KEY_PRESSED 0x0200
  7. #define EV_KEY_LONG 0x0300
  8. #define EV_KEY_REPEATE 0x0400
  9. #define EV_KEY_REALIZED 0x0500
  10. #define EV_KEY_DOUBLE 0x0600
  11. #define EV_FUNC_FIRST 0x0700
  12. #define EV_MASK 0x0700
  13. extern uint16_t Event; /* 0xKKKKKAAA */
  14. /* AAA - it is event key. Event can be defined by & operation with EV_MASK*/
  15. /* KKKKKK - keys - one bit fpr one key. Up to 5 keys */
  16. volatile extern uint16_t EventQueue; /* for setting user event */
  17. extern uint16_t EncCounter; /* 0 - 4096 */
  18. extern uint16_t EncStep;
  19. extern uint16_t EncStepMax;
  20. extern uint16_t EncMax;
  21. #define ENC_MAX_DEFAULT 4095
  22. #define ENC_STEP_MAX_DEFAULT 200
  23. extern volatile uint8_t EvCounter; // Press delay counter
  24. typedef void (*MenuFunction_t)(void);
  25. extern MenuFunction_t CurrentFunction; // Current function
  26. #define CurrentFunc(MenuFunc) CurrentFunction = MenuFunc
  27. extern void EventInit(void);
  28. extern void EventKeys(void); /* This function is periodicaly called (e.g. from ISR) */
  29. extern void EventCheck(void); /* This function should be called to handele the event */
  30. /* Event detect delays */
  31. #define KEY_PRESSED_VALUE 4 // Press event delay
  32. #define KEY_LONG_VALUE 140 // Long press event delay
  33. #define KEY_REPEATE_VALUE 160 // Repeate event delay
  34. #define KEY_REALIZE_VALUE 8 // Realize event detect delay
  35. //#define KEY_DOUBLE_VALUE 40 // Double event detect delay. It should be more then REALIZE_KEY_VALUE and KEY_PRESSED_VALUE
  36. #define KEYPORT GPIOA->IDR
  37. #define KEY1 GPIO_IDR_IDR2
  38. #define KEY2 GPIO_IDR_IDR1
  39. #define KEY3 GPIO_IDR_IDR0
  40. #define KEY4 GPIO_IDR_IDR3
  41. #define KEY5 GPIO_IDR_IDR5
  42. #define KEY6 GPIO_IDR_IDR6
  43. #define KEY_MASK_SYS (KEY1)
  44. #define KEY_MASK (KEY1|KEY2|KEY3|KEY4|KEY5)
  45. #define KEY_ENTER KEY1 /* Encoder button */
  46. #define KEY_DOWN KEY2 /* Encoder down */
  47. #define KEY_UP KEY3 /* Encored event up */
  48. #define KEY_ADC KEY4 /* Adc ready */
  49. #define KEY_CLOCK KEY5 /* Second event */
  50. //#define KEY_GRAPH KEY6 /* Gpath update */
  51. #endif /* _EVENT_H_ */