Display (lv_display)

显示原文

What is a Display?

In LVGL, an lv_display_t (not to be confused with a Screen) is a data type that represents a single display panel --- the hardware that displays LVGL-rendered pixels on your device. During system initialization, you must do the following for each display panel you want LVGL to use:


什么是显示器?

在 LVGL 中,*lv_display_t*(不要与 Screen 混淆)是一个数据类型,表示一个单独的显示面板——即硬件设备,用于在您的设备上显示 LVGL 渲染的像素。 在系统初始化期间,您必须为每个希望 LVGL 使用的显示面板执行以下操作:

显示原文

How Many Displays Can LVGL Use?

LVGL can use any number of displays. It is only limited by available RAM and MCU time.

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.

If you set up LVGL to use more than one display, be aware that some functions use the default_display during their execution, such as creating Screens.


LVGL 可以使用多少个显示器?

LVGL 可以使用任意数量的显示器,唯一的限制是可用的 RAM 和 MCU 时间。

为什么你需要支持多显示器?以下是一些示例:

  • 拥有一个“正常的”TFT 显示器用于本地 UI,并根据需要在 VNC 上创建“虚拟”屏幕。(你需要添加 VNC 驱动程序。)

  • 拥有一个大尺寸 TFT 显示器和一个小的单色显示器。

  • 在一个大型仪器或技术设备中拥有一些较小且简单的显示器。

  • 拥有两个大尺寸 TFT 显示器:一个给客户用,另一个给店员用。

如果你设置 LVGL 使用多个显示器,请注意某些函数在执行时使用 default_display,例如创建 Screens

Display Features

显示原文

Attributes

Once created, a Display object remembers the characteristics of the display hardware it is representing, as well as other things relevant to its lifetime:

  • Resolution (width and height in pixels)

  • Color Depth (bits per pixel)

  • Color Format (how colors in pixels are laid out)

  • 4 screen_layers automatically created with each display

  • All Screens created in association with this display (and not yet deleted---only one is dislayed at any given time)

  • The draw_buffers assigned to it

  • The flush_callback function that moves pixels from draw_buffers to Display hardware

  • What areas of the display have been updated (made "dirty") so rendering logic can compute what to render during a display refresh

  • Optional custom pointer as display_user_data


属性

一旦创建,Display 对象会记住它所表示的显示硬件的特性,以及与其生命周期相关的其他信息:

  • 分辨率(宽度和高度,单位为像素)

  • 颜色深度(每像素位数)

  • 颜色格式(像素中的颜色布局方式)

  • 每个显示器自动创建的 4 个 screen_layers

  • 与此显示器关联的所有 :ref:`screens`(且尚未删除——在任何给定时刻只显示一个)

  • 分配给它的 draw_buffers

  • 用于将像素从 draw_buffers 移动到显示硬件的 flush_callback 函数

  • 显示器的哪些区域已更新(被标记为“脏”),以便渲染逻辑在 display refresh 时计算需要渲染的内容

  • 可选的自定义指针,作为 display_user_data

显示原文

Screen Layers

When an lv_display_t object is created, 4 permanent Screens that facilitate layering are created and attached to it.

  1. Bottom Layer (below Active Screen, transparent, not scroll-able, but click-able)

  2. Active Screen

  3. Top Layer (above Active Screen, transparent and neither scroll-able nor click-able)

  4. System Layer (above Top Layer, transparent and neither scroll-able nor click-able)

1, 3 and 4 are independent of the Active Screen and they will be shown (if they contain anything that is visible) regardless of which screen is the Active Screen.

备注

For the bottom layer to be visible, the Active Screen's background has to be at least partially, if not fully, transparent.

You can get pointers to each of these screens on the default_display by using (respectively):

You can get pointers to each of these screens on a specified display by using (respectively):

To set a Screen you create to be the Active Screen, call lv_screen_load() or lv_screen_load_anim().


屏幕层

当一个 lv_display_t 对象被创建时,4 个永久的 Screens 会被创建并附加到它上面,这些屏幕有助于实现层次结构。

  1. 底层(位于活动屏幕下方,透明、不可滚动,但可以点击)

  2. Active Screen

  3. 顶层(位于活动屏幕上方,透明且不可滚动或点击)

  4. 系统层(位于顶层上方,透明且不可滚动或点击)

1、3 和 4 层是独立于 Active Screen 的,它们会被显示(如果它们包含任何可见内容),无论当前活动屏幕是什么。

备注

为了使底层可见,活动屏幕的背景必须至少部分透明,甚至完全透明。

你可以通过以下方式获取 default_display 上这些屏幕的指针(分别是):

你也可以通过以下方式获取指定显示器上的这些屏幕的指针(分别是):

要将创建的屏幕设置为 Active Screen,调用 lv_screen_load()lv_screen_load_anim()

显示原文

Top and System Layers

LVGL uses the Top Layer and System Layer two empower you to ensure that certain Widgets(控件) are always on top of other layers.

You can add "pop-up windows" to the Top Layer freely. The Top Layer was meant to be used to create Widgets that are visible on all Screens shown on a Display. But, the System Layer is intended for system-level things (e.g. mouse cursor will be placed there with lv_indev_set_cursor()).

These layers work like any other Widget, meaning they have styles, and any kind of Widgets can be created in them.

备注

While the Top Layer and System Layer are created by their owning Display (lv_display) as not scroll-able and not click-able, these behaviors can be overridden the same as any other Widget by using lv_obj_set_scrollbar_mode(scr1, LV_SCROLLBAR_MODE_xxx) and lv_obj_add_flag(scr1, LV_OBJ_FLAG_CLICKABLE) respectively.

If the LV_OBJ_FLAG_CLICKABLE flag is set on the Top Layer, then it will absorb all user clicks and acts as a modal Widget.

lv_obj_add_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE);

顶层和系统层

LVGL 使用顶层和系统层来确保某些 Widgets(控件) 始终 位于其他层之上。

你可以自由地将“弹出窗口”添加到 顶层。顶层旨在用于创建在显示器上所有屏幕上都可见的 Widgets。 而 系统层 则用于系统级别的内容(例如,鼠标光标将通过 lv_indev_set_cursor() 被放置在该层)。

这些层像任何其他 Widget 一样工作,这意味着它们有样式,并且可以在它们上创建任何类型的 Widget。

备注

虽然顶层和系统层是由它们所属的 Display (lv_display) 创建的,并且默认不可滚动和不可点击,但这些行为可以像任何其他 Widget 一样被覆盖 方法是分别使用 lv_obj_set_scrollbar_mode(scr1, LV_SCROLLBAR_MODE_xxx)lv_obj_add_flag(scr1, LV_OBJ_FLAG_CLICKABLE)

如果在顶层上设置了 LV_OBJ_FLAG_CLICKABLE 标志,则它将吸收所有用户点击并充当模态 Widget。

lv_obj_add_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE);
显示原文

Bottom Layer

Similar to the Top- and System Layers, the Bottom Layer is also the full size of the Display, but it is located below the Active Screen. It's visible only if the Active Screen's background opacity is < 255.


底层

与顶层和系统层类似,底层也与显示器的大小相同,但它位于 Active Screen 之下。 只有当活动屏幕的背景不透明度小于 255 时,底层才会可见。

显示原文