diff --git a/bin/config-dist.yaml b/bin/config-dist.yaml index a241a929a2..22ca3e7db4 100644 --- a/bin/config-dist.yaml +++ b/bin/config-dist.yaml @@ -121,3 +121,6 @@ Logging: Webserver: # Port: 443 # Port for Webserver & Webservices # RootPath: /usr/share/doc/meshtasticd/web # Root Dir of WebServer + +General: + MaxNodes: 200 diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 7f20b56661..e6d801b195 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -71,7 +71,7 @@ namespace graphics // #define SHOW_REDRAWS // A text message frame + debug frame + all the node infos -static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES]; +FrameCallback *normalFrames; static uint32_t targetFramerate = IDLE_FRAMERATE; static char btPIN[16] = "888888"; @@ -893,6 +893,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_OledType screenType, OLEDDISPLAY_GEOMETRY geometry) : concurrency::OSThread("Screen"), address_found(address), model(screenType), geometry(geometry), cmdQueue(32) { + graphics::normalFrames = new FrameCallback[MAX_NUM_NODES + NUM_EXTRA_FRAMES]; #if defined(USE_SH1106) || defined(USE_SH1107) || defined(USE_SH1107_128_64) dispdev = new SH1106Wire(address.address, -1, -1, geometry, (address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE); @@ -931,6 +932,11 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O cmdQueue.setReader(this); } +Screen::~Screen() +{ + delete[] graphics::normalFrames; +} + /** * Prepare the display for the unit going to the lowest power mode possible. Most screens will just * poweroff, but eink screens will show a "I'm sleeping" graphic, possibly with a QR code diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index 69e858dd2a..a66cc44ecc 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -125,6 +125,8 @@ class Screen : public concurrency::OSThread public: explicit Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY); + ~Screen(); + Screen(const Screen &) = delete; Screen &operator=(const Screen &) = delete; diff --git a/src/mesh/PacketHistory.cpp b/src/mesh/PacketHistory.cpp index 9ecad47cd2..26a73a3fe8 100644 --- a/src/mesh/PacketHistory.cpp +++ b/src/mesh/PacketHistory.cpp @@ -2,6 +2,10 @@ #include "configuration.h" #include "mesh-pb-constants.h" +#ifdef ARCH_PORTDUINO +#include "platform/portduino/PortduinoGlue.h" +#endif + PacketHistory::PacketHistory() { recentPackets.reserve(MAX_NUM_NODES); // Prealloc the worst case # of records - to prevent heap fragmentation diff --git a/src/mesh/mesh-pb-constants.h b/src/mesh/mesh-pb-constants.h index 22a80c8e31..a044c8bd9e 100644 --- a/src/mesh/mesh-pb-constants.h +++ b/src/mesh/mesh-pb-constants.h @@ -16,7 +16,11 @@ #define MAX_RX_TOPHONE 32 /// max number of nodes allowed in the mesh +#if ARCH_PORTDUINO +#define MAX_NUM_NODES settingsMap[maxnodes] +#else #define MAX_NUM_NODES (member_size(meshtastic_DeviceState, node_db_lite) / member_size(meshtastic_DeviceState, node_db_lite[0])) +#endif /// Max number of channels allowed #define MAX_NUM_CHANNELS (member_size(meshtastic_ChannelFile, channels) / member_size(meshtastic_ChannelFile, channels[0])) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 997058406a..ee8bf21e99 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -199,6 +199,9 @@ void portduinoSetup() settingsMap[webserverport] = (yamlConfig["Webserver"]["Port"]).as(-1); settingsStrings[webserverrootpath] = (yamlConfig["Webserver"]["RootPath"]).as(""); } + if (yamlConfig["General"]) { + settingsMap[maxnodes] = (yamlConfig["General"]["MaxNodes"]).as(MAX_NUM_NODES); + } } catch (YAML::Exception e) { std::cout << "*** Exception " << e.what() << std::endl; diff --git a/src/platform/portduino/PortduinoGlue.h b/src/platform/portduino/PortduinoGlue.h index 3fe5f74bf0..505c436d60 100644 --- a/src/platform/portduino/PortduinoGlue.h +++ b/src/platform/portduino/PortduinoGlue.h @@ -36,7 +36,8 @@ enum configNames { logoutputlevel, webserver, webserverport, - webserverrootpath + webserverrootpath, + maxnodes }; enum { no_screen, st7789, st7735, st7735s, ili9341 }; enum { no_touchscreen, xpt2046, stmpe610 }; diff --git a/src/shutdown.h b/src/shutdown.h index 6449b129ee..21abba07ea 100644 --- a/src/shutdown.h +++ b/src/shutdown.h @@ -26,6 +26,8 @@ void powerCommandsCheck() SPI.end(); Wire.end(); Serial1.end(); + if (screen) + delete screen; reboot(); #else rebootAtMsec = -1;