「App:Library:LVGL:docs:Overview:Displays」の版間の差分

提供: robot-jp wiki
ナビゲーションに移動検索に移動
(ページの作成:「https://docs.lvgl.io/8.2/overview/style.html __NOTOC__ {| class="wikitable" !英文 !自動翻訳 |- | | |} :戻る : Previous」)
 
9行目: 9行目:
 
|}
 
|}
  
 +
 +
 +
= Displays =
 +
Important
 +
 +
The basic concept of a ''display'' in LVGL is explained in the [Porting](/porting/display) section. So before reading further, please read the [Porting](/porting/display) section first.
 +
 +
== Multiple display support ==
 +
In LVGL you can have multiple displays, each with their own driver and objects. The only limitation is that every display needs to have the same color depth (as defined in <code>LV_COLOR_DEPTH</code>). If the displays are different in this regard the rendered image can be converted to the correct format in the drivers <code>flush_cb</code>.
 +
 +
Creating more displays is easy: just initialize more display buffers and register another driver for every display. When you create the UI, use <code>lv_disp_set_default(disp)</code> to tell the library on which display to create objects.
 +
 +
Why would you want multi-display support? Here are some examples:
 +
 +
* Have a "normal" TFT display with local UI and create "virtual" screens on VNC on demand. (You need to add your VNC driver).
 +
* Have a large TFT display and a small monochrome display.
 +
* Have some smaller and simple displays in a large instrument or technology.
 +
* Have two large TFT displays: one for a customer and one for the shop assistant.
 +
 +
=== Using only one display ===
 +
Using more displays can be useful but in most cases it's not required. Therefore, the whole concept of multi-display handling is completely hidden if you register only one display. By default, the last created (and only) display is used.
 +
 +
<code>lv_scr_act()</code>, <code>lv_scr_load(scr)</code>, <code>lv_layer_top()</code>, <code>lv_layer_sys()</code>, <code>LV_HOR_RES</code> and <code>LV_VER_RES</code> are always applied on the most recently created (default) display. If you pass <code>NULL</code> as <code>disp</code> parameter to display related functions the default display will usually be used. E.g. <code>lv_disp_trig_activity(NULL)</code> will trigger a user activity on the default display. (See below in Inactivity).
 +
 +
=== Mirror display ===
 +
To mirror the image of a display to another display, you don't need to use multi-display support. Just transfer the buffer received in <code>drv.flush_cb</code> to the other display too.
 +
 +
=== Split image ===
 +
You can create a larger virtual display from an array of smaller ones. You can create it as below:
 +
 +
# Set the resolution of the displays to the large display's resolution.
 +
# In <code>drv.flush_cb</code>, truncate and modify the <code>area</code> parameter for each display.
 +
# Send the buffer's content to each real display with the truncated area.
 +
 +
== Screens ==
 +
Every display has its own set of screens and the objects on each screen.
 +
 +
Be sure not to confuse displays and screens:
 +
 +
* Displays are the physical hardware drawing the pixels.
 +
* Screens are the high-level root objects associated with a particular display. One display can have multiple screens associated with it, but not vice versa.
 +
 +
Screens can be considered the highest level containers which have no parent. A screen's size is always equal to its display and their origin is (0;0). Therefore, a screen's coordinates can't be changed, i.e. <code>lv_obj_set_pos()</code>, <code>lv_obj_set_size()</code> or similar functions can't be used on screens.
 +
 +
A screen can be created from any object type but the two most typical types are Base object and Image (to create a wallpaper).
 +
 +
To create a screen, use <code>lv_obj_t * scr = lv_<type>_create(NULL, copy)</code>. <code>copy</code> can be an existing screen copied into the new screen.
 +
 +
To load a screen, use <code>lv_scr_load(scr)</code>. To get the active screen, use <code>lv_scr_act()</code>. These functions work on the default display. If you want to specify which display to work on, use <code>lv_disp_get_scr_act(disp)</code> and <code>lv_disp_load_scr(disp, scr)</code>. A screen can be loaded with animations too. Read more here.
 +
 +
Screens can be deleted with <code>lv_obj_del(scr)</code>, but ensure that you do not delete the currently loaded screen.
 +
 +
=== Transparent screens ===
 +
Usually, the opacity of the screen is <code>LV_OPA_COVER</code> to provide a solid background for its children. If this is not the case (opacity < 100%) the display's background color or image will be visible. See the Display background section for more details. If the display's background opacity is also not <code>LV_OPA_COVER</code> LVGL has no solid background to draw.
 +
 +
This configuration (transparent screen and display) could be used to create for example OSD menus where a video is played on a lower layer, and a menu is overlayed on an upper layer.
 +
 +
To handle transparent displays, special (slower) color mixing algorithms need to be used by LVGL so this feature needs to enabled with <code>LV_COLOR_SCREEN_TRANSP</code> in <code>lv_conf.h</code>. As this mode operates on the Alpha channel of the pixels <code>LV_COLOR_DEPTH = 32</code> is also required. The Alpha channel of 32-bit colors will be 0 where there are no objects and 255 where there are solid objects.
 +
 +
In summary, to enable transparent screens and displays for OSD menu-like UIs:
 +
 +
* Enable <code>LV_COLOR_SCREEN_TRANSP</code> in <code>lv_conf.h</code>
 +
* Be sure to use <code>LV_COLOR_DEPTH 32</code>
 +
* Set the screen's opacity to <code>LV_OPA_TRANSP</code> e.g. with <code>lv_obj_set_style_local_bg_opa(lv_scr_act(), LV_OBJMASK_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP)</code>
 +
* Set the display opacity to <code>LV_OPA_TRANSP</code> with <code>lv_disp_set_bg_opa(NULL, LV_OPA_TRANSP);</code>
 +
 +
== Features of displays ==
 +
 +
=== Inactivity ===
 +
A user's inactivity time is measured on each display. Every use of an Input device (if associated with the display) counts as an activity. To get time elapsed since the last activity, use <code>lv_disp_get_inactive_time(disp)</code>. If <code>NULL</code> is passed, the lowest inactivity time among all displays will be returned (NULL isn't just the default display).
 +
 +
You can manually trigger an activity using <code>lv_disp_trig_activity(disp)</code>. If <code>disp</code> is <code>NULL</code>, the default screen will be used (and not all displays).
 +
 +
=== Background ===
 +
Every display has a background color, background image and background opacity properties. They become visible when the current screen is transparent or not positioned to cover the whole display.
 +
 +
