mirror of
https://github.com/lvgl/lvgl.git
synced 2025-02-04 07:13:00 +08:00
Merge branch 'demo-close' into release/v8.3
This commit is contained in:
commit
1c5d4b02d7
@ -89,7 +89,7 @@ LV_FONT_DECLARE(lv_font_benchmark_montserrat_16_compr_az);
|
||||
LV_FONT_DECLARE(lv_font_benchmark_montserrat_28_compr_az);
|
||||
|
||||
static void monitor_cb(lv_disp_drv_t * drv, uint32_t time, uint32_t px);
|
||||
static void scene_next_task_cb(lv_timer_t * timer);
|
||||
static void next_scene_timer_cb(lv_timer_t * timer);
|
||||
static void rect_create(lv_style_t * style);
|
||||
static void img_create(lv_style_t * style, const void * src, bool rotate, bool zoom, bool aa);
|
||||
static void txt_create(lv_style_t * style);
|
||||
@ -636,7 +636,7 @@ static lv_obj_t * scene_bg;
|
||||
static lv_obj_t * title;
|
||||
static lv_obj_t * subtitle;
|
||||
static uint32_t rnd_act;
|
||||
|
||||
static lv_timer_t * next_scene_timer;
|
||||
|
||||
static const uint32_t rnd_map[] = {
|
||||
0xbd13204f, 0x67d8167f, 0x20211c99, 0xb0a7cc05,
|
||||
@ -708,9 +708,21 @@ void lv_demo_benchmark(void)
|
||||
benchmark_init();
|
||||
|
||||
/*Manually start scenes*/
|
||||
scene_next_task_cb(NULL);
|
||||
next_scene_timer_cb(NULL);
|
||||
}
|
||||
|
||||
void lv_demo_benchmark_close(void)
|
||||
{
|
||||
if(next_scene_timer) lv_timer_del(next_scene_timer);
|
||||
next_scene_timer = NULL;
|
||||
|
||||
lv_anim_del(NULL, NULL);
|
||||
|
||||
lv_style_reset(&style_common);
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
}
|
||||
|
||||
void lv_demo_benchmark_run_scene(int_fast16_t scene_no)
|
||||
{
|
||||
@ -973,11 +985,13 @@ static void report_cb(lv_timer_t * timer)
|
||||
}
|
||||
}
|
||||
|
||||
static void scene_next_task_cb(lv_timer_t * timer)
|
||||
static void next_scene_timer_cb(lv_timer_t * timer)
|
||||
{
|
||||
LV_UNUSED(timer);
|
||||
lv_obj_clean(scene_bg);
|
||||
|
||||
next_scene_timer = NULL;
|
||||
|
||||
if(opa_mode) {
|
||||
if(scene_act >= 0) {
|
||||
if(scenes[scene_act].time_sum_opa == 0) scenes[scene_act].time_sum_opa = 1;
|
||||
@ -1014,8 +1028,8 @@ static void scene_next_task_cb(lv_timer_t * timer)
|
||||
|
||||
rnd_reset();
|
||||
scenes[scene_act].create_cb();
|
||||
lv_timer_t * t = lv_timer_create(scene_next_task_cb, SCENE_TIME, NULL);
|
||||
lv_timer_set_repeat_count(t, 1);
|
||||
next_scene_timer = lv_timer_create(next_scene_timer_cb, SCENE_TIME, NULL);
|
||||
lv_timer_set_repeat_count(next_scene_timer, 1);
|
||||
|
||||
}
|
||||
/*Ready*/
|
||||
|
@ -30,6 +30,8 @@ typedef void finished_cb_t(void);
|
||||
**********************/
|
||||
void lv_demo_benchmark(void);
|
||||
|
||||
void lv_demo_benchmark_close(void);
|
||||
|
||||
void lv_demo_benchmark_run_scene(int_fast16_t scene_no);
|
||||
|
||||
void lv_demo_benchmark_set_finished_cb(finished_cb_t * finished_cb);
|
||||
|
@ -46,8 +46,11 @@ static lv_obj_t * t2;
|
||||
|
||||
void lv_demo_keypad_encoder(void)
|
||||
{
|
||||
g = lv_group_create();
|
||||
lv_group_set_default(g);
|
||||
g = lv_group_get_default();
|
||||
if(g == NULL) {
|
||||
g = lv_group_create();
|
||||
lv_group_set_default(g);
|
||||
}
|
||||
|
||||
lv_indev_t * cur_drv = NULL;
|
||||
for(;;) {
|
||||
@ -76,6 +79,12 @@ void lv_demo_keypad_encoder(void)
|
||||
msgbox_create();
|
||||
}
|
||||
|
||||
void lv_demo_keypad_encoder_close(void)
|
||||
{
|
||||
lv_obj_clean(lv_scr_act());
|
||||
lv_obj_clean(lv_layer_top());
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -27,6 +27,7 @@ extern "C" {
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_demo_keypad_encoder(void);
|
||||
void lv_demo_keypad_encoder_close(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -103,6 +103,12 @@ static const uint32_t time_list[] = {
|
||||
2 * 60 + 19,
|
||||
};
|
||||
|
||||
#if LV_DEMO_MUSIC_AUTO_PLAY
|
||||
static lv_timer_t * auto_step_timer;
|
||||
#endif
|
||||
|
||||
static lv_color_t original_screen_bg_color;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -113,16 +119,33 @@ static const uint32_t time_list[] = {
|
||||
|
||||
void lv_demo_music(void)
|
||||
{
|
||||
original_screen_bg_color = lv_obj_get_style_bg_color(lv_scr_act(), 0);
|
||||
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x343247), 0);
|
||||
|
||||
list = _lv_demo_music_list_create(lv_scr_act());
|
||||
ctrl = _lv_demo_music_main_create(lv_scr_act());
|
||||
|
||||
#if LV_DEMO_MUSIC_AUTO_PLAY
|
||||
lv_timer_create(auto_step_cb, 1000, NULL);
|
||||
auto_step_timer = lv_timer_create(auto_step_cb, 1000, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void lv_demo_music_close(void)
|
||||
{
|
||||
/*Delete all aniamtions*/
|
||||
lv_anim_del(NULL, NULL);
|
||||
|
||||
#if LV_DEMO_MUSIC_AUTO_PLAY
|
||||
lv_timer_del(auto_step_timer);
|
||||
#endif
|
||||
_lv_demo_music_list_close();
|
||||
_lv_demo_music_main_close();
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
lv_obj_set_style_bg_color(lv_scr_act(), original_screen_bg_color, 0);
|
||||
}
|
||||
|
||||
const char * _lv_demo_music_get_title(uint32_t track_id)
|
||||
{
|
||||
if(track_id >= sizeof(title_list) / sizeof(title_list[0])) return NULL;
|
||||
|
@ -36,6 +36,8 @@ extern "C" {
|
||||
**********************/
|
||||
|
||||
void lv_demo_music(void);
|
||||
void lv_demo_music_close(void);
|
||||
|
||||
const char * _lv_demo_music_get_title(uint32_t track_id);
|
||||
const char * _lv_demo_music_get_artist(uint32_t track_id);
|
||||
const char * _lv_demo_music_get_genre(uint32_t track_id);
|
||||
|
@ -130,6 +130,19 @@ lv_obj_t * _lv_demo_music_list_create(lv_obj_t * parent)
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
void _lv_demo_music_list_close(void)
|
||||
{
|
||||
lv_style_reset(&style_scrollbar);
|
||||
lv_style_reset(&style_btn);
|
||||
lv_style_reset(&style_btn_pr);
|
||||
lv_style_reset(&style_btn_chk);
|
||||
lv_style_reset(&style_btn_dis);
|
||||
lv_style_reset(&style_title);
|
||||
lv_style_reset(&style_artist);
|
||||
lv_style_reset(&style_time);
|
||||
}
|
||||
|
||||
void _lv_demo_music_list_btn_check(uint32_t track_id, bool state)
|
||||
{
|
||||
lv_obj_t * btn = lv_obj_get_child(list, track_id);
|
||||
|
@ -28,6 +28,8 @@ extern "C" {
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
lv_obj_t * _lv_demo_music_list_create(lv_obj_t * parent);
|
||||
void _lv_demo_music_list_close(void);
|
||||
|
||||
void _lv_demo_music_list_btn_check(uint32_t track_id, bool state);
|
||||
|
||||
/**********************
|
||||
|
@ -60,7 +60,7 @@ static void prev_click_event_cb(lv_event_t * e);
|
||||
static void next_click_event_cb(lv_event_t * e);
|
||||
static void timer_cb(lv_timer_t * t);
|
||||
static void track_load(uint32_t id);
|
||||
static void stop_start_anim(lv_timer_t * t);
|
||||
static void stop_start_anim_timer_cb(lv_timer_t * t);
|
||||
static void spectrum_end_cb(lv_anim_t * a);
|
||||
static void album_fade_anim_cb(void * var, int32_t v);
|
||||
static int32_t get_cos(int32_t deg, int32_t a);
|
||||
@ -84,6 +84,7 @@ static uint32_t spectrum_lane_ofs_start = 0;
|
||||
static uint32_t bar_rot = 0;
|
||||
static uint32_t time_act;
|
||||
static lv_timer_t * sec_counter_timer;
|
||||
static lv_timer_t * stop_start_anim_timer;
|
||||
static const lv_font_t * font_small;
|
||||
static const lv_font_t * font_large;
|
||||
static uint32_t track_id;
|
||||
@ -232,8 +233,8 @@ lv_obj_t * _lv_demo_music_main_create(lv_obj_t * parent)
|
||||
|
||||
start_anim = true;
|
||||
|
||||
lv_timer_t * timer = lv_timer_create(stop_start_anim, INTRO_TIME + 6000, NULL);
|
||||
lv_timer_set_repeat_count(timer, 1);
|
||||
stop_start_anim_timer = lv_timer_create(stop_start_anim_timer_cb, INTRO_TIME + 6000, NULL);
|
||||
lv_timer_set_repeat_count(stop_start_anim_timer, 1);
|
||||
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_bounce);
|
||||
@ -292,6 +293,12 @@ lv_obj_t * _lv_demo_music_main_create(lv_obj_t * parent)
|
||||
return main_cont;
|
||||
}
|
||||
|
||||
void _lv_demo_music_main_close(void)
|
||||
{
|
||||
if(stop_start_anim_timer) lv_timer_del(stop_start_anim_timer);
|
||||
lv_timer_del(sec_counter_timer);
|
||||
}
|
||||
|
||||
void _lv_demo_music_album_next(bool next)
|
||||
{
|
||||
uint32_t id = track_id;
|
||||
@ -990,10 +997,11 @@ static void spectrum_end_cb(lv_anim_t * a)
|
||||
}
|
||||
|
||||
|
||||
static void stop_start_anim(lv_timer_t * t)
|
||||
static void stop_start_anim_timer_cb(lv_timer_t * t)
|
||||
{
|
||||
LV_UNUSED(t);
|
||||
start_anim = false;
|
||||
stop_start_anim_timer = NULL;
|
||||
lv_obj_refresh_ext_draw_size(spectrum_obj);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@ extern "C" {
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
lv_obj_t * _lv_demo_music_main_create(lv_obj_t * parent);
|
||||
void _lv_demo_music_main_close(void);
|
||||
|
||||
void _lv_demo_music_play(uint32_t id);
|
||||
void _lv_demo_music_resume(void);
|
||||
void _lv_demo_music_pause(void);
|
||||
|
@ -25,7 +25,7 @@ static void msgbox_del(lv_timer_t * tmr);
|
||||
static void set_y_anim(void * obj, int32_t v);
|
||||
static void set_width_anim(void * obj, int32_t v);
|
||||
static void arc_set_end_angle_anim(void * obj, int32_t v);
|
||||
static void obj_test_task_cb(lv_timer_t * tmr);
|
||||
static void obj_test_timer_cb(lv_timer_t * tmr);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -34,6 +34,8 @@ static lv_obj_t * main_page;
|
||||
static lv_obj_t * ta;
|
||||
static const char * mbox_btns[] = {"Ok", "Cancel", ""};
|
||||
static uint32_t mem_free_start = 0;
|
||||
static lv_timer_t * obj_test_timer;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -45,14 +47,21 @@ static uint32_t mem_free_start = 0;
|
||||
void lv_demo_stress(void)
|
||||
{
|
||||
LV_LOG_USER("Starting stress test. (< 100 bytes permanent memory leak is normal due to fragmentation)");
|
||||
lv_timer_create(obj_test_task_cb, LV_DEMO_STRESS_TIME_STEP, NULL);
|
||||
obj_test_timer = lv_timer_create(obj_test_timer_cb, LV_DEMO_STRESS_TIME_STEP, NULL);
|
||||
}
|
||||
|
||||
void lv_demo_stress_close(void)
|
||||
{
|
||||
lv_timer_del(obj_test_timer);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
lv_obj_clean(lv_layer_top());
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void obj_test_task_cb(lv_timer_t * tmr)
|
||||
static void obj_test_timer_cb(lv_timer_t * tmr)
|
||||
{
|
||||
(void) tmr; /*Unused*/
|
||||
static int16_t state = -1;
|
||||
|
@ -30,6 +30,8 @@ extern "C" {
|
||||
**********************/
|
||||
void lv_demo_stress(void);
|
||||
|
||||
void lv_demo_stress_close(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -86,6 +86,8 @@ static uint32_t session_desktop = 1000;
|
||||
static uint32_t session_tablet = 1000;
|
||||
static uint32_t session_mobile = 1000;
|
||||
|
||||
static lv_timer_t * meter2_timer;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -196,6 +198,22 @@ void lv_demo_widgets(void)
|
||||
color_changer_create(tv);
|
||||
}
|
||||
|
||||
void lv_demo_widgets_close(void)
|
||||
{
|
||||
/*Delete all animation*/
|
||||
lv_anim_del(NULL, NULL);
|
||||
|
||||
lv_timer_del(meter2_timer);
|
||||
meter2_timer = NULL;
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
lv_style_reset(&style_text_muted);
|
||||
lv_style_reset(&style_title);
|
||||
lv_style_reset(&style_icon);
|
||||
lv_style_reset(&style_bullet);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@ -205,6 +223,7 @@ static void profile_create(lv_obj_t * parent)
|
||||
lv_obj_t * panel1 = lv_obj_create(parent);
|
||||
lv_obj_set_height(panel1, LV_SIZE_CONTENT);
|
||||
|
||||
|
||||
LV_IMG_DECLARE(img_demo_widgets_avatar);
|
||||
lv_obj_t * avatar = lv_img_create(panel1);
|
||||
lv_img_set_src(avatar, &img_demo_widgets_avatar);
|
||||
@ -698,7 +717,7 @@ static void analytics_create(lv_obj_t * parent)
|
||||
lv_meter_set_indicator_start_value(meter2, meter2_indic[2], 70);
|
||||
lv_meter_set_indicator_end_value(meter2, meter2_indic[2], 99);
|
||||
|
||||
lv_timer_create(meter2_timer_cb, 100, meter2_indic);
|
||||
meter2_timer = lv_timer_create(meter2_timer_cb, 100, meter2_indic);
|
||||
|
||||
meter3 = create_meter_box(parent, "Network Speed", "Low speed", "Normal Speed", "High Speed");
|
||||
if(disp_size < DISP_LARGE) lv_obj_add_flag(lv_obj_get_parent(meter3), LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
|
||||
|
@ -27,6 +27,7 @@ extern "C" {
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_demo_widgets(void);
|
||||
void lv_demo_widgets_close(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -188,6 +188,7 @@ typedef struct _lv_obj_t {
|
||||
uint16_t style_cnt : 6;
|
||||
uint16_t h_layout : 1;
|
||||
uint16_t w_layout : 1;
|
||||
uint16_t being_deleted : 1;
|
||||
} lv_obj_t;
|
||||
|
||||
|
||||
|
@ -360,6 +360,8 @@ static void obj_del_core(lv_obj_t * obj)
|
||||
lv_res_t res = lv_event_send(obj, LV_EVENT_DELETE, NULL);
|
||||
if(res == LV_RES_INV) return;
|
||||
|
||||
obj->being_deleted = 1;
|
||||
|
||||
/*Recursively delete the children*/
|
||||
lv_obj_t * child = lv_obj_get_child(obj, 0);
|
||||
while(child) {
|
||||
|
@ -77,8 +77,8 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name)
|
||||
|
||||
lv_obj_t * btns = lv_tabview_get_tab_btns(obj);
|
||||
|
||||
char ** old_map = tabview->map;
|
||||
char ** new_map;
|
||||
const char ** old_map = (const char **)tabview->map;
|
||||
const char ** new_map;
|
||||
|
||||
/*top or bottom dir*/
|
||||
if(tabview->tab_pos & LV_DIR_VER) {
|
||||
@ -138,6 +138,8 @@ void lv_tabview_rename_tab(lv_obj_t * obj, uint32_t id, const char * new_name)
|
||||
void lv_tabview_set_act(lv_obj_t * obj, uint32_t id, lv_anim_enable_t anim_en)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
if(obj->being_deleted) return;
|
||||
|
||||
lv_tabview_t * tabview = (lv_tabview_t *)obj;
|
||||
|
||||
if(id >= tabview->tab_cnt) {
|
||||
|
@ -27,7 +27,7 @@ extern "C" {
|
||||
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
char ** map;
|
||||
const char ** map;
|
||||
uint16_t tab_cnt;
|
||||
uint16_t tab_cur;
|
||||
lv_dir_t tab_pos;
|
||||
|
Loading…
x
Reference in New Issue
Block a user