61 lines
2.0 KiB
C++
61 lines
2.0 KiB
C++
/*
|
|
* Performance Monitor
|
|
*
|
|
* Measures what the display pipeline actually does, so display experiments
|
|
* (bounce buffers, draw-buffer size, XIP from PSRAM - wiki open question #13)
|
|
* can be compared with numbers instead of impressions:
|
|
*
|
|
* - render frames/s and ms per frame (LVGL's monitor_cb: render + flush)
|
|
* - time spent copying pixels into the PSRAM framebuffer (flush_cb)
|
|
* - LVGL task idle % (lv_timer_get_idle)
|
|
* - CPU idle % per core (FreeRTOS run-time stats)
|
|
* - internal heap, largest block, PSRAM free
|
|
*
|
|
* Console:
|
|
* perf one line for the last window
|
|
* perf on [sec] print a PERF, line every <sec> s (default 1) - use while
|
|
* provoking symptoms (Wi-Fi scan, tuning save, OTA)
|
|
* perf off
|
|
*
|
|
* PERF line (CSV, greppable like CANRAW):
|
|
* PERF,<ts_ms>,<fps>,<avg_ms>,<max_ms>,<kpx/frame>,<flush_ms/s>,
|
|
* <lvgl_idle%>,<idle0%>,<idle1%>,<int_free>,<int_largest>,<psram_free>,
|
|
* <vsync/s>,<vsync_gap_max_us>
|
|
* vsync/s is the panel's own refresh rate (constant when healthy);
|
|
* vsync_gap_max_us is the longest interval between two refreshes in the
|
|
* window - a DMA underrun/restart stretches it.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
namespace PerfMon {
|
|
|
|
/** Call once in setup(), before the LVGL port starts. */
|
|
void init();
|
|
|
|
/** Hook for lv_disp_drv_t::monitor_cb - one rendered frame (ms, pixels). */
|
|
void onFrame(uint32_t time_ms, uint32_t px);
|
|
|
|
/** Hook for the flush callback - one pixel copy into the framebuffer. */
|
|
void onFlush(uint32_t time_us, uint32_t px);
|
|
|
|
/**
|
|
* Hook for the RGB panel's refresh-finished (vsync) interrupt. ISR context:
|
|
* counts frames the panel actually completed and the longest gap between two,
|
|
* which is where a DMA underrun / restart (flicker, dots) shows up.
|
|
*/
|
|
void onVsync();
|
|
|
|
/** Console line beginning with "perf". */
|
|
bool handleCommand(const char* line);
|
|
|
|
/**
|
|
* Kept for compatibility; periodic reporting now runs from an esp_timer so it
|
|
* survives a blocked loop() (the OTA job). Safe to call, does nothing.
|
|
*/
|
|
void tick();
|
|
|
|
} // namespace PerfMon
|