Skip to content

Commit

Permalink
Menu: Move rt_timer to user_data
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryzee119 committed Apr 7, 2022
1 parent f64aed3 commit bf00ffb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dash_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

static lv_obj_t *main_menu;
static lv_obj_t *rt_info;
static lv_timer_t *rt_info_timer;

typedef struct
{
Expand Down Expand Up @@ -128,8 +127,9 @@ static void close_callback(lv_event_t *e)
{
if (obj == main_menu)
{
lv_obj_del(rt_info);
lv_timer_t *rt_info_timer = (lv_timer_t *)rt_info->user_data;
lv_timer_del(rt_info_timer);
lv_obj_del_async(rt_info);
//Main menu is about to be deleted, invalidate this pointer.
main_menu = NULL;
rt_info = NULL;
Expand Down Expand Up @@ -356,7 +356,8 @@ void main_menu_open()
lv_obj_add_style(rt_info, &rtinfo_style, LV_PART_MAIN);
lv_obj_set_width(rt_info, MAINMENU_WIDTH);
lv_obj_set_style_text_align(rt_info, LV_TEXT_ALIGN_LEFT, 0);
rt_info_timer = lv_timer_create(realtime_info_cb, 2000, rt_info);
lv_timer_t *rt_info_timer = lv_timer_create(realtime_info_cb, 2000, rt_info);
rt_info->user_data = rt_info_timer;
lv_timer_ready(rt_info_timer);
}

Expand Down

0 comments on commit bf00ffb

Please sign in to comment.