daumemo / LVGL_tutorial_simple_project

Other
20 stars 1 forks source link

Question about settings for monochrome display of LCD screens. #1

Open nezumimrx opened 1 year ago

nezumimrx commented 1 year ago

Hi Daumemo, So glad to find your post on "How to use LVGL library – Arduino on an ESP-32 and SPI LCD". It's really really helpful to my kind of beginners of LVGL lib.

I am currently working on a project that requires a monochrome display on a 240*320-pixel LCD screen to show color-depth 1 BMP format images. But I can't get my code to show images properly. Could you be so kind as to give some examples, please? I am desperate in need of some help.... Especially on those callback functions. I have no idea how to write void my_disp_flush() properly to display monochrome images.

I have did some changes to lv_conf.h.:

define USE_LV_THEME_MONO 1 /Mono color theme for monochrome displays/

define LV_USE_BMP 1

define LV_COLOR_DEPTH 1

define LV_COLOR_16_SWAP 0

and I read another post (https://maldus512.medium.com/porting-littlevgl-for-a-monochrome-display-6c7be58851ce). So I added some functions. void my_set_px_cb(lv_disp_drv_t disp_drv, uint8_t buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa) void my_rounder_cb(lv_disp_drv_t disp_drv, lv_area_t area)

ln setup function, I wrote: static lv_disp_drv_t disp_drv; lv_disp_drv_init( &disp_drv ); disp_drv.hor_res = screenWidth; disp_drv.ver_res = screenHeight; disp_drv.flush_cb = my_disp_flush; /Callback/ disp_drv.set_px_cb = my_set_px_cb; /Callback/ disp_drv.rounder_cb = my_rounder_cb; /Callback/ disp_drv.draw_buf = &draw_buf; lv_disp_t * disp; disp = lv_disp_drv_register(&disp_drv);

but I think the real problem is the my_disp_flush callback function doesn't match with monochrome settings. void my_disp_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 ); tft.startWrite(); tft.setAddrWindow( area->x1, area->y1, w, h ); tft.pushColors( ( uint16_t )&color_p->full, w * h, true ); tft.endWrite(); lv_disp_flush_ready( disp ); }

since this function display 16bit color.

What should I do to solve this problem?

daumemo commented 10 months ago

Hi, sorry for a one year late replay from me - somehow I have missed your question. First of all - I myself am no professional in LVGL - I have learned everything by just try-and-test method. The monochrome display use case makes even more difficult to answer your question, as I personally don't have any experience with such type of displays. One of ideas, that you have proposed yourself, could be checking my_disp_flush function. It uses tft.* method which might be more or less display specific functions. Especially tft.pushColors is used for displaying colored images and not bitmap images - which might need changing to another function altogether.