Lv_draw_sw_rgb565_swap

Description

Swap rgb byte order on ili9341.

What MCU/Processor/Board and compiler are you using?

Esp32 toolchain on VSCode

What LVGL version are you using?

9.1

What do you want to achieve?

I want to swap color bytes order.

What have you tried so far?

I’ve tried to #define LV_DRAW_SW_RGB565_SWAP in lv_draw_sw.h and also lv_conf.h but an error is thrown becuse when lv_draw_sw_rgb565_swap is called, also this macro LV_DRAW_SW_RGB565_SWAP is called, and it doesn’t seem to be defined correctly.
in lvgl 8 it was super easy, you just had to define LV_COLOR_16_SWAP in your lv_conf.h and everything was OK.

In lv_display.h i’ve found some lines that tells to call lv_draw_sw_rgb565_swap in my flusc_cb, but i don’t have idea on where (and with which parameters) i have to do that call.
I just havent found documentation about it for v9.

Code to reproduce

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

hey, this was tricky for me too, but i solved like this:

void Renderer::flushCb(
    lv_display_t *display, const lv_area_t *area, uint8_t *px_map)
{
    lv_draw_sw_rgb565_swap(
        px_map, (area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1));

    const int offsetx1 = area->x1;
    const int offsetx2 = area->x2;
    const int offsety1 = area->y1;
    const int offsety2 = area->y2;
    esp_lcd_panel_draw_bitmap(
        panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, px_map);

    lv_disp_flush_ready(display);
}

you have to swap the colors before sending the command to draw the bitmap.

1 Like

Thanks a lot, i was just replying to myself saying to the world how i solved. Actually i made it the way lvgl v8 made it. In the function call_flush_cb in the file lvgl/core/lv_ref.c, I added lv_draw_sw_rgb565_swap(px_map, lv_area_get_size(&offset_area));. In lvgl8 they also made a check using #ifdef and a constant, something like LV_16_SWAP but i’m not sure 100% about the name. Anyway, that constant was configurable in lv_conf.h and lv_ref.c knew about it. Since v9, lv_ref.c has no access (i.e. doesnt include it) to lv_conf.h. So, instead of adding a constant and including lv_conf.h in lv_ref.c (modifying even more lvgl structure) of lv_conf.h i just preferred to call the byte swapping.

1 Like