display.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "display.h"
  2. #include <TM1637Display.h>
  3. //#include "tm1637.h"
  4. #include <esp_system.h>
  5. const int display_clk = 21;
  6. const int display_dio = 22;
  7. TM1637Display display(display_clk, display_dio);
  8. //tm1637_led_t *lcd;
  9. void display_setup(void) {
  10. uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
  11. display.setBrightness(0x0a);
  12. display.setSegments(data);
  13. switch (esp_random() % 5) {
  14. case 0:
  15. display.showNumberDecEx(1223, 0b11100000, true); //Display the numCounter value;
  16. break;
  17. case 1:
  18. display.showNumberDecEx(2016, 0b11100000, true); //Display the numCounter value;
  19. break;
  20. case 2:
  21. display.showNumberDecEx(1998, 0b11100000, true); //Display the numCounter value;
  22. break;
  23. case 3:
  24. display.showNumberDecEx(8008, 0b11100000, true); //Display the numCounter value;
  25. break;
  26. case 4:
  27. display.showNumberDecEx(531, 0b11100000, false); //Display the numCounter value;
  28. break;
  29. case 5:
  30. display.showNumberDecEx(5537, 0b11100000, true); //Display the numCounter value;
  31. break;
  32. }
  33. return;
  34. }
  35. //see https://github.com/avishorp/TM1637/blob/master/examples/TM1637Test/TM1637Test.ino