The background color is a simple color to fill the display. It can be adjusted with <code>lv_disp_set_bg_color(disp, color)</code>;
 +
 +
The display background image is a path to a file or a pointer to an <code>lv_img_dsc_t</code> variable (converted image data) to be used as wallpaper. It can be set with <code>lv_disp_set_bg_image(disp, &my_img)</code>; If a background image is configured the background won't be filled with <code>bg_color</code>.
 +
 +
The opacity of the background color or image can be adjusted with <code>lv_disp_set_bg_opa(disp, opa)</code>.
 +
 +
The <code>disp</code> parameter of these functions can be <code>NULL</code> to select the default display.
 +
 +
== API ==
 +
Enums
 +
 +
; <span id="_CPPv318lv_scr_load_anim_t"></span><span id="_CPPv218lv_scr_load_anim_t"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06e" class="target"></span>enum lv_scr_load_anim_t[https://docs.lvgl.io/8.2/overview/display.html#_CPPv418lv_scr_load_anim_t] <span id="_CPPv318lv_scr_load_anim_t"></span><span id="_CPPv218lv_scr_load_anim_t"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06e" class="target"></span>
 +
: ''Values:''
 +
:; <span id="_CPPv3N18lv_scr_load_anim_t21LV_SCR_LOAD_ANIM_NONEE"></span><span id="_CPPv2N18lv_scr_load_anim_t21LV_SCR_LOAD_ANIM_NONEE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06eac4d7241159e71b5710d9d2dfea9c9e49" class="target"></span>enumerat[https://docs.lvgl.io/8.2/overview/display.html#_CPPv418lv_scr_load_anim_t]or LV_SCR_LOAD_ANIM_NONE[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t21LV_SCR_LOAD_ANIM_NONEE] <span id="_CPPv3N18lv_scr_load_anim_t21LV_SCR_LOAD_ANIM_NONEE"></span><span id="_CPPv2N18lv_scr_load_anim_t21LV_SCR_LOAD_ANIM_NONEE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06eac4d7241159e71b5710d9d2dfea9c9e49" class="target"></span>
 +
::
 +
:; <span id="_CPPv3N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_OVER_LEFTE"></span><span id="_CPPv2N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_OVER_LEFTE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06eaaf8a8c0cbd838d201013910ea07704ac" class="target"></span>enumerator LV_SCR_LOAD[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t21LV_SCR_LOAD_ANIM_NONEE]_ANIM_OVER_LEFT[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_OVER_LEFTE] <span id="_CPPv3N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_OVER_LEFTE"></span><span id="_CPPv2N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_OVER_LEFTE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06eaaf8a8c0cbd838d201013910ea07704ac" class="target"></span>
 +
::
 +
:; <span id="_CPPv3N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_OVER_RIGHTE"></span><span id="_CPPv2N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_OVER_RIGHTE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea4451ce2c951da3d701c13b78b9110d12" class="target"></span>enumerator LV_SCR_LOAD_ANIM[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_OVER_LEFTE]_OVER_RIGHT[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_OVER_RIGHTE] <span id="_CPPv3N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_OVER_RIGHTE"></span><span id="_CPPv2N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_OVER_RIGHTE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea4451ce2c951da3d701c13b78b9110d12" class="target"></span>
 +
::
 +
:; <span id="_CPPv3N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_OVER_TOPE"></span><span id="_CPPv2N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_OVER_TOPE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea8033a9cb143ebbbce6849324b3c33315" class="target"></span>enumerator LV_SCR_LOAD_ANIM_[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_OVER_RIGHTE]OVER_TOP[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_OVER_TOPE] <span id="_CPPv3N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_OVER_TOPE"></span><span id="_CPPv2N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_OVER_TOPE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea8033a9cb143ebbbce6849324b3c33315" class="target"></span>
 +
::
 +
:; <span id="_CPPv3N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_OVER_BOTTOME"></span><span id="_CPPv2N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_OVER_BOTTOME"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea84d9244e123dd83ec0e9e5401c988711" class="target"></span>enumerator LV_SCR_LOAD_ANI[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_OVER_TOPE]M_OVER_BOTTOM[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_OVER_BOTTOME] <span id="_CPPv3N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_OVER_BOTTOME"></span><span id="_CPPv2N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_OVER_BOTTOME"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea84d9244e123dd83ec0e9e5401c988711" class="target"></span>
 +
::
 +
:; <span id="_CPPv3N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_MOVE_LEFTE"></span><span id="_CPPv2N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_MOVE_LEFTE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea8e90694b82fac8a4108dfd3d2c9c513e" class="target"></span>enumerator LV_SCR_LOAD_ANIM_M[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_OVER_BOTTOME]OVE_LEFT[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_MOVE_LEFTE] <span id="_CPPv3N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_MOVE_LEFTE"></span><span id="_CPPv2N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_MOVE_LEFTE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea8e90694b82fac8a4108dfd3d2c9c513e" class="target"></span>
 +
::
 +
:; <span id="_CPPv3N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_MOVE_RIGHTE"></span><span id="_CPPv2N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_MOVE_RIGHTE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06eaf35915bc6d1ac1c08575d6492fb4b752" class="target"></span>enumerator LV_SCR_LOAD_ANIM[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t26LV_SCR_LOAD_ANIM_MOVE_LEFTE]_MOVE_RIGHT[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_MOVE_RIGHTE] <span id="_CPPv3N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_MOVE_RIGHTE"></span><span id="_CPPv2N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_MOVE_RIGHTE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06eaf35915bc6d1ac1c08575d6492fb4b752" class="target"></span>
 +
::
 +
:; <span id="_CPPv3N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_MOVE_TOPE"></span><span id="_CPPv2N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_MOVE_TOPE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea7ce2102f40dd52daa98854e85a341d29" class="target"></span>enumerator LV_SCR_LOAD_ANIM_[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t27LV_SCR_LOAD_ANIM_MOVE_RIGHTE]MOVE_TOP[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_MOVE_TOPE] <span id="_CPPv3N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_MOVE_TOPE"></span><span id="_CPPv2N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_MOVE_TOPE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea7ce2102f40dd52daa98854e85a341d29" class="target"></span>
 +
::
 +
:; <span id="_CPPv3N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_MOVE_BOTTOME"></span><span id="_CPPv2N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_MOVE_BOTTOME"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06eaceab5be119341c6f2a22c91cd3a1ec52" class="target"></span>enumerator LV_SCR_LOAD_ANI[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t25LV_SCR_LOAD_ANIM_MOVE_TOPE]M_MOVE_BOTTOM[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_MOVE_BOTTOME] <span id="_CPPv3N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_MOVE_BOTTOME"></span><span id="_CPPv2N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_MOVE_BOTTOME"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06eaceab5be119341c6f2a22c91cd3a1ec52" class="target"></span>
 +
::
 +
:; <span id="_CPPv3N18lv_scr_load_anim_t24LV_SCR_LOAD_ANIM_FADE_ONE"></span><span id="_CPPv2N18lv_scr_load_anim_t24LV_SCR_LOAD_ANIM_FADE_ONE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea3e415bd11c085aff5bc42db7f945695d" class="target"></span>enumerator LV_SCR_LOAD_ANIM_F[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t28LV_SCR_LOAD_ANIM_MOVE_BOTTOME]ADE_ON[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t24LV_SCR_LOAD_ANIM_FADE_ONE] <span id="_CPPv3N18lv_scr_load_anim_t24LV_SCR_LOAD_ANIM_FADE_ONE"></span><span id="_CPPv2N18lv_scr_load_anim_t24LV_SCR_LOAD_ANIM_FADE_ONE"></span><span id="lv__disp_8h_1a0f753e364206eb26e1ad7c10d737b06ea3e415bd11c085aff5bc42db7f945695d" class="target"></span>
 +
::
 +
 +
Functions
 +
 +
; <span id="_CPPv319lv_disp_get_scr_actP9lv_disp_t"></span><span id="_CPPv219lv_disp_get_scr_actP9lv_disp_t"></span><span id="lv_disp_get_scr_act__lv_disp_tP"></span><span id="lv__disp_8h_1aabefd7ce9a47f468b779dcad4372df2a" class="target"></span>lv_obj_t *lv[https://docs.lvgl.io/8.2/overview/display.html#_CPPv4N18lv_scr_load_anim_t24LV_SCR_LOAD_ANIM_FADE_ONE]_disp_get_scr_act(lv_disp_t *disp)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv419lv_disp_get_scr_actP9lv_disp_t] <span id="_CPPv319lv_disp_get_scr_actP9lv_disp_t"></span><span id="_CPPv219lv_disp_get_scr_actP9lv_disp_t"></span><span id="lv_disp_get_scr_act__lv_disp_tP"></span><span id="lv__disp_8h_1aabefd7ce9a47f468b779dcad4372df2a" class="target"></span>
 +
: Return with a pointer to the active screen[https://docs.lvgl.io/8.2/overview/display.html#_CPPv419lv_disp_get_scr_actP9lv_disp_t]
 +
:; Parameters
 +
:: disp -- pointer to display which active screen should be get. (NULL to use the default screen)
 +
:; Returns
 +
:: pointer to the active screen object (loaded by 'lv_scr_load()')
 +
 +
; <span id="_CPPv320lv_disp_get_scr_prevP9lv_disp_t"></span><span id="_CPPv220lv_disp_get_scr_prevP9lv_disp_t"></span><span id="lv_disp_get_scr_prev__lv_disp_tP"></span><span id="lv__disp_8h_1a5b5470e277e2802fd2ab1b39a1f18219" class="target"></span>lv_obj_t *lv_disp_get_scr_prev(lv_disp_t *disp)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv420lv_disp_get_scr_prevP9lv_disp_t] <span id="_CPPv320lv_disp_get_scr_prevP9lv_disp_t"></span><span id="_CPPv220lv_disp_get_scr_prevP9lv_disp_t"></span><span id="lv_disp_get_scr_prev__lv_disp_tP"></span><span id="lv__disp_8h_1a5b5470e277e2802fd2ab1b39a1f18219" class="target"></span>
 +
: Return with a pointer to the previous scree[https://docs.lvgl.io/8.2/overview/display.html#_CPPv420lv_disp_get_scr_prevP9lv_disp_t]n. Only used during screen transitions.
 +
:; Parameters
 +
:: disp -- pointer to display which previous screen should be get. (NULL to use the default screen)
 +
:; Returns
 +
:: pointer to the previous screen object or NULL if not used now
 +
 +
; <span id="_CPPv316lv_disp_load_scrP8lv_obj_t"></span><span id="_CPPv216lv_disp_load_scrP8lv_obj_t"></span><span id="lv_disp_load_scr__lv_obj_tP"></span><span id="lv__disp_8h_1a77dbb02b01dd121e3ff923d7a0182341" class="target"></span>void lv_disp_load_scr(lv_obj_t *scr)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv416lv_disp_load_scrP8lv_obj_t] <span id="_CPPv316lv_disp_load_scrP8lv_obj_t"></span><span id="_CPPv216lv_disp_load_scrP8lv_obj_t"></span><span id="lv_disp_load_scr__lv_obj_tP"></span><span id="lv__disp_8h_1a77dbb02b01dd121e3ff923d7a0182341" class="target"></span>
 +
: Make a screen active
 +
:; Paramete[https://docs.lvgl.io/8.2/overview/display.html#_CPPv416lv_disp_load_scrP8lv_obj_t]rs
 +
:: scr -- pointer to a screen
 +
 +
; <span id="_CPPv321lv_disp_get_layer_topP9lv_disp_t"></span><span id="_CPPv221lv_disp_get_layer_topP9lv_disp_t"></span><span id="lv_disp_get_layer_top__lv_disp_tP"></span><span id="lv__disp_8h_1abb96745c10c7d8b5d7acc93e70584145" class="target"></span>lv_obj_t *lv_disp_get_layer_top(lv_disp_t *disp)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv421lv_disp_get_layer_topP9lv_disp_t] <span id="_CPPv321lv_disp_get_layer_topP9lv_disp_t"></span><span id="_CPPv221lv_disp_get_layer_topP9lv_disp_t"></span><span id="lv_disp_get_layer_top__lv_disp_tP"></span><span id="lv__disp_8h_1abb96745c10c7d8b5d7acc93e70584145" class="target"></span>
 +
: Return with the top layer. (Same on every sc[https://docs.lvgl.io/8.2/overview/display.html#_CPPv421lv_disp_get_layer_topP9lv_disp_t]reen and it is above the normal screen layer)
 +
:; Parameters
 +
:: disp -- pointer to display which top layer should be get. (NULL to use the default screen)
 +
:; Returns
 +
:: pointer to the top layer object (transparent screen sized lv_obj)
 +
 +
; <span id="_CPPv321lv_disp_get_layer_sysP9lv_disp_t"></span><span id="_CPPv221lv_disp_get_layer_sysP9lv_disp_t"></span><span id="lv_disp_get_layer_sys__lv_disp_tP"></span><span id="lv__disp_8h_1ae9a48f536aab873d71c07c313c4e433e" class="target"></span>lv_obj_t *lv_disp_get_layer_sys(lv_disp_t *disp)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv421lv_disp_get_layer_sysP9lv_disp_t] <span id="_CPPv321lv_disp_get_layer_sysP9lv_disp_t"></span><span id="_CPPv221lv_disp_get_layer_sysP9lv_disp_t"></span><span id="lv_disp_get_layer_sys__lv_disp_tP"></span><span id="lv__disp_8h_1ae9a48f536aab873d71c07c313c4e433e" class="target"></span>
 +
: Return with the sys. layer. (Same on every s[https://docs.lvgl.io/8.2/overview/display.html#_CPPv421lv_disp_get_layer_sysP9lv_disp_t]creen and it is above the normal screen and the top layer)
 +
:; Parameters
 +
:: disp -- pointer to display which sys. layer should be retrieved. (NULL to use the default screen)
 +
:; Returns
 +
:: pointer to the sys layer object (transparent screen sized lv_obj)
 +
 +
; <span id="_CPPv317lv_disp_set_themeP9lv_disp_tP10lv_theme_t"></span><span id="_CPPv217lv_disp_set_themeP9lv_disp_tP10lv_theme_t"></span><span id="lv_disp_set_theme__lv_disp_tP.lv_theme_tP"></span><span id="lv__disp_8h_1a88eb1d18c3ce9dd2de868b5b4c3347af" class="target"></span>void lv_disp_set_theme(lv_disp_t *disp, lv_theme_t *th)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv417lv_disp_set_themeP9lv_disp_tP10lv_theme_t] <span id="_CPPv317lv_disp_set_themeP9lv_disp_tP10lv_theme_t"></span><span id="_CPPv217lv_disp_set_themeP9lv_disp_tP10lv_theme_t"></span><span id="lv_disp_set_theme__lv_disp_tP.lv_theme_tP"></span><span id="lv__disp_8h_1a88eb1d18c3ce9dd2de868b5b4c3347af" class="target"></span>
 +
: Set the theme of a display
 +
:; Parameters
 +
:: disp --[https://docs.lvgl.io/8.2/overview/display.html#_CPPv417lv_disp_set_themeP9lv_disp_tP10lv_theme_t] pointer to a display
 +
 +
; <span id="_CPPv317lv_disp_get_themeP9lv_disp_t"></span><span id="_CPPv217lv_disp_get_themeP9lv_disp_t"></span><span id="lv_disp_get_theme__lv_disp_tP"></span><span id="lv__disp_8h_1ade6752f9389f3e2e6aef5c0413c91934" class="target"></span>lv_theme_t *lv_disp_get_theme(lv_disp_t *disp)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv417lv_disp_get_themeP9lv_disp_t] <span id="_CPPv317lv_disp_get_themeP9lv_disp_t"></span><span id="_CPPv217lv_disp_get_themeP9lv_disp_t"></span><span id="lv_disp_get_theme__lv_disp_tP"></span><span id="lv__disp_8h_1ade6752f9389f3e2e6aef5c0413c91934" class="target"></span>
 +
: Get the theme of a display
 +
:; Parameters
 +
[https://docs.lvgl.io/8.2/overview/display.html#_CPPv417lv_disp_get_themeP9lv_disp_t]
 +
:: disp -- pointer to a display
 +
:; Returns
 +
:: the display's theme (can be NULL)
 +
 +
; <span id="_CPPv320lv_disp_set_bg_colorP9lv_disp_t10lv_color_t"></span><span id="_CPPv220lv_disp_set_bg_colorP9lv_disp_t10lv_color_t"></span><span id="lv_disp_set_bg_color__lv_disp_tP.lv_color_t"></span><span id="lv__disp_8h_1aa5d66786eac6c09b625a4ad14c78b5da" class="target"></span>void lv_disp_set_bg_color(lv_disp_t *disp, lv_color_t color)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv420lv_disp_set_bg_colorP9lv_disp_t10lv_color_t] <span id="_CPPv320lv_disp_set_bg_colorP9lv_disp_t10lv_color_t"></span><span id="_CPPv220lv_disp_set_bg_colorP9lv_disp_t10lv_color_t"></span><span id="lv_disp_set_bg_color__lv_disp_tP.lv_color_t"></span><span id="lv__disp_8h_1aa5d66786eac6c09b625a4ad14c78b5da" class="target"></span>
 +
: Set the background color of a display
 +
:; Parameters
 +
::* [https://docs.lvgl.io/8.2/overview/display.html#_CPPv420lv_disp_set_bg_colorP9lv_disp_t10lv_color_t] disp -- pointer to a display
 +
::* color -- color of the background
 +
 +
; <span id="_CPPv320lv_disp_set_bg_imageP9lv_disp_tPKv"></span><span id="_CPPv220lv_disp_set_bg_imageP9lv_disp_tPKv"></span><span id="lv_disp_set_bg_image__lv_disp_tP.voidCP"></span><span id="lv__disp_8h_1ad4726ee5585141717f1a92d78644f9c2" class="target"></span>void lv_disp_set_bg_image(lv_disp_t *disp, const void *img_src)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv420lv_disp_set_bg_imageP9lv_disp_tPKv] <span id="_CPPv320lv_disp_set_bg_imageP9lv_disp_tPKv"></span><span id="_CPPv220lv_disp_set_bg_imageP9lv_disp_tPKv"></span><span id="lv_disp_set_bg_image__lv_disp_tP.voidCP"></span><span id="lv__disp_8h_1ad4726ee5585141717f1a92d78644f9c2" class="target"></span>
 +
: Set the background image of a display
 +
:; Parameters
 +
::* di[https://docs.lvgl.io/8.2/overview/display.html#_CPPv420lv_disp_set_bg_imageP9lv_disp_tPKv]sp -- pointer to a display
 +
::* img_src -- path to file or pointer to an <code>lv_img_dsc_t</code> variable
 +
 +
; <span id="_CPPv318lv_disp_set_bg_opaP9lv_disp_t8lv_opa_t"></span><span id="_CPPv218lv_disp_set_bg_opaP9lv_disp_t8lv_opa_t"></span><span id="lv_disp_set_bg_opa__lv_disp_tP.lv_opa_t"></span><span id="lv__disp_8h_1a80edf118ea4b29b9267c6df493123ca1" class="target"></span>void lv_disp_set_bg_opa(lv_disp_t *disp, lv_opa_t opa)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv418lv_disp_set_bg_opaP9lv_disp_t8lv_opa_t] <span id="_CPPv318lv_disp_set_bg_opaP9lv_disp_t8lv_opa_t"></span><span id="_CPPv218lv_disp_set_bg_opaP9lv_disp_t8lv_opa_t"></span><span id="lv_disp_set_bg_opa__lv_disp_tP.lv_opa_t"></span><span id="lv__disp_8h_1a80edf118ea4b29b9267c6df493123ca1" class="target"></span>
 +
: Set opacity of the background
 +
:; Parameters
 +
::* d[https://docs.lvgl.io/8.2/overview/display.html#_CPPv418lv_disp_set_bg_opaP9lv_disp_t8lv_opa_t]isp -- pointer to a display
 +
::* opa -- opacity (0..255)
 +
 +
; <span id="_CPPv316lv_scr_load_animP8lv_obj_t18lv_scr_load_anim_t8uint32_t8uint32_tb"></span><span id="_CPPv216lv_scr_load_animP8lv_obj_t18lv_scr_load_anim_t8uint32_t8uint32_tb"></span><span id="lv_scr_load_anim__lv_obj_tP.lv_scr_load_anim_t.uint32_t.uint32_t.b"></span><span id="lv__disp_8h_1a34d6349247c52a4c149cabdb1319c8a0" class="target"></span>void lv_scr_load_anim(lv_obj_t *scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv416lv_scr_load_animP8lv_obj_t18lv_scr_load_anim_t8uint32_t8uint32_tb] <span id="_CPPv316lv_scr_load_animP8lv_obj_t18lv_scr_load_anim_t8uint32_t8uint32_tb"></span><span id="_CPPv216lv_scr_load_animP8lv_obj_t18lv_scr_load_anim_t8uint32_t8uint32_tb"></span><span id="lv_scr_load_anim__lv_obj_tP.lv_scr_load_anim_t.uint32_t.uint32_t.b"></span><span id="lv__disp_8h_1a34d6349247c52a4c149cabdb1319c8a0" class="target"></span>
 +
: Switch screen with animation
 +
:; Parameters
 +
::* scr -- pointer to the new screen to load
 +
::* anim_type -- typ[https://docs.lvgl.io/8.2/overview/display.html#_CPPv416lv_scr_load_animP8lv_obj_t18lv_scr_load_anim_t8uint32_t8uint32_tb]e of the animation from <code>lv_scr_load_anim_t</code>. E.g. <code>LV_SCR_LOAD_ANIM_MOVE_LEFT</code>
 +
::* time -- time of the animation
 +
::* delay -- delay before the transition
 +
::* auto_del -- true: automatically delete the old screen
 +
 +
; <span id="_CPPv325lv_disp_get_inactive_timePK9lv_disp_t"></span><span id="_CPPv225lv_disp_get_inactive_timePK9lv_disp_t"></span><span id="lv_disp_get_inactive_time__lv_disp_tCP"></span><span id="lv__disp_8h_1a4ae9136128a901bf5b37f23672842f0d" class="target"></span>uint32_t lv_disp_get_inactive_time(const lv_disp_t *disp)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv425lv_disp_get_inactive_timePK9lv_disp_t] <span id="_CPPv325lv_disp_get_inactive_timePK9lv_disp_t"></span><span id="_CPPv225lv_disp_get_inactive_timePK9lv_disp_t"></span><span id="lv_disp_get_inactive_time__lv_disp_tCP"></span><span id="lv__disp_8h_1a4ae9136128a901bf5b37f23672842f0d" class="target"></span>
 +
: Get elapsed time since last user activity on a displa[https://docs.lvgl.io/8.2/overview/display.html#_CPPv425lv_disp_get_inactive_timePK9lv_disp_t]y (e.g. click)
 +
:; Parameters
 +
:: disp -- pointer to a display (NULL to get the overall smallest inactivity)
 +
:; Returns
 +
:: elapsed ticks (milliseconds) since the last activity
 +
 +
; <span id="_CPPv321lv_disp_trig_activityP9lv_disp_t"></span><span id="_CPPv221lv_disp_trig_activityP9lv_disp_t"></span><span id="lv_disp_trig_activity__lv_disp_tP"></span><span id="lv__disp_8h_1a44083753547903dc975e6ec29b4ea280" class="target"></span>void lv_disp_trig_activity(lv_disp_t *disp)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv421lv_disp_trig_activityP9lv_disp_t] <span id="_CPPv321lv_disp_trig_activityP9lv_disp_t"></span><span id="_CPPv221lv_disp_trig_activityP9lv_disp_t"></span><span id="lv_disp_trig_activity__lv_disp_tP"></span><span id="lv__disp_8h_1a44083753547903dc975e6ec29b4ea280" class="target"></span>
 +
: Manually trigger an activity on a displ[https://docs.lvgl.io/8.2/overview/display.html#_CPPv421lv_disp_trig_activityP9lv_disp_t]ay
 +
:; Parameters
 +
:: disp -- pointer to a display (NULL to use the default display)
 +
 +
; <span id="_CPPv320lv_disp_clean_dcacheP9lv_disp_t"></span><span id="_CPPv220lv_disp_clean_dcacheP9lv_disp_t"></span><span id="lv_disp_clean_dcache__lv_disp_tP"></span><span id="lv__disp_8h_1a3a3770903c53e8d7fbf47555bfdb152b" class="target"></span>void lv_disp_clean_dcache(lv_disp_t *disp)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv420lv_disp_clean_dcacheP9lv_disp_t] <span id="_CPPv320lv_disp_clean_dcacheP9lv_disp_t"></span><span id="_CPPv220lv_disp_clean_dcacheP9lv_disp_t"></span><span id="lv_disp_clean_dcache__lv_disp_tP"></span><span id="lv__disp_8h_1a3a3770903c53e8d7fbf47555bfdb152b" class="target"></span>
 +
: Clean any CPU cache that is related to[https://docs.lvgl.io/8.2/overview/display.html#_CPPv420lv_disp_clean_dcacheP9lv_disp_t] the display.
 +
:; Parameters
 +
:: disp -- pointer to a display (NULL to use the default display)
 +
 +
; <span id="_CPPv323_lv_disp_get_refr_timerP9lv_disp_t"></span><span id="_CPPv223_lv_disp_get_refr_timerP9lv_disp_t"></span><span id="_lv_disp_get_refr_timer__lv_disp_tP"></span><span id="lv__disp_8h_1ac7a44c2ea827ab4174a0a1a706d065c2" class="target"></span>lv_timer_t *_lv_disp_get_refr_timer(lv_disp_t *disp)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv423_lv_disp_get_refr_timerP9lv_disp_t] <span id="_CPPv323_lv_disp_get_refr_timerP9lv_disp_t"></span><span id="_CPPv223_lv_disp_get_refr_timerP9lv_disp_t"></span><span id="_lv_disp_get_refr_timer__lv_disp_tP"></span><span id="lv__disp_8h_1ac7a44c2ea827ab4174a0a1a706d065c2" class="target"></span>
 +
: Get a pointer to the screen refresher timer to m[https://docs.lvgl.io/8.2/overview/display.html#_CPPv423_lv_disp_get_refr_timerP9lv_disp_t]odify its parameters with <code>lv_timer_...</code> functions.
 +
:; Parameters
 +
:: disp -- pointer to a display
 +
:; Returns
 +
:: pointer to the display refresher timer. (NULL on error)
 +
 +
; <span id="_CPPv310lv_scr_actv"></span><span id="_CPPv210lv_scr_actv"></span><span id="lv_scr_act__void"></span><span id="lv__disp_8h_1a4e716d4e070c3b0ab848d277a4d6704c" class="target"></span>static inline lv_obj_t *lv_scr_act(void)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv410lv_scr_actv] <span id="_CPPv310lv_scr_actv"></span><span id="_CPPv210lv_scr_actv"></span><span id="lv_scr_act__void"></span><span id="lv__disp_8h_1a4e716d4e070c3b0ab848d277a4d6704c" class="target"></span>
 +
: Get the active screen of the default[https://docs.lvgl.io/8.2/overview/display.html#_CPPv410lv_scr_actv] display
 +
:; Returns
 +
:: pointer to the active screen
 +
 +
; <span id="_CPPv312lv_layer_topv"></span><span id="_CPPv212lv_layer_topv"></span><span id="lv_layer_top__void"></span><span id="lv__disp_8h_1a04b984c1db6bb83548ea1b1858422345" class="target"></span>static inline lv_obj_t *lv_layer_top(void)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv412lv_layer_topv] <span id="_CPPv312lv_layer_topv"></span><span id="_CPPv212lv_layer_topv"></span><span id="lv_layer_top__void"></span><span id="lv__disp_8h_1a04b984c1db6bb83548ea1b1858422345" class="target"></span>
 +
: Get the top layer of the default displ[https://docs.lvgl.io/8.2/overview/display.html#_CPPv412lv_layer_topv]ay
 +
:; Returns
 +
:: pointer to the top layer
 +
 +
; <span id="_CPPv312lv_layer_sysv"></span><span id="_CPPv212lv_layer_sysv"></span><span id="lv_layer_sys__void"></span><span id="lv__disp_8h_1ac4f26a96ade3c25c46c7f79f6f767ce4" class="target"></span>static inline lv_obj_t *lv_layer_sys(void)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv412lv_layer_sysv] <span id="_CPPv312lv_layer_sysv"></span><span id="_CPPv212lv_layer_sysv"></span><span id="lv_layer_sys__void"></span><span id="lv__disp_8h_1ac4f26a96ade3c25c46c7f79f6f767ce4" class="target"></span>
 +
: Get the active screen of the default d[https://docs.lvgl.io/8.2/overview/display.html#_CPPv412lv_layer_sysv]isplay
 +
:; Returns
 +
:: pointer to the sys layer
 +
 +
; <span id="_CPPv311lv_scr_loadP8lv_obj_t"></span><span id="_CPPv211lv_scr_loadP8lv_obj_t"></span><span id="lv_scr_load__lv_obj_tP"></span><span id="lv__disp_8h_1a14a1792cf92d6c3fbdc62b154cb54023" class="target"></span>static inline void lv_scr_load(lv_obj_t *scr)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv411lv_scr_loadP8lv_obj_t] <span id="_CPPv311lv_scr_loadP8lv_obj_t"></span><span id="_CPPv211lv_scr_loadP8lv_obj_t"></span><span id="lv_scr_load__lv_obj_tP"></span><span id="lv__disp_8h_1a14a1792cf92d6c3fbdc62b154cb54023" class="target"></span>
 +
:
 +
 +
; <span id="_CPPv36lv_dpx10lv_coord_t"></span><span id="_CPPv26lv_dpx10lv_coord_t"></span><span id="lv_dpx__lv_coord_t"></span><span id="lv__disp_8h_1ad8d0e384a4d60fefbe4682535f766628" class="target"></span>static inline lv_coord_t lv_dpx(lv_[https://docs.lvgl.io/8.2/overview/display.html#_CPPv411lv_scr_loadP8lv_obj_t]coord_t n)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv46lv_dpx10lv_coord_t] <span id="_CPPv36lv_dpx10lv_coord_t"></span><span id="_CPPv26lv_dpx10lv_coord_t"></span><span id="lv_dpx__lv_coord_t"></span><span id="lv__disp_8h_1ad8d0e384a4d60fefbe4682535f766628" class="target"></span>
 +
: Scale the given number of pixels (a dista[https://docs.lvgl.io/8.2/overview/display.html#_CPPv46lv_dpx10lv_coord_t]nce or size) relative to a 160 DPI display considering the DPI of the default display. It ensures that e.g. <code>lv_dpx(100)</code> will have the same physical size regardless to the DPI of the display.
 +
:; Parameters
 +
:: n -- the number of pixels to scale
 +
:; Returns
 +
:: <code>n x current_dpi/160</code>
 +
 +
; <span id="_CPPv311lv_disp_dpxPK9lv_disp_t10lv_coord_t"></span><span id="_CPPv211lv_disp_dpxPK9lv_disp_t10lv_coord_t"></span><span id="lv_disp_dpx__lv_disp_tCP.lv_coord_t"></span><span id="lv__disp_8h_1a5a5f23760a6625483500522546b659c6" class="target"></span>static inline lv_coord_t lv_disp_dpx(const lv_disp_t *disp, lv_coord_t n)[https://docs.lvgl.io/8.2/overview/display.html#_CPPv411lv_disp_dpxPK9lv_disp_t10lv_coord_t] <span id="_CPPv311lv_disp_dpxPK9lv_disp_t10lv_coord_t"></span><span id="_CPPv211lv_disp_dpxPK9lv_disp_t10lv_coord_t"></span><span id="lv_disp_dpx__lv_disp_tCP.lv_coord_t"></span><span id="lv__disp_8h_1a5a5f23760a6625483500522546b659c6" class="target"></span>
 +
: Scale the given number of pixels (a distance or size) relative to a 1[https://docs.lvgl.io/8.2/overview/display.html#_CPPv411lv_disp_dpxPK9lv_disp_t10lv_coord_t]60 DPI display considering the DPI of the given display. It ensures that e.g. <code>lv_dpx(100)</code> will have the same physical size regardless to the DPI of the display.
 +
:; Parameters
 +
::* obj -- a display whose dpi should be considered
 +
::* n -- the number of pixels to scale
 +
:; Returns
 +
:: <code>n x current_dpi/160</code>
  
  

2022年6月27日 (月) 10:32時点における版

https://docs.lvgl.io/8.2/overview/style.html

英文 自動翻訳


Displays

Important

The basic concept of a display in LVGL is explained in the [Porting](/porting/display) section. So before reading further, please read the [Porting](/porting/display) section first.

Multiple display support

In LVGL you can have multiple displays, each with their own driver and objects. The only limitation is that every display needs to have the same color depth (as defined in LV_COLOR_DEPTH). If the displays are different in this regard the rendered image can be converted to the correct format in the drivers flush_cb.

Creating more displays is easy: just initialize more display buffers and register another driver for every display. When you create the UI, use lv_disp_set_default(disp) to tell the library on which display to create objects.

Why would you want multi-display support? Here are some examples:

  • Have a "normal" TFT display with local UI and create "virtual" screens on VNC on demand. (You need to add your VNC driver).
  • Have a large TFT display and a small monochrome display.
  • Have some smaller and simple displays in a large instrument or technology.
  • Have two large TFT displays: one for a customer and one for the shop assistant.

Using only one display

Using more displays can be useful but in most cases it's not required. Therefore, the whole concept of multi-display handling is completely hidden if you register only one display. By default, the last created (and only) display is used.

lv_scr_act(), lv_scr_load(scr), lv_layer_top(), lv_layer_sys(), LV_HOR_RES and LV_VER_RES are always applied on the most recently created (default) display. If you pass NULL as disp parameter to display related functions the default display will usually be used. E.g. lv_disp_trig_activity(NULL) will trigger a user activity on the default display. (See below in Inactivity).

Mirror display

To mirror the image of a display to another display, you don't need to use multi-display support. Just transfer the buffer received in drv.flush_cb to the other display too.

Split image

You can create a larger virtual display from an array of smaller ones. You can create it as below:

  1. Set the resolution of the displays to the large display's resolution.
  2. In drv.flush_cb, truncate and modify the area parameter for each display.
  3. Send the buffer's content to each real display with the truncated area.

Screens

Every display has its own set of screens and the objects on each screen.

Be sure not to confuse displays and screens:

  • Displays are the physical hardware drawing the pixels.
  • Screens are the high-level root objects associated with a particular display. One display can have multiple screens associated with it, but not vice versa.

Screens can be considered the highest level containers which have no parent. A screen's size is always equal to its display and their origin is (0;0). Therefore, a screen's coordinates can't be changed, i.e. lv_obj_set_pos(), lv_obj_set_size() or similar functions can't be used on screens.

A screen can be created from any object type but the two most typical types are Base object and Image (to create a wallpaper).

To create a screen, use lv_obj_t * scr = lv_<type>_create(NULL, copy). copy can be an existing screen copied into the new screen.

To load a screen, use lv_scr_load(scr). To get the active screen, use lv_scr_act(). These functions work on the default display. If you want to specify which display to work on, use lv_disp_get_scr_act(disp) and lv_disp_load_scr(disp, scr). A screen can be loaded with animations too. Read more here.

Screens can be deleted with lv_obj_del(scr), but ensure that you do not delete the currently loaded screen.

Transparent screens

Usually, the opacity of the screen is LV_OPA_COVER to provide a solid background for its children. If this is not the case (opacity < 100%) the display's background color or image will be visible. See the Display background section for more details. If the display's background opacity is also not LV_OPA_COVER LVGL has no solid background to draw.

This configuration (transparent screen and display) could be used to create for example OSD menus where a video is played on a lower layer, and a menu is overlayed on an upper layer.

To handle transparent displays, special (slower) color mixing algorithms need to be used by LVGL so this feature needs to enabled with LV_COLOR_SCREEN_TRANSP in lv_conf.h. As this mode operates on the Alpha channel of the pixels LV_COLOR_DEPTH = 32 is also required. The Alpha channel of 32-bit colors will be 0 where there are no objects and 255 where there are solid objects.

In summary, to enable transparent screens and displays for OSD menu-like UIs:

  • Enable LV_COLOR_SCREEN_TRANSP in lv_conf.h
  • Be sure to use LV_COLOR_DEPTH 32
  • Set the screen's opacity to LV_OPA_TRANSP e.g. with lv_obj_set_style_local_bg_opa(lv_scr_act(), LV_OBJMASK_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP)
  • Set the display opacity to LV_OPA_TRANSP with lv_disp_set_bg_opa(NULL, LV_OPA_TRANSP);

Features of displays

Inactivity

A user's inactivity time is measured on each display. Every use of an Input device (if associated with the display) counts as an activity. To get time elapsed since the last activity, use lv_disp_get_inactive_time(disp). If NULL is passed, the lowest inactivity time among all displays will be returned (NULL isn't just the default display).

You can manually trigger an activity using lv_disp_trig_activity(disp). If disp is NULL, the default screen will be used (and not all displays).

Background

Every display has a background color, background image and background opacity properties. They become visible when the current screen is transparent or not positioned to cover the whole display.

The background color is a simple color to fill the display. It can be adjusted with lv_disp_set_bg_color(disp, color);

The display background image is a path to a file or a pointer to an lv_img_dsc_t variable (converted image data) to be used as wallpaper. It can be set with lv_disp_set_bg_image(disp, &my_img); If a background image is configured the background won't be filled with bg_color.

The opacity of the background color or image can be adjusted with lv_disp_set_bg_opa(disp, opa).

The disp parameter of these functions can be NULL to select the default display.

API

Enums

enum lv_scr_load_anim_t[1]
Values:
enumerat[2]or LV_SCR_LOAD_ANIM_NONE[3]
enumerator LV_SCR_LOAD[4]_ANIM_OVER_LEFT[5]
enumerator LV_SCR_LOAD_ANIM[6]_OVER_RIGHT[7]
enumerator LV_SCR_LOAD_ANIM_[8]OVER_TOP[9]
enumerator LV_SCR_LOAD_ANI[10]M_OVER_BOTTOM[11]
enumerator LV_SCR_LOAD_ANIM_M[12]OVE_LEFT[13]
enumerator LV_SCR_LOAD_ANIM[14]_MOVE_RIGHT[15]
enumerator LV_SCR_LOAD_ANIM_[16]MOVE_TOP[17]
enumerator LV_SCR_LOAD_ANI[18]M_MOVE_BOTTOM[19]
enumerator LV_SCR_LOAD_ANIM_F[20]ADE_ON[21]

Functions

lv_obj_t *lv[22]_disp_get_scr_act(lv_disp_t *disp)[23]
Return with a pointer to the active screen[24]
Parameters
disp -- pointer to display which active screen should be get. (NULL to use the default screen)
Returns
pointer to the active screen object (loaded by 'lv_scr_load()')
lv_obj_t *lv_disp_get_scr_prev(lv_disp_t *disp)[25]
Return with a pointer to the previous scree[26]n. Only used during screen transitions.
Parameters
disp -- pointer to display which previous screen should be get. (NULL to use the default screen)
Returns
pointer to the previous screen object or NULL if not used now
void lv_disp_load_scr(lv_obj_t *scr)[27]
Make a screen active
Paramete[28]rs
scr -- pointer to a screen
lv_obj_t *lv_disp_get_layer_top(lv_disp_t *disp)[29]
Return with the top layer. (Same on every sc[30]reen and it is above the normal screen layer)
Parameters
disp -- pointer to display which top layer should be get. (NULL to use the default screen)
Returns
pointer to the top layer object (transparent screen sized lv_obj)
lv_obj_t *lv_disp_get_layer_sys(lv_disp_t *disp)[31]
Return with the sys. layer. (Same on every s[32]creen and it is above the normal screen and the top layer)
Parameters
disp -- pointer to display which sys. layer should be retrieved. (NULL to use the default screen)
Returns
pointer to the sys layer object (transparent screen sized lv_obj)
void lv_disp_set_theme(lv_disp_t *disp, lv_theme_t *th)[33]
Set the theme of a display
Parameters
disp --[34] pointer to a display
lv_theme_t *lv_disp_get_theme(lv_disp_t *disp)[35]
Get the theme of a display
Parameters

[36]

disp -- pointer to a display
Returns
the display's theme (can be NULL)
void lv_disp_set_bg_color(lv_disp_t *disp, lv_color_t color)[37]
Set the background color of a display
Parameters
  • [38] disp -- pointer to a display
  • color -- color of the background
void lv_disp_set_bg_image(lv_disp_t *disp, const void *img_src)[39]
Set the background image of a display
Parameters
  • di[40]sp -- pointer to a display
  • img_src -- path to file or pointer to an lv_img_dsc_t variable
void lv_disp_set_bg_opa(lv_disp_t *disp, lv_opa_t opa)[41]
Set opacity of the background
Parameters
  • d[42]isp -- pointer to a display
  • opa -- opacity (0..255)
void lv_scr_load_anim(lv_obj_t *scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del)[43]
Switch screen with animation
Parameters
  • scr -- pointer to the new screen to load
  • anim_type -- typ[44]e of the animation from lv_scr_load_anim_t. E.g. LV_SCR_LOAD_ANIM_MOVE_LEFT
  • time -- time of the animation
  • delay -- delay before the transition
  • auto_del -- true: automatically delete the old screen
uint32_t lv_disp_get_inactive_time(const lv_disp_t *disp)[45]
Get elapsed time since last user activity on a displa[46]y (e.g. click)
Parameters
disp -- pointer to a display (NULL to get the overall smallest inactivity)
Returns
elapsed ticks (milliseconds) since the last activity
void lv_disp_trig_activity(lv_disp_t *disp)[47]
Manually trigger an activity on a displ[48]ay
Parameters
disp -- pointer to a display (NULL to use the default display)
void lv_disp_clean_dcache(lv_disp_t *disp)[49]
Clean any CPU cache that is related to[50] the display.
Parameters
disp -- pointer to a display (NULL to use the default display)
lv_timer_t *_lv_disp_get_refr_timer(lv_disp_t *disp)[51]
Get a pointer to the screen refresher timer to m[52]odify its parameters with lv_timer_... functions.
Parameters
disp -- pointer to a display
Returns
pointer to the display refresher timer. (NULL on error)
static inline lv_obj_t *lv_scr_act(void)[53]
Get the active screen of the default[54] display
Returns
pointer to the active screen
static inline lv_obj_t *lv_layer_top(void)[55]
Get the top layer of the default displ[56]ay
Returns
pointer to the top layer
static inline lv_obj_t *lv_layer_sys(void)[57]
Get the active screen of the default d[58]isplay
Returns
pointer to the sys layer
static inline void lv_scr_load(lv_obj_t *scr)[59]
static inline lv_coord_t lv_dpx(lv_[60]coord_t n)[61]
Scale the given number of pixels (a dista[62]nce or size) relative to a 160 DPI display considering the DPI of the default display. It ensures that e.g. lv_dpx(100) will have the same physical size regardless to the DPI of the display.
Parameters
n -- the number of pixels to scale
Returns
n x current_dpi/160
static inline lv_coord_t lv_disp_dpx(const lv_disp_t *disp, lv_coord_t n)[63]
Scale the given number of pixels (a distance or size) relative to a 1[64]60 DPI display considering the DPI of the given display. It ensures that e.g. lv_dpx(100) will have the same physical size regardless to the DPI of the display.
Parameters
  • obj -- a display whose dpi should be considered
  • n -- the number of pixels to scale
Returns
n x current_dpi/160






戻る : Previous