RGB332 native display format in LVGL 9


I would like to use RGB332 as LVGL’s native format in my application. My display is a RGB332 1024x600 RGB TTL display on a ESP32S3.

lv.conf has these options for LV_COLOR_DEPTH:

/*Color depth: 8 (A8), 16 (RGB565), 24 (RGB888), 32 (XRGB8888)*/

None of which seem to fit. I am setting up drawing using

    lv_display_t * lv_display = lv_display_create(1024, 600);
    lv_display_set_flush_cb(lv_display, lv_flush_cb);
    lv_display_set_buffers(lv_display, lv_buf, NULL, H_RES*V_RES/10, LV_DISPLAY_RENDER_MODE_PARTIAL);

and then in my lv_flush_cb:

void lv_flush_cb(lv_display_t * display, const lv_area_t * area, unsigned char * px_map)
    uint8_t * buf = (uint8_t *)px_map; 
    int16_t x, y;
    for(y = area->y1; y <= area->y2; y++) {
        for(x = area->x1; x <= area->x2; x++) {
            // bg is a framebuffer i maintain that is drawn to the ESP GDMA to the display
            bg[y*1024 + x] = (*buf);
    // Inform LVGL that you are ready with the flushing and buf is not used anymore

With LV_COLOR_DEPTH at 8, this only results in a black screen. Setting LV_COLOR_DEPTH to 16 and converting RGB565 to RGB332 on the fly in lv_flush_cb does work fine, but is slow and wastes CPU and RAM.

How can I achieve this? I can’t find much information online other than older versions of LVGL which indicated that LV_COLOR_DEPTH = 8 was for RGB332. But that seems to have changed.

1 Like

I’ve eventually done this myself, including color blending for RGB332. If this is any interest to anyone it is in the Tulip fork here: lvgl/src/draw/sw/blend/lv_draw_sw_blend_to_rgb332.c at tulip · bwhitman/lvgl · GitHub

1 Like

Very useful, thank you very much