diff --git a/index.html b/index.html index 4006b30..4d5b62b 100644 --- a/index.html +++ b/index.html @@ -928,7 +928,7 @@

Compile and Run

Porting

Written for v6.0

System architecture

-

+

Application Your application which creates the GUI and handles the specific tasks.

LittlevGL @@ -1382,7 +1382,7 @@

Using styles

Setting the //glass style property will prevent inheriting that style//. You should use it if the style is transparent so that its children use colors and others from its parent.

Built-in styles

There are several built-in styles in the library:

-

+

As you can see there is a style for screens, for buttons, plain and pretty styles and transparent styles as well. The lv_style_transp, lv_style_transp_fit and lv_style_transp_tight differ only in paddings: for lv_style_transp_tight all padings are zero, for lv_style_transp_fit only hor and ver paddings are zero.

The built in styles are global lv_style_t variables so you can use them like: lv_btn_set_style(obj, LV_BTN_STYLE_REL, &lv_style_btn_rel)

You can modify the built-in styles or you can create new styles. When creating new styles it is recommended to first copy a built-in style to be sure all fields are initialized with a proper value. The lv_style_copy(&dest_style, &src_style) can be used to copy styles.

@@ -1400,7 +1400,7 @@

Style animations

a.repeat_pause = 0; /*Wait before repeat [ms]*/ a.end_cb = NULL; /*Call this function when the animation ready*/

Style example

The example below demonstrates the above-described style usage

-

+

/*Create a style*/
 static lv_style_t style1;
 lv_style_copy(&style1, &lv_style_plain);    /*Copy a built-in style to initialize the new style*/
@@ -1437,7 +1437,7 @@ 

Style animations

theme.btn.tgl_pr /*Toggled pressed button style*/ theme.btn.ina /*Inactive button style*/

A theme can initialized by: lv_theme_xxx_init(hue, font). Where xxx is the name of the theme, hue is a Hue value from HSV color space (0..360) and font is the font applied in the theme (NULL to use the LV_FONT_DEFAULT default font)

When a theme is initialized its styles can be used like this:

-

+

/*Create a default slider*/
 lv_obj_t *slider = lv_slider_create(lv_scr_act(), NULL);
 lv_slider_set_value(slider, 70);
@@ -1860,7 +1860,7 @@ 

