Description
I’m porting LVGL to an e-Paper display for the first time using the Raspberry Pi 4. I’ve used the vendor supplied code to write bitmaps, text, graphic primitives, etc. to the display and now I want to take advantage of LVGL to build a UI. I’m running into some trouble and I believe the issue is with my flush callback.
If it helps troubleshoot, I’m using a raw e-Paper panel from Waveshare.
Edit: Specifically, it’s GDEW042T2.
The e-Paper’s datasheet: https://www.waveshare.com/w/upload/6/6a/4.2inch-e-paper-specification.pdf
The controller’s datasheet: https://www.waveshare.com/w/upload/8/88/UC8176.pdf
What MCU/Processor/Board and compiler are you using?
Raspberry Pi 4 b+ with gcc
What do you want to achieve?
Write to an e-Paper display
What have you tried so far?
I’ve gotten the code to compile and run by following the example in lvgl/examples/porting/lv_port_disp_template.c
and using the lv_example_label_1()
example in lvgl/examples/widgets/lv_example_widgets.h
, but the output is black and white stripes.
I think my problem is with lv_color_t
and how to convert it to something the vendor supplied display code can render.
Code to reproduce
A minimal example of my flush callback
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
/ * some display setup */
for (uint16_t j = 0; j < DISP_HEIGHT; j++) {
for (uint16_t i = 0; i < DISP_WIDTH; i++) {
// is this the correct approach? I can ignore area because it's full refresh right?
display_sendData(lv_color_to1(*color_p));
color_p++;
}
}
/* some display cleanup */
lv_disp_flush_ready(disp_drv);
}
display_sendData
is usually called like
uint8_t* imageBuffer;
/* fill the buffer */
for (uint16_t j = 0; j < DISP_HEIGHT; j++) {
for (uint16_t i = 0; i < DISP_WIDTH; i++) {
display_sendData(imageBuffer[i + j * DISP_WIDTH]);
color_p++;
}
}
For completeness, here is my main
function
lv_init();
disp_init();
static lv_disp_draw_buf_t draw_buf_dsc_1;
static lv_color_t buf_1[DISP_HOR_RES * DISP_VER_RES];
lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, DISP_HOR_RES * DISP_VER_RES);
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.draw_buf = &draw_buf_dsc_1;
disp_drv.hor_res = DISP_HOR_RES;
disp_drv.ver_res = DISP_VER_RES;
disp_drv.flush_cb = disp_flush;
disp_drv.full_refresh = 1;
lv_disp_t * disp;
disp = lv_disp_drv_register(&disp_drv);
lv_example_label_1();
while (1)
{
lv_task_handler();
lv_tick_inc(1);
delay_ms(1);
}
return 0;
I’ve changed two lines in lv_conf.h
. Line 15:
- #if 0 /*Set it to "1" to enable content */
+ #if 1 /*Set it to "1" to enable content */
and line 27:
- #define LV_COLOR_DEPTH 16
+ #define LV_COLOR_DEPTH 1