From afc5d1fdeb721f21c2250a0b73cdef5269c9d85f Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 17 May 2025 18:25:22 -0500 Subject: [PATCH] Get MUI and legacy screen co-existing on Portduino --- src/PowerFSM.cpp | 6 ++++-- src/main.cpp | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index dbe4796cf..7e7494046 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -198,7 +198,8 @@ static void powerEnter() LOG_INFO("Loss of power in Powered"); powerFSM.trigger(EVENT_POWER_DISCONNECTED); } else { - screen->setOn(true); + if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR ) + screen->setOn(true); setBluetoothEnable(true); // within enter() the function getState() returns the state we came from @@ -221,7 +222,8 @@ static void powerIdle() static void powerExit() { - screen->setOn(true); + if (screen) + screen->setOn(true); setBluetoothEnable(true); // Mothballed: print change of power-state to device screen diff --git a/src/main.cpp b/src/main.cpp index 66fa8db05..fb9799a43 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -537,12 +537,6 @@ void setup() digitalWrite(AQ_SET_PIN, HIGH); #endif -#if HAS_TFT - if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_COLOR) { - tftSetup(); - } -#endif - // Currently only the tbeam has a PMU // PMU initialization needs to be placed before i2c scanning power = new Power(); @@ -767,6 +761,12 @@ void setup() // but we need to do this after main cpu init (esp32setup), because we need the random seed set nodeDB = new NodeDB; +#if HAS_TFT + if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_COLOR) { + tftSetup(); + } +#endif + // If we're taking on the repeater role, use NextHopRouter and turn off 3V3_S rail because peripherals are not needed if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) { router = new NextHopRouter(); @@ -955,7 +955,7 @@ void setup() defined(ST7789_CS) || defined(HX8357_CS) || defined(USE_ST7789) || defined(ILI9488_CS) screen->setup(); #elif defined(ARCH_PORTDUINO) - if (screen_found.port != ScanI2C::I2CPort::NO_I2C || settingsMap[displayPanel]) { + if ((screen_found.port != ScanI2C::I2CPort::NO_I2C || settingsMap[displayPanel]) && config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) { screen->setup(); } #else @@ -963,8 +963,9 @@ void setup() screen->setup(); #endif #endif - - screen->print("Started...\n"); + if (screen) { + screen->print("Started...\n"); + } #ifdef PIN_PWR_DELAY_MS // This may be required to give the peripherals time to power up.