hello everyone ive faced problem with this task
i have method that creates buttons with labels and returns label pointer as return value. so i can change its text and implement pushbutton callback.
also i am trying to work with calendar object, but when i am trying to (for example) lv_set_pos. ive got segmentation fault.
I cant find how to work with objects in lvgl properly, As example here`s code
(return btn) btn pointer is a global var so i can work with it later.
lv_obj_t * createstyledbutton_ret_btn(lv_obj_t * btn,lv_obj_t * par,lv_style_t* style, lv_coord_t pos_x,lv_coord_t pos_y,lv_coord_t size_wide,lv_coord_t size_height,char btn_text[],lv_event_cb_t event_call_back_function)
{
btn = lv_btn_create(par, NULL);
lv_obj_add_style( btn, LV_OBJ_PART_MAIN,style);
lv_obj_add_protect(btn, LV_PROTECT_CLICK_FOCUS);
lv_obj_align(btn, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_pos(btn, pos_x, pos_y);
lv_obj_set_size(btn,size_wide, size_height);
lv_obj_set_event_cb(btn, event_call_back_function); /*Assign a callback to the button*/
lv_obj_t * label = lv_label_create(btn, NULL); /*Add a label to the button*/
// lv_obj_align( label, NULL, allign, 0, 0 );
lv_label_set_text(label, btn_text); /*Set the labels text*/
return btn;
`}
also i have calendar init method (where ive added return and input pointer but if i try to change calendar`s settings, ive got segmentation fault)
lv_obj_t* lv_ex_calendar_2(lv_obj_t* calendar)
{
calendar = lv_calendar_create(tab0, NULL);
lv_obj_set_size(calendar, 600, 600);
//lv_obj_align(calendar, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_pos(calendar,-600,10);
lv_obj_set_event_cb(calendar, calendar_event_handler);
/*Make the date number smaller to be sure they fit into their area*/
lv_obj_set_style_local_text_font(calendar, LV_CALENDAR_PART_DATE, LV_STATE_DEFAULT, lv_theme_get_font_small());
/*Set today's date*/
lv_calendar_date_t today;
today.year = 2021;
today.month = 10;
today.day = 23;
lv_calendar_set_today_date(calendar, &today);
lv_calendar_set_showed_date(calendar, &today);
return calendar;
}
but i am using pointers as input. so should i use pointers to pointers? seems method creates own pointer(different from global)