Build a custom widget for the LVGL 7.1.1

I tryed to write this and in simulator…

    lv_obj_t * screen;
    screen = lv_obj_create(lv_scr_act(), NULL);
    lv_obj_set_size(screen, 480, 320);
    lv_obj_align(screen, NULL, LV_ALIGN_CENTER, 0, 0);
    //        lv_obj_set_style_local_bg_color(screen, LV_OBJ_PART_MAIN,   LV_STATE_DEFAULT, LV_COLOR_BLUE);

      
    
    lv_obj_t * gauge;
    gauge = lv_arc_create(screen, NULL);
    lv_obj_set_size(gauge, 250, 250);
    lv_arc_set_angles(gauge, 180, 360);
    lv_arc_set_bg_angles(gauge, 180, 360);
    lv_arc_set_value(gauge, 72);
            
    lv_obj_set_style_local_bg_opa(gauge, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);                      /* remove background arc */
    lv_obj_set_style_local_border_opa(gauge, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);                  /* remove border arc */
    lv_obj_set_style_local_line_color(gauge, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE); /* active line indicator orange */
    lv_obj_set_style_local_line_rounded(gauge, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, false);         /* square line of arc indicator */
    lv_obj_set_style_local_line_rounded(gauge, LV_ARC_PART_BG, LV_STATE_DEFAULT, false);            /* square line of arc bg */
    
    lv_obj_set_style_local_line_width(gauge, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, 40);              /* line more big */
    lv_obj_set_style_local_line_width(gauge, LV_ARC_PART_BG, LV_STATE_DEFAULT, 40);                 /* and bg of arc */
    lv_obj_set_style_local_value_str(gauge, LV_ARC_PART_BG, LV_STATE_DEFAULT, "pounds");            /* text */
    lv_obj_align(gauge, NULL, LV_ALIGN_CENTER, 0, 0);
    
    /* text of value */
    lv_obj_t * txt;
    txt = lv_label_create(screen, NULL);
    lv_label_set_text(txt, "72");
    lv_obj_set_style_local_text_font(txt, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_montserrat_36);
    lv_obj_align(txt, gauge, LV_ALIGN_IN_BOTTOM_MID, 0, -((lv_obj_get_height(gauge)/2)+5));

1 Like