main.ino 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <TFT_eSPI.h>
  2. #include "config.h"
  3. #include "display.h"
  4. static TFT_eSPI tft = TFT_eSPI();
  5. static bool lastSelectState = false;
  6. // ---------------------------------------------------------------------------
  7. // Show the correct screen for the current input state
  8. // ---------------------------------------------------------------------------
  9. static void applyState(bool sysSelect) {
  10. // HIGH = System A
  11. // LOW = System B
  12. if (sysSelect) {
  13. displayShowSystemA(tft);
  14. } else {
  15. displayShowSystemB(tft);
  16. }
  17. }
  18. void setup() {
  19. // System select input — internal pull-up so the pin has a defined level
  20. // when nothing is connected (defaults to HIGH = System A)
  21. pinMode(PIN_SYS_SELECT, INPUT_PULLUP);
  22. // Backlight on
  23. pinMode(PIN_TFT_BL, OUTPUT);
  24. digitalWrite(PIN_TFT_BL, HIGH);
  25. displayInit(tft);
  26. displayShowLogo(tft); // animation handles its own 10 s timing
  27. lastSelectState = digitalRead(PIN_SYS_SELECT);
  28. applyState(lastSelectState);
  29. }
  30. void loop() {
  31. bool state = digitalRead(PIN_SYS_SELECT);
  32. if (state != lastSelectState) {
  33. lastSelectState = state;
  34. applyState(state);
  35. }
  36. delay(POLL_INTERVAL_MS);
  37. }