Add perf console (render fps, flush cost, CPU idle, heap) for the display work; record idle baseline
Firmware / build (push) Successful in 4m8s

This commit is contained in:
2026-09-27 16:43:53 +02:00
parent 43ca6b96ec
commit d3e499efed
8 changed files with 277 additions and 4 deletions
+28 -1
View File
@@ -9,6 +9,8 @@
#define ESP_UTILS_LOG_TAG "LvPort"
#include "esp_lib_utils.h"
#include "lvgl_v8_port.h"
#include "modules/perf_monitor.h"
#include "esp_timer.h"
using namespace esp_panel::drivers;
@@ -478,14 +480,27 @@ void flush_callback(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color
const int offsetx2 = area->x2;
const int offsety1 = area->y1;
const int offsety2 = area->y2;
const int w = offsetx2 - offsetx1 + 1;
const int h = offsety2 - offsety1 + 1;
lcd->drawBitmap(offsetx1, offsety1, offsetx2 - offsetx1 + 1, offsety2 - offsety1 + 1, (const uint8_t *)color_map);
// Time the pixel copy into the (PSRAM) framebuffer - this is the PSRAM
// write cost the display experiments (open question #13) change.
const int64_t t0 = esp_timer_get_time();
lcd->drawBitmap(offsetx1, offsety1, w, h, (const uint8_t *)color_map);
PerfMon::onFlush((uint32_t)(esp_timer_get_time() - t0), (uint32_t)(w * h));
// For RGB LCD, directly notify LVGL that the buffer is ready
if (lcd->getBus()->getBasicAttributes().type == ESP_PANEL_BUS_TYPE_RGB) {
lv_disp_flush_ready(drv);
}
}
// LVGL calls this once per rendered frame (render + flush time, pixels drawn).
static void monitor_callback(lv_disp_drv_t *drv, uint32_t time_ms, uint32_t px)
{
(void)drv;
PerfMon::onFrame(time_ms, px);
}
static void update_callback(lv_disp_drv_t *drv)
{
LCD *lcd = (LCD *)drv->user_data;
@@ -605,6 +620,9 @@ static lv_disp_t *display_init(LCD *lcd)
ESP_UTILS_LOGD("Register display driver to LVGL");
lv_disp_drv_init(&disp_drv);
disp_drv.flush_cb = flush_callback;
#if LVGL_PORT_AVOID_TEARING_MODE == 0
disp_drv.monitor_cb = monitor_callback;
#endif
#if (LVGL_PORT_ROTATION_DEGREE == 90) || (LVGL_PORT_ROTATION_DEGREE == 270)
disp_drv.hor_res = lcd_height;
disp_drv.ver_res = lcd_width;
@@ -815,6 +833,15 @@ bool lvgl_port_lock(int timeout_ms)
return (xSemaphoreTakeRecursive(lvgl_mux, timeout_ticks) == pdTRUE);
}
bool lvgl_port_lock_available(void)
{
if (!lvgl_port_lock(0)) {
return false;
}
lvgl_port_unlock();
return true;
}
bool lvgl_port_unlock(void)
{
ESP_UTILS_CHECK_NULL_RETURN(lvgl_mux, false, "LVGL mutex is not initialized");
+8
View File
@@ -171,6 +171,14 @@ bool lvgl_port_lock(int timeout_ms);
*/
bool lvgl_port_unlock(void);
/**
* @brief Try the LVGL lock without waiting and release it at once.
* Used by the perf monitor to read lv_timer_get_idle() only when the
* UI task is not mid-render (the value is a plain int, so a stale read
* is harmless; a blocked console is not).
*/
bool lvgl_port_lock_available(void);
#ifdef __cplusplus
}
#endif