| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #include <TFT_eSPI.h>
- #include "config.h"
- #include "display.h"
- static TFT_eSPI tft = TFT_eSPI();
- static bool lastSelectState = false;
- static bool screenBlanked = false;
- static unsigned long sysAStartMs = 0;
- // ---------------------------------------------------------------------------
- // Show the correct screen for the current input state
- // ---------------------------------------------------------------------------
- static void applyState(bool sysSelect) {
- screenBlanked = false;
- if (sysSelect) {
- // System A — show screen and start the blank timer
- displayShowSystemA(tft);
- sysAStartMs = millis();
- } else {
- // System B — show screen, no blank timer
- displayShowSystemB(tft);
- }
- }
- void setup() {
- // Internal pull-up: pin floating defaults to HIGH = System A
- pinMode(PIN_SYS_SELECT, INPUT_PULLUP);
- displayInit(tft);
- displayShowLogo(tft);
- displayShowSplash(tft);
- lastSelectState = digitalRead(PIN_SYS_SELECT);
- applyState(lastSelectState);
- }
- void loop() {
- bool state = digitalRead(PIN_SYS_SELECT);
- if (state != lastSelectState) {
- lastSelectState = state;
- applyState(state);
- }
- // Blank screen after timeout when sitting on System A
- if (lastSelectState && !screenBlanked) {
- if (millis() - sysAStartMs >= BLANK_TIMEOUT_MS) {
- displayBlank(tft);
- screenBlanked = true;
- }
- }
- delay(POLL_INTERVAL_MS);
- }
|