App not displaying something consistent since I upgraded to the 9.0.0 version

Hi !

I noticed there are many breaking changes in recent versions. For example :
- lv_color_t datatype doesn’t seem to offer the full member anymore.
- lv_disp_drv_t and lv_disp_draw_buf_t datatype were removed
- lv_disp_drv_init and lv_disp_draw_buf_init functions were removed
- lv_indev_drv_t datatype was removed
- lv_mem_free function seems to have been renamed to lv_free
- …

I tried my best to make my project work after upgrading, but after few days, I’m not event able to display anything consistent but only some garbage pixels. I’m using the Lilygo T-Display-S3 board and it was working fine before the upgrade. The intial PlatformIO version I used was 8.3.7 and I’m now trying to upgrade to version 9.0.0 (on GitHub). I wish I won’t have to revert to the PlatformIO actual library version.

Note that using directly TFT_eSPI library is still working fine. The issue is only with LVGL.

I followed LVGL documentation guidelines here : https://docs.lvgl.io/master/porting/disp.html#. But I can’t find complete example showing how to make it work with the Master version, but only previous versions. Can anyone give me a link where I can find some complete examples working (with the Master version) ?

Thank you very much in advance !

Here is a simplified code listing that explained how I did it :

#include <TFT_eSPI.h>
#include <lvgl.h>

#define CONFIG_LCD_PWR_GPIO_PIN 15 // LED Backlight

static const char *TAG_MAIN = "MAIN";

void espidf_set_GPIO_pin(gpio_num_t GPIO_pin, gpio_mode_t GPIO_pin_mode, uint32_t  GPIO_pin_level = 0)  //TODO : ajouter gestion d'erreur
{

    if(GPIO_pin != GPIO_NUM_NC)
    {
        // Set the GPIO pin to output mode
        gpio_pad_select_gpio(GPIO_pin);
        gpio_set_direction(GPIO_pin, GPIO_pin_mode);

        // set GPIO pin if GPIO_MODE_OUTPUT
        if (GPIO_pin_mode == GPIO_MODE_OUTPUT) gpio_set_level(GPIO_pin, GPIO_pin_level);

        char level_str[10];
        sprintf(level_str, ", Level %u", GPIO_pin_level);
        ESP_LOGD(TAG_MAIN, "Pin %d, Mode %d %s", GPIO_pin, GPIO_pin_mode, (GPIO_pin_mode == GPIO_MODE_OUTPUT)? level_str : "");
    }
    else
    {
        ESP_LOGD(TAG_MAIN, "espidf_set_GPIO_pin: GPIO_pin is -1 (not present/not used on this board) ");
    }
}

//TFT screen resolution
static const uint16_t screenWidth  = 170;
static const uint16_t screenHeight = 320;

// static lv_color_t buf[screenWidth * screenHeight / 10];
static lv_color_t buf[screenWidth * screenHeight];

TFT_eSPI gfx=TFT_eSPI(screenWidth /* width */, screenHeight /* height */);

// // Display flushing
// void disp_flush( lv_disp_t *disp, const lv_area_t *area, lv_color_t *color_p )
// // void my_disp_flush( lv_disp_t *disp, const lv_area_t *area, lv_color_t *color_p )
// {
//     uint32_t w = ( area->x2 - area->x1 + 1 );
//     uint32_t h = ( area->y2 - area->y1 + 1 );

//     gfx.startWrite();
//     gfx.setAddrWindow( area->x1, area->y1, w, h );
//     gfx.pushColors( ( uint16_t * ) &color_p->full, w * h, true );
//     gfx.endWrite();

//     lv_disp_flush_ready( disp );
// }

