Description
I am attempting to get lvgl working on my NodeMCU-32s (ESP32 wroom) clone, and so far I can initialize the 7" display (using the RA8875 controller and code (from Adafruit) with a label. That part works fine.
The problem occurs when I go to update the label to change the text (e.g., using a task every 500 ms). the original text remains in place on the screen, however any subsequent text updates cause ghosted lines to be drawn around the original text. I even enabled the FPS counter in the bottom corner, and it does the same thing across the bottom.
What MCU/Processor/Board and compiler are you using?
NodeMCU-32s (ESP32 wroom)
CLion + PlatformIO
What LVGL version are you using?
7.9
What do you want to achieve?
To be able to update the UI, and it be reflected correctly on screen.
What have you tried so far?
I’ve tried enabling double-buffering to no avail.
Code to reproduce
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_RA8875.h>
#include <lvgl.h>
#define RA8875_INT 13
#define RA8875_CS 5
#define RA8875_RESET 12
#define BUFFER_SIZE (LV_HOR_RES_MAX * 10)
#define NBR_PIXELS_IN_BUFFER (BUFFER_SIZE)
Adafruit_RA8875 get_tft() {
static Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
return tft;
}
static lv_disp_buf_t disp_buf;
static lv_color_t buf0[BUFFER_SIZE], buf1[BUFFER_SIZE];
void display_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p);
void task(lv_task_t * task) {
static uint8_t toggle = 0;
auto * label = (lv_obj_t *) task->user_data;
if ((toggle++ % 2) != 0) {
lv_label_set_text(label, "Hello Arduino! (V7.9.X)");
} else {
lv_label_set_text(label, "Hello World!");
}
}
void setup() {
Serial.begin(115200);
lv_init();
Adafruit_RA8875 tft = get_tft();
tft.begin(RA8875_800x480);
tft.setRotation(1);
tft.displayOn(true);
tft.GPIOX(true);
tft.touchEnable(true);
tft.fillScreen(RA8875_WHITE);
tft.PWM1config(true, RA8875_PWM_CLK_DIV1024);
tft.PWM1out(255);
pinMode(RA8875_INT, INPUT);
digitalWrite(RA8875_INT, HIGH);
lv_disp_buf_init(&disp_buf, buf0, buf1, NBR_PIXELS_IN_BUFFER);
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.flush_cb = display_flush;
disp_drv.buffer = &disp_buf;
lv_disp_drv_register(&disp_drv);
lv_obj_t * label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(label, "Hello Arduino! (V7.9.x)");
lv_obj_align(label, nullptr, LV_ALIGN_CENTER, 0, 0);
lv_task_create(task, 500, LV_TASK_PRIO_MID, label);
}
void loop() {
lv_task_handler();
delay(5);
}
void display_flush(lv_disp_drv_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);
Adafruit_RA8875 tft = get_tft();
tft.startWrite();
tft.drawPixels(&color_p->full, (w * h), area->x1, area->y1);
tft.endWrite();
lv_disp_flush_ready(disp);
}
Screenshot and/or video
https://imgur.com/a/obT7biC - video showing problem