Notes

  • Currently the Arc object does not support anti-aliasing.
  • Example

    -

    +

    /*Create style for the Arcs*/
     lv_style_t style;
     lv_style_copy(&style, &lv_style_plain);
    @@ -1901,7 +1901,7 @@ 

    Notes

  • The indicator is not a real object; it is only drawn by the bar.
  • Example

    -

    +

    /*Create a default bar*/
     lv_obj_t * bar1 = lv_bar_create(lv_scr_act(), NULL);
     lv_obj_set_size(bar1, 200, 30);
    @@ -1956,7 +1956,7 @@ 

    Overview

    The object size can be modified with lv_obj_set_width(obj, new_width) and lv_obj_set_height(obj, new_height) or in one function with lv_obj_set_size(obj, new_width, new_height).

    Note that these functions only work for objects with a parent. Screens do not have a parent, and attempting to use these functions will result in undefined behavior.

    You can align the object to an other with lv_obj_align(obj1, obj2, LV_ALIGN_TYPE, x_shift, y_shift). The last two argument means an x and y shift after the alignment. The second argument is another object on which to align the first (NULL means: align to the parent). The third argument is the type of alignment: -

    +

    The alignment types build like: LV_ALIGN_OUT_TOP_MID. For example to align a text below an image: lv_obj_align(text, image, LV_ALIGN_OUT_BOTTOM_MID, 0, 10). Or to align a text in the middle of its parent: lv_obj_align(text, NULL, LV_ALIGN_CENTER, 0, 0).

    You can set a new parent for an object with lv_obj_set_parent(obj, new_parent).

    To get the children of an object use lv_obj_get_child(obj, child_prev) (from last to first) or lv_obj_get_child_back(obj, child_prev) (from first to last). To get the first child pass NULL as the second parameter and then the previous child (return value). The function will return with NULL when there are no more children.

    @@ -1999,7 +1999,7 @@

    Overview

    Style usage

    All style.body properties are used. Default for screens _lv_style_plain_ and _lv_style_plain_color_ for normal objects

    Example

    -

    +

    /*Create a simple base object*/
     lv_obj_t * obj1;
     obj1 = lv_obj_create(lv_scr_act(), NULL);
    @@ -2064,7 +2064,7 @@ 

    Notes

  • If a button was long pressed and its long press action was set then its click action will not be called
  • Example

    -

    +

    static lv_res_t btn_click_action(lv_obj_t * btn)
     {
         uint8_t id = lv_obj_get_free_num(btn);
    @@ -2147,7 +2147,7 @@ 

    Notes

  • The Button matrix object is very light weighted. It creates only the Background Base object and draws the buttons on it instead of creating a lot of real button.
  • Example

    -

    +

    /*Called when a button is released ot long pressed*/
     static lv_res_t btnm_action(lv_obj_t * btnm, const char *txt)
     {
    @@ -2233,7 +2233,7 @@ 

    Style usage

  • LV_CALENDAR_STYLE_TODAY_BOX body and text properties are used to set the style of the today box
  • Example

    -

    +

    /*Create a Calendar object*/
     lv_obj_t * calendar = lv_calendar_create(lv_scr_act(), NULL);
     lv_obj_set_size(calendar, 240, 220);
    @@ -2332,7 +2332,7 @@ 

    Style usage

    The series related parameters can be set directly for each chart with lv_chart_set_series_width(), lv_chart_set_series_opa() and lv_chart_set_series_dark().

    Example

    -

    +

    /*Create a style for the chart*/
     static lv_style_t style;
     lv_style_copy(&style, &lv_style_pretty);
    @@ -2385,7 +2385,7 @@ 

    Style usage

  • LV_CB_STYLE_BOX_TGL_PR Style of the checked released box. Uses the style.body properties. Default: _lv_style_btn_tgl_pr_
  • Example

    -

    +

    static lv_res_t cb_release_action(lv_obj_t * cb)
     {
         /*A check box is clicked*/
    @@ -2466,7 +2466,7 @@ 

    Notes

  • You can't set the child position with hor/ver fit enabled. Let's imagine what happens. If you change the position of the only child when fit is enabled the the container will move/fit "around" the new position. If you have more objects on a container then you can align them relative to each other. As a workaround you can create a small transparent object on the container. It will fix the container to not "follow" the children.
  • Example

    -

    +

    lv_obj_t * box1;
     box1 = lv_cont_create(lv_scr_act(), NULL);
     lv_obj_set_style(box1, &lv_style_pretty);
    @@ -2524,7 +2524,7 @@ 

    Style usage

  • LV_DDLIST_STYLE_SB Style of the scrollbar. The style.body properties are used. Default: _lv_style_plain_color_
  • Example

    -

    +

    static lv_res_t ddlist_action(lv_obj_t * ddlist)
     {
         uint8_t id = lv_obj_get_free_num(ddlist);
    @@ -2583,7 +2583,7 @@ 

    Style usage

  • text.font/color/letter_space label attributes
  • Example

    -

    +

    /*Create a style*/
     static lv_style_t style;
     lv_style_copy(&style, &lv_style_pretty_color);
    @@ -2643,7 +2643,7 @@ 

    Notes

  • Symbols names (like SYMBOL_EDIT) are short strings, therefore, you can concatenate them to show more symbols.
  • Example

    -

    +

    /*Declare a cogwheel image variable*/
     LV_IMG_DECLARE(img_cw);
     
    @@ -2729,7 +2729,7 @@ 

    Style usage

    Notes

    Example

    -

    +

    /*Create style to make the button darker when pressed*/
     lv_style_t style_pr;
     lv_style_copy(&style_pr, &lv_style_plain);
    @@ -2787,7 +2787,7 @@ 

    Style usage

  • LV_KB_STYLE_BTN_INA style of the inactive buttons. Default: _lv_style_btn_ina_
  • Example

    -

    +

    /*Create styles for the keyboard*/
     static lv_style_t rel_style, pr_style;
     
    @@ -2840,7 +2840,7 @@ 

    Notes

  • To modify the height of the buttons adjust the body.padding.ver field of the corresponding style (LV_LIST_STYLE_BTN_REL , LV_LIST_STYLE_BTN_PR etc.)
  • Example

    -

    +

    /*Will be called on click of a button of a list*/
     static lv_res_t list_release_action(lv_obj_t * list_btn)
     {
    @@ -2933,7 +2933,7 @@ 

    Notes

  • Typically the default style is not suitable therefore you have to create you own style. See the Examples.
  • Example

    -

    +

    /*Create a style for the LED*/
     static lv_style_t style_led;
     lv_style_copy(&style_led, &lv_style_pretty_color);
    @@ -2986,7 +2986,7 @@ 

    Style usage

    Notes

    Example

    -

    +

    /*Create an array for the points of the line*/
     static lv_point_t line_points[] = { {5, 5}, {70, 70}, {120, 10}, {180, 60}, {240, 10} };
     
    @@ -3040,7 +3040,7 @@ 

    Notes

  • It looks better if the scale angle is: (line number - 1) * N, where N is an integer
  • Example

    -

    +

    /*******************************
      * Create 3 similar line meter
      *******************************/
    @@ -3149,7 +3149,7 @@ 

    Style usage

    Notes

    The label's click enable attribute is disabled by default. You can enable clicking with lv_obj_set_click(label, true)

    Example

    -

    +

    /*Create label on the screen. By default it will inherit the style of the screen*/
     lv_obj_t * title = lv_label_create(lv_scr_act(), NULL);
     lv_label_set_text(title, "Title Label");
    @@ -3197,7 +3197,7 @@ 

    Notes

  • The height of the buttons comes from the font height + 2 × body.vpad of _LV_MBOX_STYLE_BTN_REL_
  • Example

    -

    +

    /*Called when a button is clicked*/
     static lv_res_t mbox_apply_action(lv_obj_t * mbox, const char * txt)
     {
    @@ -3301,7 +3301,7 @@ 

    Notes

  • The background draws its border when the scrollable is drawn. It ensures that the page always will have closed shape even if the scrollable has the same color as the page's parent.
  • Example

    -

    +

    /*Create a scroll bar style*/
     static lv_style_t style_sb;
     lv_style_copy(&style_sb, &lv_style_plain);
    @@ -3346,7 +3346,7 @@ 

    Style usage

  • border is described by the body.border properties including body.padding.hor/ver (smaller is used) to give a smaller radius for the border.
  • Example

    -

    +

    /*Create a style for the Preloader*/
     static lv_style_t style;
     lv_style_copy(&style, &lv_style_plain);
    @@ -3379,7 +3379,7 @@ 

    Style usage

  • LV_ROLLER_STYLE_SEL Style of the selected option. The style.body properties are used. The selected option will be recolored with text.color. Default: _lv_style_plain_color_
  • Example

    -

    +

    /*Create a default roller*/
     lv_obj_t *roller1 = lv_roller_create(lv_scr_act(), NULL);
     lv_roller_set_options(roller1, "Apple\n"
    @@ -3455,7 +3455,7 @@ 

    Keys

  • LV_KEY_DOWN, LV_KEY_LEFT Decrement the slider's value by 1
  • Example

    -

    +

    /*Called when a new value id set on the slider*/
     static lv_res_t slider_action(lv_obj_t * slider)
     {
    @@ -3565,7 +3565,7 @@ 

    Notes

  • The Knob is not a real object it is only drawn above the Bar
  • Example

    -

    +

    /*Create styles for the switch*/
     static lv_style_t bg_style;
     static lv_style_t indic_style;
    @@ -3629,7 +3629,7 @@ 

    Style usage

    Notes

    Example

    -

    +

    /*Create a Tab view object*/
     lv_obj_t *tabview;
     tabview = lv_tabview_create(lv_scr_act(), NULL);
    @@ -3699,7 +3699,7 @@ 

    Notes

  • In password mode lv_ta_get_text(ta) gives the real text and not the asterisk characters
  • Example

    -

    +

    /*Create a scroll bar style*/
     static lv_style_t style_sb;
     lv_style_copy(&style_sb, &lv_style_plain);
    @@ -3756,7 +3756,7 @@ 

    Style usage

    Notes

    Example

    -

    +

    /*Create a scroll bar style*/
     static lv_style_t style_sb;
     lv_style_copy(&style_sb, &lv_style_plain);