An ESP32-based Redis-watcher and info-displayer https://rpjios.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.4 KiB

  1. #ifndef __ZW_DISPLAYS__H__
  2. #define __ZW_DISPLAYS__H__
  3. #include <TM1637Display.h>
  4. #include <Arduino.h>
  5. #include <functional>
  6. #define LED_BLTIN_H LOW
  7. #define LED_BLTIN_L HIGH
  8. #define LED_BLTIN 2
  9. #define LAT_FUNC micros
  10. class DisplaySpec;
  11. struct InfoSpec
  12. {
  13. const char *listKey;
  14. int startIdx;
  15. int endIdx;
  16. double lastTs;
  17. int lastVal;
  18. std::function<int(int)> adjFunc;
  19. std::function<void(DisplaySpec *)> dispFunc;
  20. };
  21. struct DisplaySpec
  22. {
  23. int clockPin;
  24. int dioPin;
  25. TM1637Display *disp;
  26. InfoSpec spec;
  27. };
  28. DisplaySpec *zwdisplayInit(String &hostname);
  29. void updateDisplay(DisplaySpec *disp);
  30. void blink(int d = 50);
  31. void runAnimation(TM1637Display *d, String animation, bool cE = false, int s = 0);
  32. void demoMode(DisplaySpec* displayListStart);
  33. String displayConfigAsJson(DisplaySpec* displayListStart);
  34. #define EXEC_ALL_DISPS(DISPLIST_START, EXEC_ME) \
  35. do \
  36. { \
  37. for (DisplaySpec *walk = DISPLIST_START; walk->clockPin != -1 && walk->dioPin != -1; walk++) \
  38. walk->disp->EXEC_ME; \
  39. } while (0)
  40. #endif