demo(benchmark): rework benchmark
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,12 @@ extern "C" {
|
||||
*********************/
|
||||
#include "../lv_demos.h"
|
||||
|
||||
#if LV_USE_DEMO_BENCHMARK
|
||||
|
||||
#if LV_USE_PERF_MONITOR == 0
|
||||
#error "lv_demo_benchmark: LV_USE_PERF_MONITOR is required. Enable it in lv_conf.h (LV_USE_PERF_MONITOR 1)"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@@ -22,39 +28,22 @@ extern "C" {
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum {
|
||||
/**Render the scenes and show them on the display.
|
||||
* Measure rendering time but it might contain extra time when LVGL waits for the driver.
|
||||
* Run each scenes for a few seconds so the performance can be seen by eye too.
|
||||
* As only the rendering time is measured and converted to FPS, really high values (e.g. 1000 FPS)
|
||||
* are possible.*/
|
||||
LV_DEMO_BENCHMARK_MODE_RENDER_AND_DRIVER,
|
||||
|
||||
/**Similar to RENDER_AND_DRIVER but instead of measuring the rendering time only measure the real FPS of the system.
|
||||
* E.g. even if a scene was rendered in 1 ms, but the screen is redrawn only in every 100 ms, the result will be 10 FPS.*/
|
||||
LV_DEMO_BENCHMARK_MODE_REAL,
|
||||
|
||||
/**Temporarily display the `flush_cb` so the pure rendering time will be measured.
|
||||
* The display is not updated during the benchmark, only at the end when the summary table is shown.
|
||||
* Render a given number of frames from each scene and calculate the FPS from them.*/
|
||||
LV_DEMO_BENCHMARK_MODE_RENDER_ONLY,
|
||||
} lv_demo_benchmark_mode_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/** Run all test scenes in the LVGL benchmark with a given mode
|
||||
*/
|
||||
void lv_demo_benchmark(lv_demo_benchmark_mode_t mode);
|
||||
|
||||
/** Run a specific test scene in the LVGL benchmark with a given mode
|
||||
*/
|
||||
void lv_demo_benchmark_run_scene(lv_demo_benchmark_mode_t mode, uint16_t scene_no);
|
||||
void lv_demo_benchmark(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_DEMO_BENCHMARK*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
|
||||
typedef void (*demo_method_cb)(void);
|
||||
#if LV_USE_DEMO_BENCHMARK
|
||||
typedef void (*demo_method_benchmark_cb)(lv_demo_benchmark_mode_t);
|
||||
typedef void (*demo_method_benchmark_scene_cb)(lv_demo_benchmark_mode_t, uint16_t);
|
||||
// typedef void (*demo_method_benchmark_cb)(lv_demo_benchmark_mode_t);
|
||||
// typedef void (*demo_method_benchmark_scene_cb)(lv_demo_benchmark_mode_t, uint16_t);
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
@@ -34,8 +34,8 @@ typedef struct {
|
||||
union {
|
||||
demo_method_cb entry_cb;
|
||||
#if LV_USE_DEMO_BENCHMARK
|
||||
demo_method_benchmark_cb entry_benchmark_cb;
|
||||
demo_method_benchmark_scene_cb entry_benchmark_scene_cb;
|
||||
// demo_method_benchmark_cb entry_benchmark_cb;
|
||||
// demo_method_benchmark_scene_cb entry_benchmark_scene_cb;
|
||||
#endif
|
||||
};
|
||||
int arg_count : 8;
|
||||
@@ -89,10 +89,10 @@ static const demo_entry_info_t demos_entry_info[] = {
|
||||
{ "scroll", .entry_cb = lv_demo_scroll },
|
||||
#endif
|
||||
|
||||
#if LV_USE_DEMO_BENCHMARK
|
||||
{ DEMO_BENCHMARK_NAME, .entry_benchmark_cb = lv_demo_benchmark, 1 },
|
||||
{ DEMO_BENCHMARK_SCENE_NAME, .entry_benchmark_scene_cb = lv_demo_benchmark_run_scene, 2 },
|
||||
#endif
|
||||
//#if LV_USE_DEMO_BENCHMARK
|
||||
// { DEMO_BENCHMARK_NAME, .entry_benchmark_cb = lv_demo_benchmark, 1 },
|
||||
// { DEMO_BENCHMARK_SCENE_NAME, .entry_benchmark_scene_cb = lv_demo_benchmark_run_scene, 2 },
|
||||
//#endif
|
||||
{ "", .entry_cb = NULL }
|
||||
};
|
||||
|
||||
@@ -138,16 +138,16 @@ bool lv_demos_create(char * info[], int size)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#if LV_USE_DEMO_BENCHMARK
|
||||
else if(demo_is_benchmark(entry_info) && entry_info->entry_benchmark_cb) {
|
||||
entry_info->entry_benchmark_cb((lv_demo_benchmark_mode_t)atoi(info[1]));
|
||||
return true;
|
||||
}
|
||||
else if(demo_is_benchmark_scene(entry_info) && entry_info->entry_benchmark_scene_cb) {
|
||||
entry_info->entry_benchmark_scene_cb((lv_demo_benchmark_mode_t)atoi(info[1]), (uint16_t)atoi(info[2]));
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
//#if LV_USE_DEMO_BENCHMARK
|
||||
// else if(demo_is_benchmark(entry_info) && entry_info->entry_benchmark_cb) {
|
||||
// entry_info->entry_benchmark_cb((lv_demo_benchmark_mode_t)atoi(info[1]));
|
||||
// return true;
|
||||
// }
|
||||
// else if(demo_is_benchmark_scene(entry_info) && entry_info->entry_benchmark_scene_cb) {
|
||||
// entry_info->entry_benchmark_scene_cb((lv_demo_benchmark_mode_t)atoi(info[1]), (uint16_t)atoi(info[2]));
|
||||
// return true;
|
||||
// }
|
||||
//#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ static card_info_t card_info[] = {
|
||||
CARD_INFO_SET(&img_multilang_avatar_13, "Jamal Brown", "Photographer and amateur astronomer 📸"),
|
||||
CARD_INFO_SET(&img_multilang_avatar_15, "Pavel Svoboda", "Hudebník a návštěvník koncertů"),
|
||||
CARD_INFO_SET(&img_multilang_avatar_16, "Elin Lindqvist", "Språkinlärare och kulturentusiast "),
|
||||
CARD_INFO_SET(&img_multilang_avatar_17, "William Carter", "DIY enthusiast and home improvement guru "),
|
||||
CARD_INFO_SET(&img_multilang_avatar_17, "William Carter", "DIY enthusiast and home improvement guru"),
|
||||
CARD_INFO_SET(&img_multilang_avatar_22, "Ava Williams", "Artist and creative visionary 🎨"),
|
||||
CARD_INFO_SET(NULL, NULL, NULL),
|
||||
};
|
||||
|
||||
@@ -48,10 +48,13 @@ static void calendar_event_cb(lv_event_t * e);
|
||||
static void slider_event_cb(lv_event_t * e);
|
||||
static void chart_event_cb(lv_event_t * e);
|
||||
static void shop_chart_event_cb(lv_event_t * e);
|
||||
static void scale2_event_cb(lv_event_t * e);
|
||||
static void scale1_indic1_anim_cb(void * var, int32_t v);
|
||||
static void scale2_timer_cb(lv_timer_t * timer);
|
||||
static void scale3_anim_cb(void * var, int32_t v);
|
||||
static void scroll_anim_y_cb(void * var, int32_t v);
|
||||
static void scroll_anim_y_cb(void * var, int32_t v);
|
||||
static void delete_timer_event_cb(lv_event_t * e);
|
||||
static void slideshow_anim_ready_cb(lv_anim_t * a_old);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -195,6 +198,28 @@ void lv_demo_widgets(void)
|
||||
color_changer_create(tv);
|
||||
}
|
||||
|
||||
|
||||
void lv_demo_widgets_start_slideshow(void)
|
||||
{
|
||||
lv_obj_update_layout(tv);
|
||||
|
||||
lv_obj_t * cont = lv_tabview_get_content(tv);
|
||||
|
||||
lv_obj_t * tab = lv_obj_get_child(cont, 0);
|
||||
|
||||
int32_t v = lv_obj_get_scroll_bottom(tab);
|
||||
uint32_t t = lv_anim_speed_to_time(lv_display_get_dpi(NULL), 0, v);
|
||||
lv_anim_t a;
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_exec_cb(&a, scroll_anim_y_cb);
|
||||
lv_anim_set_time(&a, t);
|
||||
lv_anim_set_playback_time(&a, t);
|
||||
lv_anim_set_values(&a, 0, v);
|
||||
lv_anim_set_var(&a, tab);
|
||||
lv_anim_set_ready_cb(&a, slideshow_anim_ready_cb);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@@ -740,7 +765,7 @@ static void analytics_create(lv_obj_t * parent)
|
||||
lv_obj_center(arc);
|
||||
|
||||
lv_timer_t * scale2_timer = lv_timer_create(scale2_timer_cb, 100, scale2);
|
||||
lv_obj_add_event(scale2, scale2_event_cb, LV_EVENT_DELETE, scale2_timer);
|
||||
lv_obj_add_event(scale2, delete_timer_event_cb, LV_EVENT_DELETE, scale2_timer);
|
||||
|
||||
/*Scale 3*/
|
||||
lv_scale_set_range(scale3, 10, 60);
|
||||
@@ -1535,15 +1560,6 @@ static void scale1_indic1_anim_cb(void * var, int32_t v)
|
||||
lv_label_set_text_fmt(label, "Revenue: %"LV_PRId32" %%", v);
|
||||
}
|
||||
|
||||
static void scale2_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if(code == LV_EVENT_DELETE) {
|
||||
lv_timer_t * scale2_timer = lv_event_get_user_data(e);
|
||||
if(scale2_timer) lv_timer_delete(scale2_timer);
|
||||
}
|
||||
}
|
||||
|
||||
static void scale2_timer_cb(lv_timer_t * timer)
|
||||
{
|
||||
LV_UNUSED(timer);
|
||||
@@ -1613,4 +1629,46 @@ static void scale3_anim_cb(void * var, int32_t v)
|
||||
lv_label_set_text_fmt(label, "%"LV_PRId32, v);
|
||||
}
|
||||
|
||||
static void scroll_anim_y_cb(void * var, int32_t v)
|
||||
{
|
||||
lv_obj_scroll_to_y(var, v, LV_ANIM_OFF);
|
||||
}
|
||||
|
||||
static void delete_timer_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if(code == LV_EVENT_DELETE) {
|
||||
lv_timer_t * t = lv_event_get_user_data(e);
|
||||
if(t) lv_timer_delete(t);
|
||||
}
|
||||
}
|
||||
|
||||
static void slideshow_anim_ready_cb(lv_anim_t * a_old)
|
||||
{
|
||||
LV_UNUSED(a_old);
|
||||
|
||||
lv_obj_t * cont = lv_tabview_get_content(tv);
|
||||
uint32_t tab_id = lv_tabview_get_tab_act(tv);
|
||||
tab_id += 1;
|
||||
if(tab_id > 2) tab_id = 0;
|
||||
lv_tabview_set_act(tv, tab_id, LV_ANIM_ON);
|
||||
|
||||
lv_obj_t * tab = lv_obj_get_child(cont, tab_id);
|
||||
lv_obj_scroll_to_y(tab, 0, LV_ANIM_OFF);
|
||||
lv_obj_update_layout(tv);
|
||||
|
||||
int32_t v = lv_obj_get_scroll_bottom(tab);
|
||||
uint32_t t = lv_anim_speed_to_time(lv_display_get_dpi(NULL), 0, v);
|
||||
|
||||
lv_anim_t a;
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_exec_cb(&a, scroll_anim_y_cb);
|
||||
lv_anim_set_time(&a, t);
|
||||
lv_anim_set_playback_time(&a, t);
|
||||
lv_anim_set_values(&a, 0, v);
|
||||
lv_anim_set_var(&a, tab);
|
||||
lv_anim_set_ready_cb(&a, slideshow_anim_ready_cb);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,7 @@ extern "C" {
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_demo_widgets(void);
|
||||
void lv_demo_widgets_start_slideshow(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
Reference in New Issue
Block a user