PageRenderTime 85ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/stm32/libraries/Keys/src/Keys.h

https://codeberg.org/Gruenstreifen-eV/BSFrance-stm32
C Header | 52 lines | 43 code | 9 blank | 0 comment | 0 complexity | 4674608778fd7dcc78b48261cd038dfd MD5 | raw file
Possible License(s): MIT, GPL-2.0
  1. #ifndef __KEYS_H__
  2. #define __KEYS_H__
  3. #ifdef __cplusplus
  4. #define KEY0 bit(0)
  5. #define KEY1 bit(1)
  6. #define KEY2 bit(2)
  7. #define KEY3 bit(3)
  8. #define KEY4 bit(4)
  9. #define KEY5 bit(5)
  10. #define KEY6 bit(6)
  11. #define KEY7 bit(7)
  12. #define KEY_UNPRESED 0
  13. #define KEY_PRESED 1
  14. typedef enum
  15. {
  16. BUTTON_MODE_GPIO = 0,
  17. BUTTON_MODE_EXTI = 1
  18. }ButtonMode_TypeDef;
  19. typedef struct {
  20. uint8_t pins[16]; /**< pin max 16*/
  21. uint8_t nr; /**< keys num. */
  22. uint16_t on; /**< on state, 1 high or 0 low on. */
  23. uint16_t mode; /*mode bit 1/0 exti/gpio*/
  24. } BOTTON_TypeDef;
  25. class BOTTONClass
  26. {
  27. public:
  28. BOTTONClass();
  29. BOTTONClass(uint16_t mask, uint8_t k0,
  30. uint8_t k1=0xff, uint8_t k2=0xff, uint8_t k3=0xff,
  31. uint8_t k4=0xff, uint8_t k5=0xff, uint8_t k6=0xff, uint8_t k7=0xff,
  32. uint8_t k8=0xff, uint8_t k9=0xff, uint8_t k10=0xff,uint8_t k11=0xff,
  33. uint8_t k12=0xff,uint8_t k13=0xff,uint8_t k14=0xff,uint8_t k15=0xff);
  34. void setKey(uint8_t pin,uint16_t on,ButtonMode_TypeDef mode = BUTTON_MODE_GPIO);
  35. void Init();
  36. uint8_t getKey(uint8_t key);
  37. uint16_t scan(uint8_t mode = 1);
  38. BOTTON_TypeDef *pdata = &bottons;
  39. private:
  40. BOTTON_TypeDef bottons;
  41. };
  42. #endif
  43. #endif