mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
refact(monitor): refact system monitor component (#4195)
Signed-off-by: FASTSHIFT <vifextech@foxmail.com>
This commit is contained in:
parent
42f70fecf0
commit
4658c27f37
13
Kconfig
13
Kconfig
@ -371,7 +371,7 @@ menu "LVGL configuration"
|
||||
menu "Others"
|
||||
config LV_USE_PERF_MONITOR
|
||||
bool "Show CPU usage and FPS count."
|
||||
depends on LV_USE_MONITOR
|
||||
depends on LV_USE_SYSMON
|
||||
|
||||
choice
|
||||
prompt "Performance monitor position."
|
||||
@ -398,10 +398,15 @@ menu "LVGL configuration"
|
||||
bool "Center"
|
||||
endchoice
|
||||
|
||||
config LV_USE_PERF_MONITOR_LOG_MODE
|
||||
bool "Prints performance data using log"
|
||||
depends on LV_USE_PERF_MONITOR
|
||||
default n
|
||||
|
||||
config LV_USE_MEM_MONITOR
|
||||
bool "Show the used memory and the memory fragmentation."
|
||||
depends on !LV_MEM_CUSTOM
|
||||
depends on LV_USE_MONITOR
|
||||
depends on LV_USE_SYSMON
|
||||
|
||||
choice
|
||||
prompt "Memory monitor position."
|
||||
@ -996,8 +1001,8 @@ menu "LVGL configuration"
|
||||
bool "Enable API to take snapshot"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
|
||||
config LV_USE_MONITOR
|
||||
bool "Enable Monitor component"
|
||||
config LV_USE_SYSMON
|
||||
bool "Enable system monitor component"
|
||||
default n
|
||||
|
||||
config LV_USE_MONKEY
|
||||
|
@ -279,16 +279,18 @@
|
||||
*-----------*/
|
||||
|
||||
/*1: Show CPU usage and FPS count
|
||||
* Requires `LV_USE_MONITOR = 1`*/
|
||||
* Requires `LV_USE_SYSMON = 1`*/
|
||||
#define LV_USE_PERF_MONITOR 0
|
||||
#if LV_USE_PERF_MONITOR
|
||||
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
|
||||
#define LV_USE_PERF_MONITOR_LOG_MDOE 0
|
||||
|
||||
/*0: Displays performance data on the screen, 1: Prints performance data using log.*/
|
||||
#define LV_USE_PERF_MONITOR_LOG_MODE 0
|
||||
#endif
|
||||
|
||||
/*1: Show the used memory and the memory fragmentation
|
||||
* Requires `LV_USE_BUILTIN_MALLOC = 1`
|
||||
* Requires `LV_USE_MONITOR = 1`*/
|
||||
* Requires `LV_USE_SYSMON = 1`*/
|
||||
#define LV_USE_MEM_MONITOR 0
|
||||
#if LV_USE_MEM_MONITOR
|
||||
#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
|
||||
@ -695,8 +697,8 @@
|
||||
/*1: Enable API to take snapshot for object*/
|
||||
#define LV_USE_SNAPSHOT 0
|
||||
|
||||
/*1: Enable Monitor component*/
|
||||
#define LV_USE_MONITOR 1
|
||||
/*1: Enable system monitor component*/
|
||||
#define LV_USE_SYSMON 0
|
||||
|
||||
/*1: Enable Monkey test*/
|
||||
#define LV_USE_MONKEY 0
|
||||
|
2
lvgl.h
2
lvgl.h
@ -76,11 +76,11 @@ extern "C" {
|
||||
#include "src/widgets/win/lv_win.h"
|
||||
|
||||
#include "src/others/snapshot/lv_snapshot.h"
|
||||
#include "src/others/sysmon/lv_sysmon.h"
|
||||
#include "src/others/monkey/lv_monkey.h"
|
||||
#include "src/others/gridnav/lv_gridnav.h"
|
||||
#include "src/others/fragment/lv_fragment.h"
|
||||
#include "src/others/imgfont/lv_imgfont.h"
|
||||
#include "src/others/monitor/lv_monitor.h"
|
||||
#include "src/others/msg/lv_msg.h"
|
||||
#include "src/others/ime/lv_ime_pinyin.h"
|
||||
#include "src/others/file_explorer/lv_file_explorer.h"
|
||||
|
@ -160,6 +160,10 @@ void lv_init(void)
|
||||
/*Initialize the screen refresh system*/
|
||||
_lv_refr_init();
|
||||
|
||||
#if LV_USE_SYSMON
|
||||
_lv_sysmon_builtin_init();
|
||||
#endif
|
||||
|
||||
_lv_img_decoder_init();
|
||||
|
||||
_lv_img_cache_builtin_init();
|
||||
|
@ -12,13 +12,10 @@
|
||||
#include "lv_disp_private.h"
|
||||
#include "../hal/lv_hal_tick.h"
|
||||
#include "../misc/lv_timer.h"
|
||||
#include "../misc/lv_mem.h"
|
||||
#include "../misc/lv_math.h"
|
||||
#include "../misc/lv_gc.h"
|
||||
#include "../draw/lv_draw.h"
|
||||
#include "../font/lv_font_fmt_txt.h"
|
||||
#include "../others/snapshot/lv_snapshot.h"
|
||||
#include "../others/monitor/lv_monitor.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -66,9 +63,6 @@ static lv_disp_t * disp_refr; /*Display being refreshed*/
|
||||
*/
|
||||
void _lv_refr_init(void)
|
||||
{
|
||||
#if LV_USE_MONITOR
|
||||
_lv_monitor_builtin_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
void lv_refr_now(lv_disp_t * disp)
|
||||
@ -421,8 +415,6 @@ static void refr_invalid_areas(void)
|
||||
if(i == last_i) disp_refr->last_area = 1;
|
||||
disp_refr->last_part = 0;
|
||||
refr_area(&disp_refr->inv_areas[i]);
|
||||
|
||||
lv_area_get_size(&disp_refr->inv_areas[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -857,7 +857,7 @@
|
||||
*-----------*/
|
||||
|
||||
/*1: Show CPU usage and FPS count
|
||||
* Requires `LV_USE_MONITOR = 1`*/
|
||||
* Requires `LV_USE_SYSMON = 1`*/
|
||||
#ifndef LV_USE_PERF_MONITOR
|
||||
#ifdef CONFIG_LV_USE_PERF_MONITOR
|
||||
#define LV_USE_PERF_MONITOR CONFIG_LV_USE_PERF_MONITOR
|
||||
@ -873,18 +873,20 @@
|
||||
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
|
||||
#endif
|
||||
#endif
|
||||
#ifndef LV_USE_PERF_MONITOR_LOG_MDOE
|
||||
#ifdef CONFIG_LV_USE_PERF_MONITOR_LOG_MDOE
|
||||
#define LV_USE_PERF_MONITOR_LOG_MDOE CONFIG_LV_USE_PERF_MONITOR_LOG_MDOE
|
||||
|
||||
/*0: Displays performance data on the screen, 1: Prints performance data using log.*/
|
||||
#ifndef LV_USE_PERF_MONITOR_LOG_MODE
|
||||
#ifdef CONFIG_LV_USE_PERF_MONITOR_LOG_MODE
|
||||
#define LV_USE_PERF_MONITOR_LOG_MODE CONFIG_LV_USE_PERF_MONITOR_LOG_MODE
|
||||
#else
|
||||
#define LV_USE_PERF_MONITOR_LOG_MDOE 0
|
||||
#define LV_USE_PERF_MONITOR_LOG_MODE 0
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*1: Show the used memory and the memory fragmentation
|
||||
* Requires `LV_USE_BUILTIN_MALLOC = 1`
|
||||
* Requires `LV_USE_MONITOR = 1`*/
|
||||
* Requires `LV_USE_SYSMON = 1`*/
|
||||
#ifndef LV_USE_MEM_MONITOR
|
||||
#ifdef CONFIG_LV_USE_MEM_MONITOR
|
||||
#define LV_USE_MEM_MONITOR CONFIG_LV_USE_MEM_MONITOR
|
||||
@ -2335,16 +2337,12 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*1: Enable Monitor component*/
|
||||
#ifndef LV_USE_MONITOR
|
||||
#ifdef _LV_KCONFIG_PRESENT
|
||||
#ifdef CONFIG_LV_USE_MONITOR
|
||||
#define LV_USE_MONITOR CONFIG_LV_USE_MONITOR
|
||||
#else
|
||||
#define LV_USE_MONITOR 0
|
||||
#endif
|
||||
/*1: Enable system monitor component*/
|
||||
#ifndef LV_USE_SYSMON
|
||||
#ifdef CONFIG_LV_USE_SYSMON
|
||||
#define LV_USE_SYSMON CONFIG_LV_USE_SYSMON
|
||||
#else
|
||||
#define LV_USE_MONITOR 1
|
||||
#define LV_USE_SYSMON 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1,77 +0,0 @@
|
||||
/**
|
||||
* @file lv_monitor.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_MONITOR_H
|
||||
#define LV_MONITOR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_MONITOR
|
||||
|
||||
#if LV_USE_LABEL == 0
|
||||
#error "lv_monitor: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct {
|
||||
lv_label_t label;
|
||||
lv_timer_t * timer;
|
||||
} lv_monitor_t;
|
||||
|
||||
extern const lv_obj_class_t lv_monitor_class;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a monitor object (on lv_layer_sys).
|
||||
* @return pointer to the new monitor object
|
||||
*/
|
||||
lv_obj_t * lv_monitor_create(void);
|
||||
|
||||
/**
|
||||
* Check if a given flag or any of the flags are set on an object.
|
||||
* @param obj pointer to a monitor object
|
||||
* @param time monitor refresh interval
|
||||
*/
|
||||
void lv_monitor_set_refr_time(lv_obj_t * obj, uint32_t time);
|
||||
|
||||
/**
|
||||
* Initialize built-in monitors, such as performance and memory monitors.
|
||||
*/
|
||||
void _lv_monitor_builtin_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#else
|
||||
|
||||
#if LV_USE_PERF_MONITOR || LV_USE_MEM_MONITOR
|
||||
#warning "lv_monitor: lv_monitor is required. Enable it in lv_conf.h (LV_USE_MONITOR 1)"
|
||||
#endif
|
||||
|
||||
#endif /*LV_USE_MONITOR*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_MONITOR_H*/
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file lv_monitor.c
|
||||
* @file lv_sysmon.c
|
||||
*
|
||||
*/
|
||||
|
||||
@ -7,17 +7,14 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_monitor.h"
|
||||
#include "lv_sysmon.h"
|
||||
|
||||
#if LV_USE_MONITOR
|
||||
|
||||
#include "../../misc/lv_assert.h"
|
||||
#include LV_COLOR_EXTERN_INCLUDE
|
||||
#if LV_USE_SYSMON
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS &lv_monitor_class
|
||||
#define MY_CLASS &lv_sysmon_class
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -31,10 +28,10 @@ typedef struct {
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_monitor_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static void lv_monitor_event(const lv_obj_class_t * class_p, lv_event_t * e);
|
||||
static void lv_monitor_timer_cb(lv_timer_t * timer);
|
||||
static void monitor_async_cb(void * user_data);
|
||||
static void lv_sysmon_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static void lv_sysmon_event(const lv_obj_class_t * class_p, lv_event_t * e);
|
||||
static void lv_sysmon_timer_cb(lv_timer_t * timer);
|
||||
static void sysmon_async_cb(void * user_data);
|
||||
|
||||
#if LV_USE_PERF_MONITOR
|
||||
static void perf_monitor_init(void);
|
||||
@ -47,13 +44,13 @@ static void monitor_async_cb(void * user_data);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
const lv_obj_class_t lv_monitor_class = {
|
||||
const lv_obj_class_t lv_sysmon_class = {
|
||||
.base_class = &lv_label_class,
|
||||
.constructor_cb = lv_monitor_constructor,
|
||||
.constructor_cb = lv_sysmon_constructor,
|
||||
.width_def = LV_SIZE_CONTENT,
|
||||
.height_def = LV_SIZE_CONTENT,
|
||||
.event_cb = lv_monitor_event,
|
||||
.instance_size = sizeof(lv_monitor_t),
|
||||
.event_cb = lv_sysmon_event,
|
||||
.instance_size = sizeof(lv_sysmon_t),
|
||||
};
|
||||
|
||||
/**********************
|
||||
@ -64,52 +61,49 @@ const lv_obj_class_t lv_monitor_class = {
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_obj_t * lv_monitor_create(void)
|
||||
lv_obj_t * lv_sysmon_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, lv_layer_sys());
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
void lv_monitor_set_refr_time(lv_obj_t * obj, uint32_t time)
|
||||
void lv_sysmon_set_refr_period(lv_obj_t * obj, uint32_t period)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_monitor_t * monitor = (lv_monitor_t *)obj;
|
||||
lv_timer_set_period(monitor->timer, time);
|
||||
lv_sysmon_t * sysmon = (lv_sysmon_t *)obj;
|
||||
lv_timer_set_period(sysmon->timer, period);
|
||||
}
|
||||
|
||||
void _lv_monitor_builtin_init(void)
|
||||
void _lv_sysmon_builtin_init(void)
|
||||
{
|
||||
lv_async_call(monitor_async_cb, NULL);
|
||||
lv_async_call(sysmon_async_cb, NULL);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void lv_monitor_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
static void lv_sysmon_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
lv_monitor_t * monitor = (lv_monitor_t *)obj;
|
||||
monitor->timer = lv_timer_create(lv_monitor_timer_cb, 1000, obj);
|
||||
lv_sysmon_t * sysmon = (lv_sysmon_t *)obj;
|
||||
sysmon->timer = lv_timer_create(lv_sysmon_timer_cb, 1000, obj);
|
||||
lv_obj_set_style_bg_opa(obj, LV_OPA_50, 0);
|
||||
lv_obj_set_style_bg_color(obj, lv_color_black(), 0);
|
||||
lv_obj_set_style_text_color(obj, lv_color_white(), 0);
|
||||
lv_obj_set_style_pad_top(obj, 3, 0);
|
||||
lv_obj_set_style_pad_bottom(obj, 3, 0);
|
||||
lv_obj_set_style_pad_left(obj, 3, 0);
|
||||
lv_obj_set_style_pad_right(obj, 3, 0);
|
||||
lv_obj_set_style_pad_all(obj, 3, 0);
|
||||
lv_label_set_text(obj, "?");
|
||||
}
|
||||
|
||||
static void lv_monitor_timer_cb(lv_timer_t * timer)
|
||||
static void lv_sysmon_timer_cb(lv_timer_t * timer)
|
||||
{
|
||||
lv_obj_t * obj = lv_timer_get_user_data(timer);
|
||||
lv_obj_send_event(obj, LV_EVENT_REFRESH, NULL);
|
||||
}
|
||||
|
||||
static void lv_monitor_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
static void lv_sysmon_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
lv_obj_event_base(MY_CLASS, e);
|
||||
@ -119,56 +113,57 @@ static void lv_monitor_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
|
||||
static void perf_monitor_refr_finish_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * monitor = lv_event_get_user_data(e);
|
||||
perf_info_t * info = lv_obj_get_user_data(monitor);
|
||||
lv_obj_t * sysmon = lv_event_get_user_data(e);
|
||||
perf_info_t * info = lv_obj_get_user_data(sysmon);
|
||||
info->elaps_sum += lv_tick_elaps(info->disp->last_render_start_time);
|
||||
info->frame_cnt++;
|
||||
}
|
||||
|
||||
static void perf_monitor_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * monitor = lv_event_get_current_target_obj(e);
|
||||
perf_info_t * info = lv_obj_get_user_data(monitor);
|
||||
lv_obj_t * sysmon = lv_event_get_current_target_obj(e);
|
||||
perf_info_t * info = lv_obj_get_user_data(sysmon);
|
||||
uint32_t cpu = 100 - lv_timer_get_idle();
|
||||
uint32_t avg_time = info->frame_cnt ? info->elaps_sum / info->frame_cnt : 0;
|
||||
|
||||
#if LV_USE_PERF_MONITOR_LOG_MDOE
|
||||
LV_LOG("Performance: %" LV_PRIu32" FPS / %" LV_PRIu32" ms / %" LV_PRIu32 "%% CPU\n",
|
||||
/*Avoid warning*/
|
||||
LV_UNUSED(cpu);
|
||||
LV_UNUSED(avg_time);
|
||||
|
||||
#if LV_USE_PERF_MONITOR_LOG_MODE
|
||||
LV_LOG("sysmon: %" LV_PRIu32" FPS / render %" LV_PRIu32" ms / %" LV_PRIu32 "%% CPU\n",
|
||||
info->frame_cnt,
|
||||
avg_time,
|
||||
cpu);
|
||||
#else
|
||||
lv_label_set_text_fmt(
|
||||
monitor,
|
||||
sysmon,
|
||||
"%" LV_PRIu32" FPS / %" LV_PRIu32" ms\n%" LV_PRIu32 "%% CPU",
|
||||
info->frame_cnt,
|
||||
avg_time,
|
||||
cpu
|
||||
);
|
||||
#endif /*LV_USE_PERF_MONITOR_LOG_MDOE*/
|
||||
#endif /*LV_USE_PERF_MONITOR_LOG_MODE*/
|
||||
info->elaps_sum = 0;
|
||||
info->frame_cnt = 0;
|
||||
}
|
||||
|
||||
static void perf_monitor_init(void)
|
||||
{
|
||||
perf_info_t * info = lv_malloc(sizeof(perf_info_t));
|
||||
LV_ASSERT_MALLOC(info);
|
||||
static perf_info_t info = { 0 };
|
||||
info.disp = lv_disp_get_default();
|
||||
|
||||
lv_memzero(info, sizeof(perf_info_t));
|
||||
info->disp = lv_disp_get_default();
|
||||
lv_obj_t * sysmon = lv_sysmon_create(lv_layer_sys());
|
||||
lv_sysmon_set_refr_period(sysmon, 1000);
|
||||
lv_obj_align(sysmon, LV_USE_PERF_MONITOR_POS, 0, 0);
|
||||
lv_obj_set_style_text_align(sysmon, LV_TEXT_ALIGN_RIGHT, 0);
|
||||
lv_obj_set_user_data(sysmon, &info);
|
||||
lv_obj_add_event(sysmon, perf_monitor_event_cb, LV_EVENT_REFRESH, NULL);
|
||||
lv_disp_add_event(info.disp, perf_monitor_refr_finish_cb, LV_EVENT_REFR_FINISH, sysmon);
|
||||
|
||||
lv_obj_t * monitor = lv_monitor_create();
|
||||
lv_monitor_set_refr_time(monitor, 1000);
|
||||
lv_obj_align(monitor, LV_USE_PERF_MONITOR_POS, 0, 0);
|
||||
lv_obj_set_style_text_align(monitor, LV_TEXT_ALIGN_RIGHT, 0);
|
||||
lv_obj_set_user_data(monitor, info);
|
||||
lv_obj_add_event(monitor, perf_monitor_event_cb, LV_EVENT_REFRESH, NULL);
|
||||
lv_disp_add_event(info->disp, perf_monitor_refr_finish_cb, LV_EVENT_REFR_FINISH, monitor);
|
||||
|
||||
#if LV_USE_PERF_MONITOR_LOG_MDOE
|
||||
#if LV_USE_PERF_MONITOR_LOG_MODE
|
||||
/*Reduce rendering performance consumption*/
|
||||
lv_obj_add_flag(monitor, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(sysmon, LV_OBJ_FLAG_HIDDEN);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@ -176,13 +171,13 @@ static void perf_monitor_init(void)
|
||||
#if LV_USE_MEM_MONITOR && LV_USE_BUILTIN_MALLOC
|
||||
static void mem_monitor_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * monitor = lv_event_get_current_target_obj(e);
|
||||
lv_obj_t * sysmon = lv_event_get_current_target_obj(e);
|
||||
lv_mem_monitor_t mon;
|
||||
lv_mem_monitor(&mon);
|
||||
uint32_t used_size = mon.total_size - mon.free_size;;
|
||||
uint32_t used_kb = used_size / 1024;
|
||||
uint32_t used_kb_tenth = (used_size - (used_kb * 1024)) / 102;
|
||||
lv_label_set_text_fmt(monitor,
|
||||
lv_label_set_text_fmt(sysmon,
|
||||
"%"LV_PRIu32 ".%"LV_PRIu32 " kB used (%d %%)\n"
|
||||
"%d%% frag.",
|
||||
used_kb, used_kb_tenth, mon.used_pct,
|
||||
@ -191,14 +186,14 @@ static void mem_monitor_event_cb(lv_event_t * e)
|
||||
|
||||
static void mem_monitor_init(void)
|
||||
{
|
||||
lv_obj_t * monitor = lv_monitor_create();
|
||||
lv_obj_add_event(monitor, mem_monitor_event_cb, LV_EVENT_REFRESH, NULL);
|
||||
lv_obj_align(monitor, LV_USE_MEM_MONITOR_POS, 0, 0);
|
||||
lv_monitor_set_refr_time(monitor, 300);
|
||||
lv_obj_t * sysmon = lv_sysmon_create(lv_layer_sys());
|
||||
lv_obj_add_event(sysmon, mem_monitor_event_cb, LV_EVENT_REFRESH, NULL);
|
||||
lv_obj_align(sysmon, LV_USE_MEM_MONITOR_POS, 0, 0);
|
||||
lv_sysmon_set_refr_period(sysmon, 300);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void monitor_async_cb(void * user_data)
|
||||
static void sysmon_async_cb(void * user_data)
|
||||
{
|
||||
LV_UNUSED(user_data);
|
||||
#if LV_USE_PERF_MONITOR
|
||||
@ -209,4 +204,4 @@ static void monitor_async_cb(void * user_data)
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*LV_USE_MONITOR*/
|
||||
#endif /*LV_USE_SYSMON*/
|
78
src/others/sysmon/lv_sysmon.h
Normal file
78
src/others/sysmon/lv_sysmon.h
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @file lv_sysmon.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_SYSMON_H
|
||||
#define LV_SYSMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_SYSMON
|
||||
|
||||
#if LV_USE_LABEL == 0
|
||||
#error "lv_sysmon: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct {
|
||||
lv_label_t label;
|
||||
lv_timer_t * timer;
|
||||
} lv_sysmon_t;
|
||||
|
||||
extern const lv_obj_class_t lv_sysmon_class;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a system monitor object.
|
||||
* @param parent pointer to an object, it will be the parent of the new system monitor
|
||||
* @return pointer to the new system monitor object
|
||||
*/
|
||||
lv_obj_t * lv_sysmon_create(lv_obj_t * parent);
|
||||
|
||||
/**
|
||||
* Set the refresh period of the system monitor object
|
||||
* @param obj pointer to a system monitor object
|
||||
* @param period the refresh period in milliseconds
|
||||
*/
|
||||
void lv_sysmon_set_refr_period(lv_obj_t * obj, uint32_t period);
|
||||
|
||||
/**
|
||||
* Initialize built-in system monitor, such as performance and memory monitor.
|
||||
*/
|
||||
void _lv_sysmon_builtin_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#else
|
||||
|
||||
#if LV_USE_PERF_MONITOR || LV_USE_MEM_MONITOR
|
||||
#warning "lv_sysmon: lv_sysmon is required. Enable it in lv_conf.h (LV_USE_SYSMON 1)"
|
||||
#endif
|
||||
|
||||
#endif /*LV_USE_SYSMON*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_SYSMON_H*/
|
@ -7,7 +7,6 @@
|
||||
#define LV_LOG_PRINTF 1
|
||||
#define LV_USE_FONT_SUBPX 1
|
||||
#define LV_FONT_SUBPX_BGR 1
|
||||
#define LV_USE_PERF_MONITOR 1
|
||||
#define LV_USE_ASSERT_NULL 1
|
||||
#define LV_USE_ASSERT_MALLOC 1
|
||||
#define LV_USE_ASSERT_MEM_INTEGRITY 1
|
||||
@ -72,7 +71,7 @@
|
||||
#define LV_USE_MSG 1
|
||||
#define LV_USE_FILE_EXPLORER 1
|
||||
#define LV_USE_TINY_TTF 1
|
||||
|
||||
#define LV_USE_SYSMON 1
|
||||
|
||||
#define LV_BUILD_EXAMPLES 1
|
||||
#define LV_USE_DEMO_WIDGETS 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user