void disp_flush( lv_disp_t *disp, const lv_area_t *area, lv_color_t *color_p )
{
    uint32_t w = ( area->x2 - area->x1 + 1 );
    uint32_t h = ( area->y2 - area->y1 + 1 );

    gfx.startWrite();
    gfx.setAddrWindow( area->x1, area->y1, w, h );
    uint16_t color_int = (color_p->red << 11) | (color_p->green << 5) | color_p->blue;
    //  gfx.pushColors( ( uint16_t * ) &color_p->full, w * h, true );
    gfx.pushColors(( uint16_t * ) &color_int, w * h, true);
    gfx.endWrite();

    lv_disp_flush_ready( disp );

    Serial.println("Buffer Flushed.");
}

// void disp_flush( lv_disp_t *disp, const lv_area_t *area, lv_color_t *color_p )
// {
//     uint32_t w = ( area->x2 - area->x1 + 1 );
//     uint32_t h = ( area->y2 - area->y1 + 1 );

//     int32_t x, y;
//     for(y = area->y1; y <= area->y2; y++) {
//         for(x = area->x1; x <= area->x2; x++) {
//             lv_color32_t color32_p = lv_color_to32(*color_p);
//             uint32_t color_int = (color32_p.alpha << 24) | (color32_p.red << 16) | (color32_p.green << 8) | color32_p.blue;
//             gfx.drawPixel(x, y, color_int);
//             color_p++;
//         }
//     }

//     lv_disp_flush_ready( disp );

//     Serial.println("Buffer Flushed.");
// }

extern "C" void app_main()
{

    initArduino();

    Serial.begin(115200);
    while (!Serial) delay(10);

    Serial.println("-- TFT TEST START -- ");

   // Turning on TFT
    espidf_set_GPIO_pin (static_cast<gpio_num_t>(CONFIG_LCD_PWR_GPIO_PIN), GPIO_MODE_OUTPUT, 1);

   // Turning on Backlight
    espidf_set_GPIO_pin (static_cast<gpio_num_t>(TFT_BL), GPIO_MODE_OUTPUT, 1);

    gfx.begin();
    gfx.setRotation(3);
    gfx.fillScreen(TFT_BLACK);
    gfx.setCursor(40, 20);
    gfx.setTextColor(TFT_WHITE);
    gfx.setTextSize(2);
    gfx.println("TFT_eSPI Direct Test");

    Serial.println("-- TFT TEST END -- ");

    Serial.println("-- LVGL MENU TEST START -- ");

    lv_init();
    static lv_disp_t *disp = lv_disp_create(screenWidth, screenHeight);
    lv_disp_set_res(disp, screenWidth, screenHeight);
    lv_disp_set_physical_res(disp, screenWidth, screenHeight);
    // lv_disp_set_offset(disp, x, y)

    lv_disp_set_flush_cb(disp, disp_flush);

    // lv_disp_set_draw_buffers(disp, buf, NULL, sizeof(buf), LV_DISP_RENDER_MODE_DIRECT);
    lv_disp_set_draw_buffers(disp, buf, NULL, sizeof(buf), LV_DISP_RENDER_MODE_PARTIAL);

    // lv_disp_set_rotation(disp, LV_DISP_ROTATION_270, true);
    lv_disp_set_rotation(disp, LV_DISP_ROTATION_270, false);
    // lv_disp_set_antialaising(disp, true);
    // lv_disp_set_color_depth(disp, LV_COLOR_FORMAT_...);

    // ui_init();

    String LVGL_Test = "TEST! Powered by LVGL ";
    LVGL_Test += String('V') + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch();

    Serial.println(LVGL_Test);
    lv_obj_t *label = lv_label_create( lv_scr_act() );
    lv_label_set_text( label, LVGL_Test.c_str() );
    lv_obj_align( label, LV_ALIGN_CENTER, 0, 0 );

    while (true)
    {
        lv_timer_handler(); // let the GUI do its work
        delay( 5 );
    }

}

Hi,

Note that v9 is still under development and not fully stable. If you are looking for something stable you can use the v8.3.x versions.

Regarding the API changes, see this summary: Changes in master - new driver API · Issue #4011 · lvgl/lvgl · GitHub

Regarding the garbage screen: Can you send a photo about it?