rendering metrics

This commit is contained in:
Dejvino
2026-11-17 07:39:14 +01:00
parent 34384ac4d8
commit 64992878e5
+27
View File
@@ -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);