From 64992878e572730ed53b379fca987bc8b075618a Mon Sep 17 00:00:00 2001 From: Dejvino Date: Tue, 17 Nov 2026 07:39:14 +0100 Subject: [PATCH] rendering metrics --- src/netdeck/NetDeck.ino | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/netdeck/NetDeck.ino b/src/netdeck/NetDeck.ino index b8b7435..cad43bb 100644 --- a/src/netdeck/NetDeck.ino +++ b/src/netdeck/NetDeck.ino @@ -1938,6 +1938,21 @@ static void renderFreezeTint() static void render() { + // Frame start time for metrics + static uint32_t frameStart = millis(); + static uint32_t fpsTimer = 0; + static int frameCount = 0; + static uint32_t fps = 0; + + frameCount++; + if ((int32_t)(millis() - fpsTimer) >= 1000) { + fps = (frameCount * 1000) / (millis() - fpsTimer); + frameCount = 0; + fpsTimer = millis(); + } + frameStart = millis(); // prepare for next frame timing + + // --- Rendering --- renderMap(viewMode == VM_NETWORK); if (paused) renderFreezeTint(); renderNetwork(viewMode == VM_NETWORK); @@ -1956,8 +1971,20 @@ static void render() renderCursor(); renderBanner(); + + // --- Frame timing (every ~5s, print metrics to serial) --- + static uint32_t lastMetricsDump = 0; + if ((int32_t)(millis() - lastMetricsDump) >= 5000) { + lastMetricsDump = millis(); + // frameStart is updated at end of render(), so this is last frame duration + uint32_t ft = millis() - frameStart; + // Note: frameStart/frameCount/fps are static inside this function + // To print full stats, we'd need to make them global or print partial + Serial.printf("[metrics] FPS: ~%u | last frame: ~%u ms\n", fps, ft); + } } +// ── drawBoot ────────────────────────────────────────────────────────────── static void drawBoot() { GFXP->fillScreen(TFT_BLACK);