docs(disp): describe how to swap the bytes with RGB565 format
This commit is contained in:
@@ -136,6 +136,7 @@ or anything else to optimize while the waiting for flush.
|
||||
If ``flush_wait_cb`` is not set, LVGL assume that `lv_display_flush_ready`
|
||||
is used.
|
||||
|
||||
|
||||
Rotation
|
||||
--------
|
||||
|
||||
@@ -170,6 +171,29 @@ used as a well.
|
||||
It's very important that draw buffer(s) should be large enough for any
|
||||
selected color format.
|
||||
|
||||
|
||||
Swap endianness
|
||||
--------------
|
||||
|
||||
In case of RGB565 color format it might be required to swap the 2 bytes
|
||||
because the SPI, I2C or 8 bit parallel port periphery sends them in the wrong order.
|
||||
|
||||
The ideal solution is configure the hardware to handle the 16 bit data with different byte order,
|
||||
however if it's not possible `:cpp:expr:`lv_draw_sw_rgb565_swap(buf, buf_size_in_px)`
|
||||
can be called in the ``flush_cb`` to swap the bytes.
|
||||
|
||||
If you wish you can also write your own function, or use assembly instructions for
|
||||
the fastest possible byte swapping.
|
||||
|
||||
Note that this is not about swapping the Red and Blue channel but converting
|
||||
|
||||
``RRRRR GGG | GGG BBBBB``
|
||||
|
||||
to
|
||||
|
||||
``GGG BBBBB | RRRRR GGG``.
|
||||
|
||||
|
||||
User data
|
||||
---------
|
||||
|
||||
|
||||
@@ -259,12 +259,14 @@ void lv_display_set_flush_wait_cb(lv_display_t * disp, lv_display_flush_wait_cb_
|
||||
|
||||
/**
|
||||
* Set the color format of the display.
|
||||
* If set to other than `LV_COLOR_FORMAT_NATIVE` the layer's `buffer_convert` function will be used
|
||||
* to convert the rendered content to the desired color format.
|
||||
* @param disp pointer to a display
|
||||
* @param color_format By default `LV_COLOR_FORMAT_NATIVE` to render with L8, RGB565, RGB888 or ARGB8888.
|
||||
* `LV_COLOR_FORMAT_NATIVE_REVERSE` to change endianness.
|
||||
*
|
||||
* @param color_format Possible values are
|
||||
* - LV_COLOR_FORMAT_RGB565
|
||||
* - LV_COLOR_FORMAT_RGB888
|
||||
* - LV_COLOR_FORMAT_XRGB888
|
||||
* - LV_COLOR_FORMAT_ARGB888
|
||||
*@note To change the endianness of the rendered image in case of RGB565 format
|
||||
* (i.e. swap the 2 bytes) call `lv_draw_sw_rgb565_swap` in the flush_cb
|
||||
*/
|
||||
void lv_display_set_color_format(lv_display_t * disp, lv_color_format_t color_format);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user