You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
ndg/lib/lvgl/docs/porting/display.md

248 lines
14 KiB
Markdown

# Display interface
To register a display for LVGL, a `lv_disp_draw_buf_t` and a `lv_disp_drv_t` variable have to be initialized.
- `lv_disp_draw_buf_t` contains internal graphic buffer(s) called draw buffer(s).
- `lv_disp_drv_t` contains callback functions to interact with the display and manipulate low level drawing behavior.
## Draw buffer
Draw buffer(s) are simple array(s) that LVGL uses to render the screen content.
Once rendering is ready the content of the draw buffer is sent to the display using the `flush_cb` function set in the display driver (see below).
A draw buffer can be initialized via a `lv_disp_draw_buf_t` variable like this:
```c
/*A static or global variable to store the buffers*/
static lv_disp_draw_buf_t disp_buf;
/*Static or global buffer(s). The second buffer is optional*/
static lv_color_t buf_1[MY_DISP_HOR_RES * 10];
static lv_color_t buf_2[MY_DISP_HOR_RES * 10];
/*Initialize `disp_buf` with the buffer(s). With only one buffer use NULL instead buf_2 */
lv_disp_draw_buf_init(&disp_buf, buf_1, buf_2, MY_DISP_HOR_RES*10);
```
Note that `lv_disp_draw_buf_t` must be a static, global or dynamically allocated variable. It cannot be a local variable as they are destroyed upon end of scope.
As you can see above, the draw buffer may be smaller than the screen. In this case, larger areas are redrawn in smaller segments that fit into the draw buffer(s).
If only a small area changes (e.g. a button is pressed) then only that area will be refreshed.
A larger buffer results in better performance but above 1/10 screen sized buffer(s) there is no significant performance improvement.
Therefore it's recommended to choose the size of the draw buffer(s) to be at least 1/10 screen sized.
## Buffering modes
There are several settings to adjust the number draw buffers and buffering/refreshing modes.
You can measure the performance of different configurations using the [benchmark example](https://github.com/lvgl/lvgl/tree/master/demos/benchmark).
### One buffer
If only one buffer is used LVGL draws the content of the screen into that draw buffer and sends it to the display.
LVGL then needs to wait until the content of the buffer is sent to the display before drawing something new in it.
### Two buffers
If two buffers are used LVGL can draw into one buffer while the content of the other buffer is sent to the display in the background.
DMA or other hardware should be used to transfer data to the display so the MCU can continue drawing.
This way, the rendering and refreshing of the display become parallel operations.
### Full refresh
In the display driver (`lv_disp_drv_t`) enabling the `full_refresh` bit will force LVGL to always redraw the whole screen. This works in both *one buffer* and *two buffers* modes.
If `full_refresh` is enabled and two screen sized draw buffers are provided, LVGL's display handling works like "traditional" double buffering.
This means the `flush_cb` callback only has to update the address of the framebuffer (`color_p` parameter).
This configuration should be used if the MCU has an LCD controller peripheral and not with an external display controller (e.g. ILI9341 or SSD1963) accessed via serial link. The latter will generally be too slow to maintain high frame rates with full screen redraws.
### Direct mode
If the `direct_mode` flag is enabled in the display driver LVGL will draw directly into a **screen sized frame buffer**. That is the draw buffer(s) needs to be screen sized.
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 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 another one and should be ignored
`disp->inv_p` number of valid elements in `inv_areas`
## Display driver
Once the buffer initialization is ready a `lv_disp_drv_t` display driver needs to be:
1. initialized with `lv_disp_drv_init(&disp_drv)`
2. its fields need to be set
3. it needs to be registered in LVGL with `lv_disp_drv_register(&disp_drv)`
Note that `lv_disp_drv_t` also needs to be a static, global or dynamically allocated variable.
### Mandatory fields
In the most simple case only the following fields of `lv_disp_drv_t` need to be set:
- `draw_buf` pointer to an initialized `lv_disp_draw_buf_t` variable.
- `hor_res` horizontal resolution of the display in pixels.
- `ver_res` vertical resolution of the display in pixels.
- `flush_cb` a callback function to copy a buffer's content to a specific area of the display.
`lv_disp_flush_ready(&disp_drv)` needs to be called when flushing is ready.
LVGL might render the screen in multiple chunks and therefore call `flush_cb` multiple times. To see if the current one is the last chunk of rendering use `lv_disp_flush_is_last(&disp_drv)`.
### Optional fields
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 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.
- `screen_transp` if `1` the screen itself can have transparency as well. `LV_COLOR_SCREEN_TRANSP` must be enabled in `lv_conf.h` and `LV_COLOR_DEPTH` must be 32.
- `user_data` A custom `void` user data for the driver.
- `full_refresh` always redrawn the whole screen (see above)
- `direct_mode` draw directly into the frame buffer (see above)
Some other optional callbacks to make it easier and more optimal to work with monochrome, grayscale or other non-standard RGB displays:
- `rounder_cb` Round the coordinates of areas to redraw. E.g. a 2x2 px can be converted to 2x8.
It can be used if the display controller can refresh only areas with specific height or width (usually 8 px height with monochrome displays).
- `set_px_cb` a custom function to write the draw buffer. It can be used to store the pixels more compactly in the draw buffer if the display has a special color format. (e.g. 1-bit monochrome, 2-bit grayscale etc.)
This way the buffers used in `lv_disp_draw_buf_t` can be smaller to hold only the required number of bits for the given area size. Note that rendering with `set_px_cb` is slower than normal rendering.
- `monitor_cb` A callback function that tells how many pixels were refreshed and in how much time. Called when the last chunk is rendered and sent to the display.
- `clean_dcache_cb` A callback for cleaning any caches related to the display.
- `render_start_cb` A callback function that notifies the display driver that rendering has started. It also could be used to wait for VSYNC to start rendering. It's useful if rendering is faster than a VSYNC period.
LVGL has built-in support to several GPUs (see `lv_conf.h`) but if something else is required these functions can be used to make LVGL use a GPU:
- `gpu_fill_cb` fill an area in the memory with a color.
- `gpu_wait_cb` if any GPU function returns while the GPU is still working, LVGL will use this function when required to make sure GPU rendering is ready.
### Examples
All together it looks like this:
```c
static lv_disp_drv_t disp_drv; /*A variable to hold the drivers. Must be static or global.*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
disp_drv.draw_buf = &disp_buf; /*Set an initialized buffer*/
disp_drv.flush_cb = my_flush_cb; /*Set a flush callback to draw to the display*/
disp_drv.hor_res = 320; /*Set the horizontal resolution in pixels*/
disp_drv.ver_res = 240; /*Set the vertical resolution in pixels*/
lv_disp_t * disp;
disp = lv_disp_drv_register(&disp_drv); /*Register the driver and save the created display objects*/
```
Here are some simple examples of the callbacks:
```c
void my_flush_cb(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one
*`put_px` is just an example, it needs to implemented by you.*/
int32_t x, y;
for(y = area->y1; y <= area->y2; y++) {
for(x = area->x1; x <= area->x2; x++) {
put_px(x, y, *color_p);
color_p++;
}
}
/* IMPORTANT!!!
* Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
void my_gpu_fill_cb(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, const lv_area_t * dest_area, const lv_area_t * fill_area, lv_color_t color);
{
/*It's an example code which should be done by your GPU*/
uint32_t x, y;
dest_buf += dest_width * fill_area->y1; /*Go to the first line*/
for(y = fill_area->y1; y < fill_area->y2; y++) {
for(x = fill_area->x1; x < fill_area->x2; x++) {
dest_buf[x] = color;
}
dest_buf+=dest_width; /*Go to the next line*/
}
}
void my_rounder_cb(lv_disp_drv_t * disp_drv, lv_area_t * area)
{
/* Update the areas as needed.
* For example it makes the area to start only on 8th rows and have Nx8 pixel height.*/
area->y1 = area->y1 & 0x07;
area->y2 = (area->y2 & 0x07) + 8;
}
void my_set_px_cb(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa)
{
/* Write to the buffer as required for the display.
* For example it writes only 1-bit for monochrome displays mapped vertically.*/
buf += buf_w * (y >> 3) + x;
if(lv_color_brightness(color) > 128) (*buf) |= (1 << (y % 8));
else (*buf) &= ~(1 << (y % 8));
}
void my_monitor_cb(lv_disp_drv_t * disp_drv, uint32_t time, uint32_t px)
{
printf("%d px refreshed in %d ms\n", time, ms);
}
void my_clean_dcache_cb(lv_disp_drv_t * disp_drv, uint32)
{
/* Example for Cortex-M (CMSIS) */
SCB_CleanInvalidateDCache();
}
```
## Other options
### Rotation
LVGL supports rotation of the display in 90 degree increments. You can select whether you'd like software rotation or hardware rotation.
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 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.
(Note for users upgrading from 7.10.0 and older: these new rotation enum values match up with the old 0/1 system for rotating 90 degrees, so legacy code should continue to work as expected. Software rotation is also disabled by default for compatibility.)
Display rotation can also be changed at runtime using the `lv_disp_set_rotation(disp, rot)` API.
Squashed 'lib/lvgl/' changes from 9024b72b4..74d0a816a 74d0a816a release v8.3.11 8194d8322 chore(cmsis-pack): prepare for v8.3.11 (#4936) 1840decb4 fix(qrcode): use LV_ASSERT instead of assert ef76206c7 fix(disp): fix infinite recursive SCREEN_LOADED events 4fdc4c20b fix(obj): readjust scroll after layout when child removed (#4921) 85776aeec fix(rt-thread): fix create lvgl thread problem (#4862) d20bd1ca3 fix(keyboard): add '&' character c16bfdc22 fix(obj): fix arduino compile warnings (#4807) 3b6f98a93 fix(table):fix issue with abnormal string output of 'lv_table_set_cell_value_fmt' (#4804) 6c86969ee fix(table) user data API functions renamed (#4769) fdfff5c0b feat(table): add user_data to table cells (#4767) 2791d5739 feat(tiny_ttf): backport Tiny TTF to lvgl 8 (#4727) 68d380eb9 fix(ime_pinyin): keep cursor in the textarea when a candidate is pressed (#4731) 20b6199ba fix(arc): fix setting value by click 7efcea6d0 chore(cmake): add support for user-specified lv_conf.h path (#4689) 7f894cf75 fix(draw_needles): changed needle line draw start point from scale ce… (#4682) fa40b0519 feat(littlefs): add lv_fs_littlefs system as a driver (#4677) 17c580fad fix(arc): handle click outside background angle range (#4586) (#4667) 454e45429 fix(meter): fix minor issues (#4657) 9fbac7570 docs: fix typo 1e381f11b STM32U5 DMA2D support (8.3) (#4643) d22cda3cd fix: fix warning in lv_draw_sw_letter.c 869cc6300 backport: fix(lv_disp): fix lv_scr_load_anim being called twice quickly (#4629) 73fa50afa docs(obj): fix wording (#4625) 7a8fcbfd3 fix(draw): fix scaling rectangle parts with opa 7568df77d chore: fix compile error 9a673e447 chore(lv_draw_sw_letter.c): Fix print format (#4615) 3b2d75be0 fix(draw): fix compiler error in lv_draw_sw_transform.c #2 (#4612) 87ff746e2 docs(label): update text for recoloring (#4606) 14e21d27f fix(dropdown): avoid partial match in lv_dropdown_get_option_index (#4598) ff4f3f976 fix(dropdown): reset char_i = 0, avoid access overflow (#4589) a7a9d278c fix(btnmatrix): set LV_BTNMATRIX_BTN_NONE when clicking of disabled button (#4571) (#4578) 06e229cc7 release v8.3.10 9e388055e chore(cmsis-pack): create cmsis-pack for v8.3.10 (#4572) eb87767cc chore: code formatting 01cd1fed9 fix(vglite): be sure end_angle > start_angle in arc drawing 28094404a fix(refr): fix single buffered direct mode e2b19eb4a fix: build on Windows (MinGW environment) (#4538) bff1f2297 fix(docs): dropdown: fix function name in description of static options (#4535) 9787d47d0 fix: do not copy invalid areas if not double buffered mode (#4526) 6548ea0f2 feat(style): backport opa_layered 1375ea85a Update screen object opacity function documentation (#4505) a29645659 docs(calendar): update according to v8.2 changes 336f24127 feat(disp): add double buffered direct-mode efficient sync algorithm (v8.3) (#4497) 1c5df6c66 demo(sress): fix issues when the stress test is opened/clsoed multiple times 7d314aab6 fix(sdl): add missing parameter in lv_draw_sdl_composite_texture_obtain (#4490) fd21ed0eb ci: update screenshot compare from v9 to automatically create missing reference images 5fc488a08 ci(dropdown): fix test f17458924 fix(dropdown): position to the selected item in lv_dropdown_set_selected bcebafe4f docs(simulator): remove SDL support from the Visual Studio project 8063fac79 fix(btnmatrix): fix tapping just outside a button in a buttonmatrix 9ec3b8706 docs: update changelog bdf5bfb88 chore(cmsis-pack): prepare for release v8.3.9 (#4424) 4f102d7b6 fix: use const lv_img_dsc_t * dsc function parameter in lv_img_buf.h/ 810852b41 docs(disp): metined that rotation rotates the touch coordinates too 21e95bc1b fix(decoder): fix LV_IMG_CF_ALPHA_8BIT bin file decoder (#4406) dbcf56288 fix(config): fix typo in LV_USE_PERF_MONITOR and LV_USE_MEM_MONITOR (#4403) eee2dd186 fix(attr): refactor LV_ATTRIBUTE_* for function attributes (#4404) 141f4b8ab fix(font): fix optimizer issue in lv_font_fmt_txt.c (#4385) f9ffcc9d8 fix(chart): fix lv_chart_get_point_pos_by_id 385d999a4 fix(imgbtn): support LV_OBJ_FLAG_CHECKABLE 29ed7c571 fix(btnmatrix): Fix typo in previous commit! 65f1c9305 fix(btnmatrix): Hide button matrix when all buttons hidden b1bbb95ce chore: format code 223dc1cf9 fix(tabview): fix warning 416b26771 chore(music demo) fix formatting 645006e35 fix(indev): fix warnings when loggin coordinates is enabled 375b3b5d3 fix(obj) prevent hidden objects keeping focus 1c5d4b02d Merge branch 'demo-close' into release/v8.3 e6d7be00b docs: update changelog 15433d69b chore(cmsis-pack): update cmsis-pack for v8.3.8 (#4340) 91038a99e demos: add lv_demo_..._close() functions for each demo 9491c3ff6 example(tabview): fix tabview disable scrollig example 3de61c76a fix(tabview): remove the animation if the tab is selected by clicking the button on the header 09cc0de57 docs: mention incompatibility between software rotation and `direct_mode` or `full_refresh` (#4308) 227ac0234 docs(faq): don't say 24 bit is support as LVGL can't render in RGB888 directly 8b83fe7ea feat(rt-thread): make the rt-thread env recursively glob the UI files edd5ad28a fix(btnmatrix): fix array out of bounds addressing with groups and no buttons 07bce7466 fix:(BtnMatrix) Backport https://github.com/lvgl/lvgl/pull/4185 1713cd3fd Revert "fix:(BtnMatrix) Backport https://github.com/lvgl/lvgl/pull/4185" cb602ea77 fix:(BtnMatrix) Backport https://github.com/lvgl/lvgl/pull/4185 caf29ef0c add(docs): add renesas-ra6m3 get-started document (#4278) a3199514a fix(stm32): static function prototypes moved from .h to .c (#4276) 78cbdfc15 add(gpu): add renesas-ra6m3 gpu adaptation (#4270) 75e6ef4e1 fix(btnmatrix): fix using > 7 as button width 2376c5786 fix(png): fix decode image size and some warnings (#4248) e3659c46b fix(arduino): fix messed up variable types df96b57f4 fix(bidi): add more Hebrew checks to RTL characters set (#4171) (#4239) 67b3011f8 fix(chart): fix division by zero if there are no ticks d87737612 perf(pxp, vglite): improve performance and add more features (#4222) 6a89bd2d7 fix(msgbox): fix typo 6843c191b fix(msgbox): add missing lv_obj_class_init_obj 1caafc55d fix(disp): fix memory leak lv_scr_load_anim with auto_del and time=0 5ba90a5c4 fix(flex): register LV_STYLE_FLEX_GROW 630da9c6c fix(img): fix getting the image type on big endian systems (#4215) ee95e7dc2 fix(sdl): destroy texture after use if not stored in cache (#4173) 45b13c378 fix(draw): typo with LV_COLOR_DEPTH 8 2b56e0420 chore(cmsis-pack): update cmsis-pack for v8.3.7 (#4203) 177900b03 docs(changelog): update changelog for v8.3.7 203e7fc97 fix (spinbox): doubling characters entered from the keyboard (#4190) 7345e6235 fix(arm-2d): fix transform-chrome-keying issue (#4178) 48d7878ba fix(style): fix trasition on bg_grad color fixes: #4174 a0795b49e fix(indev): fix integer overflow in recursive zoom calculation a150b15e4 feat(btnmatrix): review ctrl map and allow width values to be max 15 a95714ba7 fix(menu): prevent setting the current page again (#4136) 8536152d8 fix(esp): fix ESP-IDF pedantic builds (backport v8.3) (#4135) 631444183 fix: color mixing with LV_COLOR_SWAP == 1 (#4101) 88c51b22a docs: udpate changelog 6b0092c0d chore(cmsis-pack): update cmsis-pack for v8.3.6 (#4108) aa313806d fix(bar): delete running animations when a new value is set without animation 5e0e1c8c4 chore: code formatting d0e19eb2d fix(arc): fix knob area invalidation fd20fabfd fix(group): fix default_group becomes wild pointer when deleted (#4076) 399069b4a Update build_html_examples.sh 501230e0f docs: use a fixed commit of lv_web_emscripten adcf16638 fix(fs_posix): allow creating new file and set permission. (#3976) 2f294aa76 docs(arduino): add note to not use lv_examles library 9a870b34a format code 0b7777f27 fix(slider): consider animations on pressing e8d8f399e fix(img): support negative angles (#3846) 0df09db23 fix(gif): synchronize with master (#4003) e2386fd46 fix(gpu): fix STM GPU drivers for some variants (#4004) 2944277f0 fix(img): possible divide by 0 exception (lvgl#3988) (#3990) 6af01798d feat(msg): add lv_msg_unsubcribe_obj 77670fb1a chore: update the version numbers to v8.3.5-dev f29514aa5 docs: update changelog e7e8cf846 feat(cmsis-pack): update cmsis-pack for v8.3.5 (#3972) 8b1270347 fix(monkey): remove executable permissions from source files (#3971) e6cd7063b fix(ci): set Ubuntu version for MicroPython test (#3865) 34c545ef1 docs(indev): fix the name of long_press_repeat_time (was long_press_rep_time) 361ee7961 feat(gpu): improve NXP's PXP and VGLite accelerators (#3952) 39f424767 fix(roller): consider the recolor setting of the label 1853cc514 perf(dam2d): rework stm32 dma2d (#3904) 9faca8a8d Update layer.md 8ea6f03fc fix(Kconfig): Fix wrong type of LV_FS_STDIO_CACHE_SIZE (v8.3) (#3906) c6c1b0b3d chore: add an option to "LV_TICK_CUSTOM" (#3879) e529230f4 ci(esp): fix push to the component registry on tag dbb15bb3e feat(cmsis-pack): update for v8.3.4 (#3896) 47c8f8f98 bump version numbers to v8.3.5-dev 2c0162b45 release v8.3.4 dec580b9f fix(rt-thread): sync rt-thread v5.0.0 rt_align (#3864) ad56dfaf7 fix(gridnav): fix stucking in pressed state with encoder c8e584f87 fix(style): add the missing support for pct pivot in tranasform style properties d2d886aae fix(draw): SDL2 gradient support #3848 (#3856) 1e3ca25fe fix(example): fix warnings 84cf05d8b fix(indev): fix scrolling on transformed obejcts 2c17b28ac fix(darw): add back the disappeared antialising=0 support 1ed026ca7 fix(benchmark): fix warnings ae3825871 demo(benchmark): fix lv_label_set_text_fmt format strings ae300acb2 [v8.3.x][rt-thread][squareline] fix compiler cannot find the lvgl/lvg… (#3834) 41fa41613 fix(msg): fix typos in API by adding wrappers fixes #3822 68f6190f8 chore: format code 1173dcba9 demo(benchmark): fix warning 716e5e2c8 fix(meter): fix setting part_draw_dsc.id in needle img drawing bb2c2ac34 fix(chart): fix very dense bar charts c4c400716 fix(flex): be sure obj->w_layout and h_layout can't be set at the same time 6825d4bd1 chore(table): remove extra spaces (#3805) 39d03a80f feat(table): scroll to the selected cell with key navigation 340a1cb60 fix(esp.cmake): add demos and examples (#3784) e06f03db7 fix(draw): fix transformation accuracy bd11ad854 fix(draw): handle LV_COLOR_DEPTH == 1 too in lv_draw_sw_transform e050f5ca1 fix(draw): fix text color with sub pixel rendering and BGR order 903e94b71 fix(style): remove the reduntant define of LV_GRADIENT_MAX_STOPS 0732400e7 Revert "feat(keyboard): ported arabic keyboard from release 7.10.0 (#3728)" 483b2a432 feat(keyboard): ported arabic keyboard from release 7.10.0 (#3728) 5545ffc92 release v8.3.3 c8bee4041 fix: version number in lvgl.h 755d363ec release v8.3.2 dfd14fa77 fix(slider): find the nearest value on click instead of floor 1ab9aa531 fix(fragment): fixed child fragment event dispatch (#3683) 4d69cd865 fix(sdl): clear streaming/target texture with FillRect (#3682) 832bef434 fix(sdl): transformation with alpha (#3576) (#3678) d5b2a9b25 fix(draw): fix border drawing with thick borders 764095021 chore: fix warnings 8b605cc48 fix(refr): fix true double double buffering logic with transparent screens ece349500 fix(draw): allow drawing outline with LV_DRAW_COMPLEX == 0 too f6655c2aa fix(draw_sw): fix image cache to access the freed stack space (#3584) cba2aa95c fix(style): use compile time prop_cnt for const styles (#3609) 660464c97 chore(rt-thread) backport fixes from v9 (#3604) 5156ee058 fix(group): be sure obj is removed from its current group in lv_group_add_obj a0515ba30 fix(style): add missing invalidation in lv_obj_remove_local_style_prop 1a4603091 docs(draw) remove reference to old lv_fs_add_drv function (#3564) f58dcd94f docs(disp): LV_COLOR_SCREEN_TRANSP remove dependency on LV_COLOR_DEPTH_32 as transparency is supported across all color depths (#3556) d59bba12d fix(colorwheel): fix updating color when using lv_colorwheel_set_hsv 5022476ed remove accidentally added code b884abae2 fix(canvas): fix clipéping on transformation aa45d5985 fix(demo): can not found lvgl.h file (#3477) 55e95ed35 fix(ci) checkout lv_micropython release/v8 branch (#3524) be485d760 ci: protect test.c with #if LV_BUILD_TEST git-subtree-dir: lib/lvgl git-subtree-split: 74d0a816a440eea53e030c4f1af842a94f7ce3d3
7 months ago
If you enable rotation the coordinates of the pointer input devices (e.g. touchpad) will be rotated too.
Note that when using software rotation, you cannot use neither `direct_mode` nor `full_refresh` in the driver. When using either of these, you will have to rotate the pixels yourself e.g. in the `flush_cb`.
Support for software rotation is a new feature, so there may be some glitches/bugs depending on your configuration. If you encounter a problem please open an issue on [GitHub](https://github.com/lvgl/lvgl/issues).
### Decoupling the display refresh timer
Normally the dirty (a.k.a invalid) areas are checked and redrawn in every `LV_DISP_DEF_REFR_PERIOD` milliseconds (set in `lv_conf.h`).
However, in some cases you might need more control on when the display refreshing happen, for example to synchronize rendering with VSYNC or the TE signal.
You can do this in the following way:
```c
/*Delete the original display refresh timer*/
lv_timer_del(disp->refr_timer);
disp->refr_timer = NULL;
/*Call this anywhere you want to refresh the dirty areas*/
_lv_disp_refr_timer(NULL);
```
If you have multiple displays call `lv_disp_set_deafult(disp1);` to select the display to refresh before `_lv_disp_refr_timer(NULL);`.
Note that `lv_timer_handler()` and `_lv_disp_refr_timer()` can not run at the same time.
If the performance monitor is enabled, the value of `LV_DISP_DEF_REFR_PERIOD` needs to be set to be consistent with the refresh period of the display to ensure that the statistical results are correct.
## Further reading
- [lv_port_disp_template.c](https://github.com/lvgl/lvgl/blob/master/examples/porting/lv_port_disp_template.c) for a template for your own driver.
- [Drawing](/overview/drawing) to learn more about how rendering works in LVGL.
- [Display features](/overview/display) to learn more about higher level display features.
## API
```eval_rst
.. doxygenfile:: lv_hal_disp.h
:project: lvgl
```