chore: many trivial spelling and layout fixes (#3008)
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
@@ -60,14 +60,14 @@ If the `direct_mode` flag is enabled in the display driver LVGL will draw direct
|
||||
It this case `flush_cb` will be called only once when all dirty areas are redrawn.
|
||||
With `direct_mode` the frame buffer always contains the current frame as it should be displayed on the screen.
|
||||
If 2 frame buffers are provided as draw buffers LVGL will alter the buffers but always draw only the dirty areas.
|
||||
Therefore the the 2 buffers needs to synchronized in `flush_cb` like this:
|
||||
Therefore the 2 buffers needs to synchronized in `flush_cb` like this:
|
||||
1. Display the frame buffer pointed by `color_p`
|
||||
2. Copy the redrawn areas from `color_p` to the other buffer.
|
||||
|
||||
The get the redrawn areas to copy use the following functions
|
||||
`_lv_refr_get_disp_refreshing()` returns the display being refreshed
|
||||
`disp->inv_areas[LV_INV_BUF_SIZE]` contains the invalidated areas
|
||||
`disp->inv_area_joined[LV_INV_BUF_SIZE]` if 1 that area was joined into an other one and should be ignored
|
||||
`disp->inv_area_joined[LV_INV_BUF_SIZE]` if 1 that area was joined into another one and should be ignored
|
||||
`disp->inv_p` number of valid elements in `inv_areas`
|
||||
|
||||
## Display driver
|
||||
@@ -92,8 +92,8 @@ LVGL might render the screen in multiple chunks and therefore call `flush_cb` mu
|
||||
There are some optional display driver data fields:
|
||||
- `physical_hor_res` horizontal resolution of the full / physical display in pixels. Only set this when _not_ using the full screen (defaults to -1 / same as `hor_res`).
|
||||
- `physical_ver_res` vertical resolution of the full / physical display in pixels. Only set this when _not_ using the full screen (defaults to -1 / same as `ver_res`).
|
||||
- `offset_x` horizontal offset from the the full / physical display in pixels. Only set this when _not_ using the full screen (defaults to 0).
|
||||
- `offset_y` vertical offset from the the full / physical display in pixels. Only set this when _not_ using the full screen (defaults to 0).
|
||||
- `offset_x` horizontal offset from the full / physical display in pixels. Only set this when _not_ using the full screen (defaults to 0).
|
||||
- `offset_y` vertical offset from the full / physical display in pixels. Only set this when _not_ using the full screen (defaults to 0).
|
||||
- `color_chroma_key` A color which will be drawn as transparent on chrome keyed images. Set to `LV_COLOR_CHROMA_KEY` from `lv_conf.h` by default.
|
||||
- `anti_aliasing` use anti-aliasing (edge smoothing). Enabled by default if `LV_COLOR_DEPTH` is set to at least 16 in `lv_conf.h`.
|
||||
- `rotated` and `sw_rotate` See the [Rotation](#rotation) section below.
|
||||
@@ -197,7 +197,7 @@ LVGL supports rotation of the display in 90 degree increments. You can select wh
|
||||
|
||||
If you select software rotation (`sw_rotate` flag set to 1), LVGL will perform the rotation for you. Your driver can and should assume that the screen width and height have not changed. Simply flush pixels to the display as normal. Software rotation requires no additional logic in your `flush_cb` callback.
|
||||
|
||||
There is a noticeable amount of overhead to performing rotation in software. Hardware rotation is available to avoid unwanted slow downs. In this mode, LVGL draws into the buffer as if your screen width and height were swapped. You are responsible for rotating the provided pixels yourself.
|
||||
There is a noticeable amount of overhead to performing rotation in software. Hardware rotation is available to avoid unwanted slowdowns. In this mode, LVGL draws into the buffer as if your screen width and height were swapped. You are responsible for rotating the provided pixels yourself.
|
||||
|
||||
The default rotation of your display when it is initialized can be set using the `rotated` flag. The available options are `LV_DISP_ROT_NONE`, `LV_DISP_ROT_90`, `LV_DISP_ROT_180`, or `LV_DISP_ROT_270`. The rotation values are relative to how you would rotate the physical display in the clockwise direction. Thus, `LV_DISP_ROT_90` means you rotate the hardware 90 degrees clockwise, and the display rotates 90 degrees counterclockwise to compensate.
|
||||
|
||||
|
||||
@@ -3,63 +3,59 @@
|
||||
:github_url: |github_link_base|/porting/gpu.md
|
||||
```
|
||||
# Add custom GPU
|
||||
|
||||
LVGL has a flexible and extendable draw pipeline. You can hook it to do some rendering with a GPU or even completely replace the built-in software renderer.
|
||||
|
||||
## Draw context
|
||||
|
||||
The core structure of drawing is `lv_draw_ctx_t`.
|
||||
It contains a pointer to a buffer where drawing should happen and a couple of callbacks to draw rectangles, texts, and other primitives.
|
||||
|
||||
### Fields
|
||||
|
||||
`lv_draw_ctx_t` has the following fields:
|
||||
- `void * buf` Pointer to a buffer to draw into
|
||||
- `lv_area_t * buf_area` The the position and size of `buf` (absolute coordinates)
|
||||
- `lv_area_t * buf_area` The position and size of `buf` (absolute coordinates)
|
||||
- `const lv_area_t * clip_area` The current clip area with absolute coordinates, always the same or smaller than `buf_area`. All drawings should be clipped to this area.
|
||||
- `void (*draw_rect)()` Draw a rectangle with shadow, gradient, border, etc.
|
||||
- `void (*draw_arc)()` Draw and arc
|
||||
- `void (*draw_arc)()` Draw an arc
|
||||
- `void (*draw_img_decoded)()` Draw an (A)RGB image that is already decoded by LVGL.
|
||||
- `lv_res_t (*draw_img)()` Draw an image before decoding it (it bypasses LVGL's internal image decoders)
|
||||
- `void (*draw_letter)()` Draw a letter
|
||||
- `void (*draw_line)()` Draw a line
|
||||
- `void (*draw_polygon)()` Draw polygon
|
||||
- `void (*draw_polygon)()` Draw a polygon
|
||||
- `void (*draw_bg)()` Replace the buffer with a rect without decoration like radius or borders.
|
||||
- `void (*wait_for_finish)()` Wait until all background operation are finished. (E.g. GPU operations)
|
||||
- `void * user_data` Custom user data for arbitrary purpose
|
||||
|
||||
(For the sake of simplicity the parameters of the callbacks are not shown here.)
|
||||
|
||||
All `draw_*` callbacks receive a pointer to the current `draw_ctx` as their first parameter. Among the other parameters there is a descriptor too that tells what to draw.
|
||||
E.g. for `draw_rect` it's called [lv_draw_rect_dsc_t](https://github.com/lvgl/lvgl/blob/master/src/draw/lv_draw_rect.h),
|
||||
for `lv_draw_line` it's called [lv_draw_line_dsc_t](https://github.com/lvgl/lvgl/blob/master/src/draw/lv_draw_line.h), etc.
|
||||
All `draw_*` callbacks receive a pointer to the current `draw_ctx` as their first parameter. Among the other parameters there is a descriptor that tells what to draw,
|
||||
e.g. for `draw_rect` it's called [lv_draw_rect_dsc_t](https://github.com/lvgl/lvgl/blob/master/src/draw/lv_draw_rect.h),
|
||||
for `lv_draw_line` it's called [lv_draw_line_dsc_t](https://github.com/lvgl/lvgl/blob/master/src/draw/lv_draw_line.h), etc.
|
||||
|
||||
To correctly render according to a `draw_dsc` you need to be familiar with the [Boxing model](https://docs.lvgl.io/master/overview/coords.html#boxing-model) of LVGL and the meanings of the fields. The name and meaning of the fields are identical to name and meaning of the [Style properties](https://docs.lvgl.io/master/overview/style-props.html).
|
||||
|
||||
### Initialization
|
||||
|
||||
The `lv_disp_drv_t` has 4 fields related to the draw context:
|
||||
- `lv_draw_ctx_t * draw_ctx` Pointer to the `draw_ctx` of this display
|
||||
- `void (*draw_ctx_init)(struct _lv_disp_drv_t * disp_drv, lv_draw_ctx_t * draw_ctx)` Callback to initialize a `draw_ctx`
|
||||
- `void (*draw_ctx_deinit)(struct _lv_disp_drv_t * disp_drv, lv_draw_ctx_t * draw_ctx)` Callback to de-initialize a `draw_ctx`
|
||||
- `size_t draw_ctx_size` Size of the draw context structure. E.g. `sizeof(lv_draw_sw_ctx_t)`
|
||||
|
||||
If you ignore these fields LVGL will set default values for callbacks and size in `lv_disp_drv_init()` based on the configuration in `lv_conf.h`.
|
||||
When you ignore these fields, LVGL will set default values for callbacks and size in `lv_disp_drv_init()` based on the configuration in `lv_conf.h`.
|
||||
`lv_disp_drv_register()` will allocate a `draw_ctx` based on `draw_ctx_size` and call `draw_ctx_init()` on it.
|
||||
|
||||
However, you can overwrite the callbacks and the size values before calling `lv_disp_drv_register()`.
|
||||
It makes possible to use your own `draw_ctx` with your own callbacks.
|
||||
It makes it possible to use your own `draw_ctx` with your own callbacks.
|
||||
|
||||
|
||||
## Software renderer
|
||||
LVGL's built in software renderer extends the basic `lv_draw_ctx_t` structure and sets the draw callbacks. It looks like this:
|
||||
```c
|
||||
typedef struct {
|
||||
/** Include the basic draw_ctx type*/
|
||||
lv_draw_ctx_t base_draw;
|
||||
/** Include the basic draw_ctx type*/
|
||||
lv_draw_ctx_t base_draw;
|
||||
|
||||
/** Blend a color or image to an area*/
|
||||
void (*blend)(lv_draw_ctx_t * draw_ctx, const lv_draw_sw_blend_dsc_t * dsc);
|
||||
/** Blend a color or image to an area*/
|
||||
void (*blend)(lv_draw_ctx_t * draw_ctx, const lv_draw_sw_blend_dsc_t * dsc);
|
||||
} lv_draw_sw_ctx_t;
|
||||
```
|
||||
|
||||
@@ -72,7 +68,7 @@ draw_sw_ctx->base_draw.draw_letter = lv_draw_sw_letter;
|
||||
|
||||
### Blend callback
|
||||
As you saw above the software renderer adds the `blend` callback field. It's a special callback related to how the software renderer works.
|
||||
All draw operations end up in the `blend` callback which can either fill an area or copy an image to an area by considering an optional mask.
|
||||
All draw operations end up in the `blend` callback which can either fill an area or copy an image to an area by considering an optional mask.
|
||||
|
||||
The `lv_draw_sw_blend_dsc_t` parameter describes what and how to blend. It has the following fields:
|
||||
- `const lv_area_t * blend_area` The area with absolute coordinates to draw on `draw_ctx->buf`. If `src_buf` is set, it's the coordinates of the image to blend.
|
||||
@@ -81,8 +77,8 @@ The `lv_draw_sw_blend_dsc_t` parameter describes what and how to blend. It has t
|
||||
- `lv_opa_t * mask_buf` NULL if ignored, or an alpha mask to apply on `blend_area`
|
||||
- `lv_draw_mask_res_t mask_res` The result of the previous mask operation. (`LV_DRAW_MASK_RES_...`)
|
||||
- `const lv_area_t * mask_area` The area of `mask_buf` with absolute coordinates
|
||||
- `lv_opa_t opa` The overall opacity
|
||||
- `lv_blend_mode_t blend_mode` E.g. `LV_BLEND_MODE_ADDITIVE`
|
||||
- `lv_opa_t opa` The overall opacity
|
||||
- `lv_blend_mode_t blend_mode` E.g. `LV_BLEND_MODE_ADDITIVE`
|
||||
|
||||
|
||||
## Extend the software renderer
|
||||
|
||||
@@ -142,7 +142,7 @@ void encoder_with_keys_read(lv_indev_drv_t * drv, lv_indev_data_t*data){
|
||||
If a button is pressed it will simulate the pressing on the assigned coordinate. (Similarly to a touchpad)
|
||||
|
||||
To assign buttons to coordinates use `lv_indev_set_button_points(my_indev, points_array)`.
|
||||
`points_array` should look like `const lv_point_t points_array[] = { {12,30},{60,90}, ...}`
|
||||
`points_array` should look like `const lv_point_t points_array[] = { {12,30},{60,90}, ...}`
|
||||
|
||||
``` important:: The points_array can't go out of scope. Either declare it as a global variable or as a static variable inside a function.
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user