「App:Library:LVGL:docs:Porting:Display interface」の版間の差分
(ページの作成:「https://docs.lvgl.io/8.2/porting/display.html __NOTOC__ {| class="wikitable" !英文 !自動翻訳 |- | | |- | | |- | | |- | | |- | | |- | | |- | | |- | | |} ---- A…」) |
|||
30行目: | 30行目: | ||
|} | |} | ||
+ | |||
+ | |||
+ | = Display interface = | ||
+ | To register a display for LVGL, a <code>lv_disp_draw_buf_t</code> and a <code>lv_disp_drv_t</code> variable have to be initialized. | ||
+ | |||
+ | * <code>lv_disp_draw_buf_t</code> contains internal graphic buffer(s) called draw buffer(s). | ||
+ | * <code>lv_disp_drv_t</code> 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 <code>flush_cb</code> function set in the display driver (see below). | ||
+ | |||
+ | A draw buffer can be initialized via a <code>lv_disp_draw_buf_t</code> variable like this: | ||
+ | /*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 <code>lv_disp_draw_buf_t</code> 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. | ||
2022年6月21日 (火) 21:33時点における版
https://docs.lvgl.io/8.2/porting/display.html
英文 | 自動翻訳 |
---|---|
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:
/*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.