docs/src/debugging/sysmon.rst
.. _sysmon:
The System Monitor module provides real-time monitoring of system performance metrics directly on your display. It supports both performance monitoring (CPU usage and FPS) and memory monitoring (used memory and fragmentation).
Dependencies
LV_USE_LABEL = 1 in lv_conf.hLV_USE_OBSERVER = 1 in lv_conf.hLV_USE_SYSMON = 1 in lv_conf.h.. _sysmon_usage:
Usage
Enable in lv_conf.h:
.. code-block:: c
/* Main sysmon enable */
#define LV_USE_SYSMON 1
/* Performance monitor (CPU% and FPS) */
#define LV_USE_PERF_MONITOR 1
/* Memory monitor (used + fragmentation) */
#define LV_USE_MEM_MONITOR 1
/* Optional: refresh period in ms */
#define LV_SYSMON_REFR_PERIOD_DEF 300
/* Optional: log to console instead of screen */
#define LV_USE_PERF_MONITOR_LOG_MODE 0
.. code-block:: c
/* Create generic monitor */
lv_obj_t * sysmon = lv_sysmon_create(lv_display_get_default());
/* Create performance monitor */
lv_sysmon_show_performance(NULL); /* NULL = default display */
/* Create memory monitor */
lv_sysmon_show_memory(NULL);
Tracks:
Display format:
.. code-block:: text
32 FPS, 45% CPU
8 ms
Where:
Pause and Resume
:cpp:expr:lv_sysmon_performance_pause(disp) pauses the perf monitor.
:cpp:expr:lv_sysmon_performance_resume(disp) resumes the perf monitor.
Displays:
Display format:
.. code-block:: text
24.8 kB (76%)
32.4 kB max, 18% frag.
Configure positions in lv_conf.h:
.. code-block:: c
/* Top-right corner */
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_TOP_RIGHT
/* Bottom-right corner */
#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
Implementation Details
Maintains:
sysmon_mem)Event-based collection:
.. container:: tighter-table-3
+----------------------+--------------------------------+
| Event | Measurement |
+======================+================================+
| LV_EVENT_REFR_START | Refresh interval start |
+----------------------+--------------------------------+
| LV_EVENT_REFR_READY | Record refresh duration |
+----------------------+--------------------------------+
| LV_EVENT_RENDER_START| Render time start |
+----------------------+--------------------------------+
| LV_EVENT_RENDER_READY| Record render duration |
+----------------------+--------------------------------+
| LV_EVENT_FLUSH_* | Measure flush operations |
+----------------------+--------------------------------+
perf_update_timer_cbmem_update_timer_cbLV_SYSMON_REFR_PERIOD_DEF)