From 6e40102f268cae43ace5e09db77a95674616adec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 8 Oct 2022 17:07:16 +0200 Subject: [PATCH 1/3] - use bigger screen fonts on Wiphone - erase oldest entry from NodeDB if it is full. --- src/graphics/Screen.cpp | 2 +- src/mesh/NodeDB.cpp | 20 ++++++++++++++++---- src/modules/CannedMessageModule.cpp | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 53405e757..601b83f9c 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -97,7 +97,7 @@ static uint16_t displayWidth, displayHeight; #define SCREEN_WIDTH displayWidth #define SCREEN_HEIGHT displayHeight -#if defined(USE_EINK) || defined(ILI9341_DRIVER) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) // The screen is bigger so use bigger fonts #define FONT_SMALL ArialMT_Plain_16 #define FONT_MEDIUM ArialMT_Plain_24 diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index fca3af305..92115d127 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -699,11 +699,23 @@ NodeInfo *NodeDB::getOrCreateNode(NodeNum n) if (!info) { if (*numNodes >= MAX_NUM_NODES) { - screen->print("error: node_db full!\n"); - DEBUG_MSG("ERROR! could not create new node, node_db is full! (%d nodes)", *numNodes); - return NULL; + screen->print("warning: node_db full! erasing oldest entry\n"); + // look for oldest node and erase it + uint32_t oldest = UINT32_MAX; + int oldestIndex = -1; + for (int i = 0; i < *numNodes; i++) { + if (nodes[i].last_heard < oldest) { + oldest = nodes[i].last_heard; + oldestIndex = i; + } + } + // Shove the remaining nodes down the chain + for (int i = oldestIndex; i < *numNodes - 1; i++) { + nodes[i] = nodes[i + 1]; + } + (*numNodes)--; } - // add the node + // add the node at the end info = &nodes[(*numNodes)++]; // everything is missing except the nodenum diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 54804859b..a21b63779 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -11,7 +11,7 @@ #include "graphics/fonts/OLEDDisplayFontsRU.h" #endif -#if defined(USE_EINK) || defined(ILI9341_DRIVER) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) // The screen is bigger so use bigger fonts #define FONT_SMALL ArialMT_Plain_16 #define FONT_MEDIUM ArialMT_Plain_24 From b2d753ed866ebd4cbb98da1b95a3b41b40be28be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 8 Oct 2022 17:36:39 +0200 Subject: [PATCH 2/3] move and repeat i2c scan to fix BLE PIN --- src/main.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 95da04014..c3f892bce 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -233,6 +233,8 @@ void setup() delay(1); #endif + // We need to scan here to decide if we have a screen for nodeDB.init() + scanI2Cdevice(); #ifdef RAK4630 // scanEInkDevice(); #endif @@ -273,10 +275,12 @@ void setup() power->setup(); // Must be after status handler is installed, so that handler gets notified of the initial configuration /* - * Move the scanning I2C device to the back of power initialization. - * Some boards need to be powered on to correctly scan to the device address, such as t-beam-s3-core + * Repeat the scanning for I2C devices after power initialization. + * Boards with an PMU need to be powered on to correctly scan to the device address, such as t-beam-s3-core */ - scanI2Cdevice(); + if ((HW_VENDOR == HardwareModel_LILYGO_TBEAM_S3_CORE) || (HW_VENDOR == HardwareModel_TBEAM)) { + scanI2Cdevice(); + } // Init our SPI controller (must be before screen and lora) initSPI(); From ee1ae627a386eb6113f463f981e7750f21c13088 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Sat, 8 Oct 2022 19:10:50 +0200 Subject: [PATCH 3/3] Model the time it is busy receiving/transmitting (#1776) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Thomas Göttgens --- src/platform/portduino/SimRadio.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/platform/portduino/SimRadio.cpp b/src/platform/portduino/SimRadio.cpp index ccfaa3b03..b3af114e5 100644 --- a/src/platform/portduino/SimRadio.cpp +++ b/src/platform/portduino/SimRadio.cpp @@ -171,6 +171,8 @@ void SimRadio::onNotify(uint32_t notification) // Packet has been sent, count it toward our TX airtime utilization. uint32_t xmitMsec = getPacketTime(txp); airTime->logAirtime(TX_LOG, xmitMsec); + + delay(xmitMsec); // Model the time it is busy sending completeSending(); } } @@ -207,6 +209,9 @@ void SimRadio::startSend(MeshPacket * txp) void SimRadio::startReceive(MeshPacket *p) { isReceiving = true; + size_t length = getPacketLength(p); + uint32_t xmitMsec = getPacketTime(length); + delay(xmitMsec); // Model the time it is busy receiving handleReceiveInterrupt(p); }