DIY fertilizer mixer and plant watering machine https://www.xythobuz.de/giessomat.html
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2021 Thomas Buck <thomas@xythobuz.de>
  3. *
  4. * This file is part of Giess-o-mat.
  5. *
  6. * Giess-o-mat is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Giess-o-mat is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Giess-o-mat. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _KEYMATRIX_H_
  20. #define _KEYMATRIX_H_
  21. #ifdef FUNCTION_UI
  22. #include <CircularBuffer.h>
  23. class Keymatrix {
  24. public:
  25. class Event {
  26. public:
  27. enum EventType {
  28. button_down,
  29. button_up,
  30. no_event
  31. };
  32. Event(EventType _type, int _row, int _col);
  33. EventType getType(void);
  34. int getRow(void);
  35. int getCol(void);
  36. // helper for 4x3 telephone keypad
  37. // -1 is *, -2 is #, or digits 0-9
  38. int getNum(void);
  39. private:
  40. EventType type;
  41. int row, col;
  42. };
  43. Keymatrix(int _rows, int _cols);
  44. ~Keymatrix(void);
  45. // first rows, then cols
  46. void setPins(int _pins[]);
  47. void setDebounce(unsigned long ms);
  48. void scan(void);
  49. bool hasEvent(void);
  50. Event getEvent(void);
  51. private:
  52. unsigned long debounce;
  53. const static unsigned long default_debounce = 5;
  54. unsigned long last_scan_time;
  55. int rows, cols;
  56. int *pins;
  57. bool *lastPressed;
  58. bool *lastState;
  59. CircularBuffer<Event *, 32> events;
  60. };
  61. #endif // FUNCTION_UI
  62. #endif // _KEYMATRIX_H_