Description
Hi, I am new to LVGL and have tried many of the excellent example widgets with success. I would now like to modify the default font size on a label. My project will have a number of labels which will require local changes to their font size.
What MCU/Processor/Board and compiler are you using?
Teensy 4.0 with Arduino IDE
What LVGL version are you using?
8.0.2
What do you want to achieve?
Locally change font size on labels
What have you tried so far?
I have added the code described in other forum posts but have errors when trying to compile. Without the added lines of code the sketch compiles and runs without problem. Any help would be much appreciated, thanks
Error message with the added lines shown in attached code;
- cannot convert ‘anonymous enum’ to ‘const lv_font_t* {aka const_lv_font_t*}’ for argument ‘2’ to ‘void lv_style_set_text_font(lv_style_t*, const lv_font_t*)’
- cannot convert ‘anonymous enum’ to lv_style_t* for argument ‘2’ to ‘void lv_obj_add_style(_lv_obj_t*, lv_style_t*, lv_style_selector_t)’
/* static void event_handler_1(lv_event_t * event)
{
LV_LOG_USER("Clicked");
static uint8_t cnt1 = 0;//using static means that will read cnt = 0 only once
lv_obj_t * btn1 = lv_event_get_target(event);
lv_obj_t * label1 = lv_obj_get_child(btn1, 0);
lv_label_set_text_fmt(label1, "Auto: %d", cnt1);
cnt1++;
}
void lv_Auto_button(void)
{
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
lv_obj_set_size(btn1, 75,30);
//lv_obj_add_event_cb(btn1, event_handler_1, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btn1, event_handler_1, LV_EVENT_CLICKED, NULL);
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, 80);
lv_obj_t * label1 = lv_label_create(btn1);
lv_label_set_text(label1, "Auto");
lv_obj_center(label1);
static lv_style_t style_label; //added to try and increase font size to montserrat_28
lv_style_init(&style_label); //added to try and increase font size to montserrat_28
lv_style_set_text_font(&style_label, LV_STATE_DEFAULT, &lv_font_montserrat_28);//added to try and increase font size to montserrat_28
lv_obj_t * label4 = lv_label_create(lv_scr_act());
lv_obj_add_style(label4, LV_STATE_DEFAULT, &style_label);//added to try and increase font size to montserrat_28
lv_label_set_text(label4, "DISTANCE");
lv_obj_set_style_text_align(label4, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_align(label4, LV_ALIGN_CENTER, 0,-80);
}*/
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.