diff --git a/src/Power.cpp b/src/Power.cpp index 4118dac538..3a2bea10c2 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -868,7 +868,6 @@ void Power::reboot() Wire.end(); Serial1.end(); if (screen) { - delete screen; screen = nullptr; } LOG_DEBUG("final reboot!"); diff --git a/src/detect/ReClockI2C.h b/src/detect/ReClockI2C.h index c8a81fb092..503f1a48b1 100644 --- a/src/detect/ReClockI2C.h +++ b/src/detect/ReClockI2C.h @@ -18,7 +18,7 @@ Only for cases where we can know it (ESP32 or known screen) we can do this. */ -extern graphics::Screen *screen; +extern std::unique_ptr screen; class ReClockI2C { diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index ce93494089..776a14c589 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -6,6 +6,7 @@ #include "mesh/generated/meshtastic/config.pb.h" #include #include +#include #include #include @@ -842,6 +843,6 @@ class Screen : public concurrency::OSThread // Extern declarations for function symbols used in UIRenderer extern std::vector functionSymbol; extern std::string functionSymbolString; -extern graphics::Screen *screen; +extern std::unique_ptr screen; #endif diff --git a/src/graphics/draw/DebugRenderer.cpp b/src/graphics/draw/DebugRenderer.cpp index 5c755b9275..95a76c0e9d 100644 --- a/src/graphics/draw/DebugRenderer.cpp +++ b/src/graphics/draw/DebugRenderer.cpp @@ -38,7 +38,7 @@ using namespace meshtastic; // External variables -extern graphics::Screen *screen; +extern std::unique_ptr screen; extern PowerStatus *powerStatus; extern NodeStatus *nodeStatus; extern GPSStatus *gpsStatus; diff --git a/src/graphics/draw/MessageRenderer.cpp b/src/graphics/draw/MessageRenderer.cpp index af5ffe93dc..932dc773ed 100644 --- a/src/graphics/draw/MessageRenderer.cpp +++ b/src/graphics/draw/MessageRenderer.cpp @@ -23,7 +23,7 @@ // External declarations extern bool hasUnreadMessage; -extern graphics::Screen *screen; +extern std::unique_ptr screen; using graphics::Emote; using graphics::emotes; diff --git a/src/graphics/draw/NodeListRenderer.cpp b/src/graphics/draw/NodeListRenderer.cpp index 3a307398ef..5b4036a983 100644 --- a/src/graphics/draw/NodeListRenderer.cpp +++ b/src/graphics/draw/NodeListRenderer.cpp @@ -18,7 +18,7 @@ #include // Global screen instance -extern graphics::Screen *screen; +extern std::unique_ptr screen; #if defined(OLED_TINY) static uint32_t lastSwitchTime = 0; diff --git a/src/graphics/draw/UIRenderer.cpp b/src/graphics/draw/UIRenderer.cpp index 5656d78f29..aba2fb632a 100644 --- a/src/graphics/draw/UIRenderer.cpp +++ b/src/graphics/draw/UIRenderer.cpp @@ -28,7 +28,7 @@ #include // External variables -extern graphics::Screen *screen; +extern std::unique_ptr screen; #if defined(OLED_TINY) static uint32_t lastSwitchTime = 0; #endif diff --git a/src/main.cpp b/src/main.cpp index 29af4c5c57..7be7afa52e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -212,7 +212,7 @@ using namespace concurrency; volatile static const char slipstreamTZString[] = {USERPREFS_TZ_STRING}; // We always create a screen object, but we only init it if we find the hardware -graphics::Screen *screen = nullptr; +std::unique_ptr screen = nullptr; // Global power status meshtastic::PowerStatus *powerStatus = new meshtastic::PowerStatus(); @@ -966,15 +966,15 @@ void setup() if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) { #if defined(HAS_SPI_TFT) || defined(USE_EINK) || defined(USE_SPISSD1306) - screen = new graphics::Screen(screen_found, screen_model, screen_geometry); + screen = std::make_unique(screen_found, screen_model, screen_geometry); #elif defined(ARCH_PORTDUINO) if ((screen_found.port != ScanI2C::I2CPort::NO_I2C || portduino_config.displayPanel) && config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) { - screen = new graphics::Screen(screen_found, screen_model, screen_geometry); + screen = std::make_unique(screen_found, screen_model, screen_geometry); } #else if (screen_found.port != ScanI2C::I2CPort::NO_I2C) - screen = new graphics::Screen(screen_found, screen_model, screen_geometry); + screen = std::make_unique(screen_found, screen_model, screen_geometry); #endif } #endif // HAS_SCREEN diff --git a/src/main.h b/src/main.h index 98dcccc718..19b1bace0d 100644 --- a/src/main.h +++ b/src/main.h @@ -11,6 +11,7 @@ #include "mesh/generated/meshtastic/telemetry.pb.h" #include #include +#include #if defined(ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_BLUETOOTH #include "nimble/NimbleBluetooth.h" extern NimbleBluetooth *nimbleBluetooth; @@ -68,7 +69,7 @@ extern UdpMulticastHandler *udpHandler; #endif // Global Screen singleton. -extern graphics::Screen *screen; +extern std::unique_ptr screen; #if !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && !MESHTASTIC_EXCLUDE_ACCELEROMETER #include "motion/AccelerometerThread.h" diff --git a/src/mesh/udp/UdpMulticastHandler.h b/src/mesh/udp/UdpMulticastHandler.h index 5a949c91aa..37ab445244 100644 --- a/src/mesh/udp/UdpMulticastHandler.h +++ b/src/mesh/udp/UdpMulticastHandler.h @@ -21,7 +21,7 @@ class UdpMulticastHandler final { public: - UdpMulticastHandler() : isRunning(false) { udpIpAddress = IPAddress(224, 0, 0, 69); } + UdpMulticastHandler() : isRunning(false) { udpIpAddress = IPAddress(239, 0, 0, 69); } void start() { diff --git a/src/modules/TraceRouteModule.cpp b/src/modules/TraceRouteModule.cpp index 7cfe3259fd..c0cac7123c 100644 --- a/src/modules/TraceRouteModule.cpp +++ b/src/modules/TraceRouteModule.cpp @@ -12,7 +12,7 @@ #include "modules/TrafficManagementModule.h" #endif -extern graphics::Screen *screen; +extern std::unique_ptr screen; TraceRouteModule *traceRouteModule; diff --git a/src/motion/BMM150Sensor.cpp b/src/motion/BMM150Sensor.cpp index f48d20288b..4f4bf26c0d 100644 --- a/src/motion/BMM150Sensor.cpp +++ b/src/motion/BMM150Sensor.cpp @@ -4,7 +4,7 @@ #if !defined(MESHTASTIC_EXCLUDE_SCREEN) // screen is defined in main.cpp -extern graphics::Screen *screen; +extern std::unique_ptr screen; #endif BMM150Sensor::BMM150Sensor(ScanI2C::FoundDevice foundDevice) : MotionSensor::MotionSensor(foundDevice) {} diff --git a/src/motion/BMX160Sensor.cpp b/src/motion/BMX160Sensor.cpp index 863a23f57f..7052f39826 100755 --- a/src/motion/BMX160Sensor.cpp +++ b/src/motion/BMX160Sensor.cpp @@ -8,7 +8,7 @@ BMX160Sensor::BMX160Sensor(ScanI2C::FoundDevice foundDevice) : MotionSensor::Mot #if !defined(MESHTASTIC_EXCLUDE_SCREEN) // screen is defined in main.cpp -extern graphics::Screen *screen; +extern std::unique_ptr screen; #endif bool BMX160Sensor::init() diff --git a/src/motion/ICM20948Sensor.cpp b/src/motion/ICM20948Sensor.cpp index 3dd5a5e468..e0fc2c5a88 100755 --- a/src/motion/ICM20948Sensor.cpp +++ b/src/motion/ICM20948Sensor.cpp @@ -4,7 +4,7 @@ #if !defined(MESHTASTIC_EXCLUDE_SCREEN) // screen is defined in main.cpp -extern graphics::Screen *screen; +extern std::unique_ptr screen; #endif // Flag when an interrupt has been detected diff --git a/src/motion/MMC5983MASensor.cpp b/src/motion/MMC5983MASensor.cpp index d63420d92d..62fb1105e3 100644 --- a/src/motion/MMC5983MASensor.cpp +++ b/src/motion/MMC5983MASensor.cpp @@ -6,7 +6,7 @@ #include "detect/ScanI2CTwoWire.h" #if !defined(MESHTASTIC_EXCLUDE_SCREEN) -extern graphics::Screen *screen; +extern std::unique_ptr screen; #endif static constexpr float MMC5983MA_ZERO_FIELD = 131072.0f; diff --git a/src/motion/MotionSensor.cpp b/src/motion/MotionSensor.cpp index 878b4dd508..b1744ad923 100755 --- a/src/motion/MotionSensor.cpp +++ b/src/motion/MotionSensor.cpp @@ -45,7 +45,7 @@ CompassAccelSample latestCompassAccelSample; } // namespace // screen is defined in main.cpp -extern graphics::Screen *screen; +extern std::unique_ptr screen; MotionSensor::MotionSensor(ScanI2C::FoundDevice foundDevice) { diff --git a/variants/esp32/esp32-common.ini b/variants/esp32/esp32-common.ini index c039c7356a..72cc1966eb 100644 --- a/variants/esp32/esp32-common.ini +++ b/variants/esp32/esp32-common.ini @@ -5,7 +5,9 @@ custom_esp32_kind = custom_mtjson_part = platform = # TODO renovate - https://github.com/pioarduino/platform-espressif32/releases/download/55.03.39/platform-espressif32.zip + ; Using forked pioarduino to fix --force-reinstall CI issue + https://github.com/meshtastic/pioarduino-platform-espressif32/archive/refs/heads/55.03.39.zip + ; https://github.com/pioarduino/platform-espressif32/releases/download/55.03.39/platform-espressif32.zip ; https://github.com/pioarduino/platform-espressif32.git#develop platform_packages = # renovate: datasource=custom.pio depName=platformio/tool-mklittlefs packageName=platformio/tool/tool-mklittlefs