| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include <TFT_eSPI.h>
- #include "config.h"
- #include "display.h"
- static TFT_eSPI tft = TFT_eSPI();
- static bool lastSelectState = false;
- // ---------------------------------------------------------------------------
- // Show the correct screen for the current input state
- // ---------------------------------------------------------------------------
- static void applyState(bool sysSelect) {
- // HIGH = System A
- // LOW = System B
- if (sysSelect) {
- displayShowSystemA(tft);
- } else {
- displayShowSystemB(tft);
- }
- }
- void setup() {
- // System select input — internal pull-up so the pin has a defined level
- // when nothing is connected (defaults to HIGH = System A)
- pinMode(PIN_SYS_SELECT, INPUT_PULLUP);
- // Backlight on
- pinMode(PIN_TFT_BL, OUTPUT);
- digitalWrite(PIN_TFT_BL, HIGH);
- displayInit(tft);
- displayShowLogo(tft); // animation handles its own 10 s timing
- lastSelectState = digitalRead(PIN_SYS_SELECT);
- applyState(lastSelectState);
- }
- void loop() {
- bool state = digitalRead(PIN_SYS_SELECT);
- if (state != lastSelectState) {
- lastSelectState = state;
- applyState(state);
- }
- delay(POLL_INTERVAL_MS);
- }
|