arch(driver): new driver architecture with new color format support

This commit is contained in:
Gabor Kiss-Vamosi
2023-02-20 20:50:58 +01:00
parent df789ed3c7
commit 124f9b0f9f
425 changed files with 25232 additions and 24168 deletions

View File

@@ -27,12 +27,12 @@ E.g. `lv_disp_trig_activity(NULL)` will trigger a user activity on the default d
### 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.
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 `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.
2. In `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
@@ -57,17 +57,18 @@ Screens can be deleted with `lv_obj_del(scr)`, but ensure that you do not delete
### 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](#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.
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 `bottom_layer` be visible.
If the bottom layer's 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.
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 overlaid on an upper layer.
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.
To properly render the screen the display's color format needs to be set to one with alpha channel.
In summary, to enable transparent screens and displays for OSD menu-like UIs:
- 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);`
- Set the screen's `bg_opa` to transparent: `lv_obj_set_style_local_bg_opa(lv_scr_act(), LV_OPA_TRANSP, 0)`
- Set the bottom layer's `bg_opa` to transparent: `lv_obj_set_style_local_bg_opa(lv_scr_act(), LV_OPA_TRANSP, 0)`
- Set the screen's bg_opa to 0: `lv_obj_set_style_local_bg_opa(lv_layer_bottom(), LV_OPA_TRANSP, 0)`
- Set a color format with alpha channel. E.g. `lv_disp_set_color_format(disp, LV_COLOR_FORMAT_NATIVE_ALPHA)`
## Features of displays

View File

@@ -11,7 +11,7 @@ Events are triggered in LVGL when something happens which might be interesting t
The user can assign callback functions to an object to see its events. In practice, it looks like this:
```c
lv_obj_t * btn = lv_btn_create(lv_scr_act());
lv_obj_add_event_cb(btn, my_event_cb, LV_EVENT_CLICKED, NULL); /*Assign an event callback*/
lv_obj_add_event(btn, my_event_cb, LV_EVENT_CLICKED, NULL); /*Assign an event callback*/
...
@@ -23,19 +23,19 @@ static void my_event_cb(lv_event_t * event)
In the example `LV_EVENT_CLICKED` means that only the click event will call `my_event_cb`. See the [list of event codes](#event-codes) for all the options.
`LV_EVENT_ALL` can be used to receive all events.
The last parameter of `lv_obj_add_event_cb` is a pointer to any custom data that will be available in the event. It will be described later in more detail.
The last parameter of `lv_obj_add_event` is a pointer to any custom data that will be available in the event. It will be described later in more detail.
More events can be added to an object, like this:
```c
lv_obj_add_event_cb(obj, my_event_cb_1, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(obj, my_event_cb_2, LV_EVENT_PRESSED, NULL);
lv_obj_add_event_cb(obj, my_event_cb_3, LV_EVENT_ALL, NULL); /*No filtering, receive all events*/
lv_obj_add_event(obj, my_event_cb_1, LV_EVENT_CLICKED, NULL);
lv_obj_add_event(obj, my_event_cb_2, LV_EVENT_PRESSED, NULL);
lv_obj_add_event(obj, my_event_cb_3, LV_EVENT_ALL, NULL); /*No filtering, receive all events*/
```
Even the same event callback can be used on an object with different `user_data`. For example:
```c
lv_obj_add_event_cb(obj, increment_on_click, LV_EVENT_CLICKED, &num1);
lv_obj_add_event_cb(obj, increment_on_click, LV_EVENT_CLICKED, &num2);
lv_obj_add_event(obj, increment_on_click, LV_EVENT_CLICKED, &num1);
lv_obj_add_event(obj, increment_on_click, LV_EVENT_CLICKED, &num2);
```
The events will be called in the order as they were added.
@@ -46,7 +46,7 @@ Other objects can use the same *event callback*.
## Remove event(s) from an object
Events can be removed from an object with the `lv_obj_remove_event_cb(obj, event_cb)` function or `lv_obj_remove_event_dsc(obj, event_dsc)`. `event_dsc` is a pointer returned by `lv_obj_add_event_cb`.
Events can be removed from an object with the `lv_obj_remove_event_cb(obj, event_cb)` function or `lv_obj_remove_event_dsc(obj, event_dsc)`. `event_dsc` is a pointer returned by `lv_obj_add_event`.
## Event codes
@@ -153,7 +153,7 @@ lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id);
- `lv_event_get_code(e)` get the event code
- `lv_event_get_current_target(e)` get the object to which an event was sent. I.e. the object whose event handler is being called.
- `lv_event_get_target(e)` get the object that originally triggered the event (different from `lv_event_get_target` if [event bubbling](#event-bubbling) is enabled)
- `lv_event_get_user_data(e)` get the pointer passed as the last parameter of `lv_obj_add_event_cb`.
- `lv_event_get_user_data(e)` get the pointer passed as the last parameter of `lv_obj_add_event`.
- `lv_event_get_param(e)` get the parameter passed as the last parameter of `lv_event_send`

View File

@@ -18,8 +18,8 @@ Pointer input devices (like a mouse) can have a cursor.
```c
...
lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
lv_indev_t * mouse_indev = lv_indev_create();
...
LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image source.*/
lv_obj_t * cursor_obj = lv_img_create(lv_scr_act()); /*Create an image object for the cursor */
lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/
@@ -55,7 +55,7 @@ void my_event(lv_event_t * e)
...
lv_obj_add_event_cb(screen1, my_event, LV_EVENT_GESTURE, NULL);
lv_obj_add_event(screen1, my_event, LV_EVENT_GESTURE, NULL);
```
To prevent passing the gesture event to the parent from an object use `lv_obj_clear_flag(obj, LV_OBJ_FLAG_GESTURE_BUBBLE)`.
@@ -79,7 +79,7 @@ You need to associate an input device with a group. An input device can send key
To create a group use `lv_group_t * g = lv_group_create()` and to add an object to the group use `lv_group_add_obj(g, obj)`.
To associate a group with an input device use `lv_indev_set_group(indev, g)`, where `indev` is the return value of `lv_indev_drv_register()`
To associate a group with an input device use `lv_indev_set_group(indev, g)`.
#### Keys
There are some predefined keys which have special meaning:

View File

@@ -149,7 +149,7 @@ static void store_scroll_value_event_cb(lv_event_t* e) {
}
lv_obj_t* container = lv_obj_create(NULL);
lv_obj_add_event_cb(container, store_scroll_value_event_cb, LV_EVENT_SCROLL, NULL);
lv_obj_add_event(container, store_scroll_value_event_cb, LV_EVENT_SCROLL, NULL);
```
Scrool coordinates can be retrieve from differents axes with these functions: