I would like to use (for testing purposes mostly) one of those cheap SSD1306-based OLED displays. Micropython provides a ssd1306 driver (micropython/ssd1306.py at master · micropython/micropython · GitHub) and I thought it would be straightforward to use with LVGL. The platform is RPi Pico, and the oled works without LVGL just fine.
I am not able to get LVGL to show anything on the screen, but it might be just my misunderstanding of how is the buffer (and its bit depth!) supposed to be configured. Do I create a separate buffer for LVGL, which will then be copied into the ssd1306 “internal” (python-side) buffer, and then flushed over i2c? I would appreciate a short working example, or a pointer how to do it.
import ssd1306
from machine import Pin, I2C
i2c=I2C(0,sda=Pin(4),scl=Pin(5),freq=50000)
oled=ssd1306.SSD1306_I2C(128,32,i2c)
import lvgl as lv
lv.init()
buf=lv.disp_draw_buf_t()
# can I use oled.buffer here? and how to specify bit depth?
buf.init(oled.buffer,None,len(oled.buffer)//4)
drv=lv.disp_drv_t()
drv.init()
drv.draw_buf=buf
drv.flush_cb=oled.show
drv.hor_res=128
drv.ver_res=32
drv.register()
scr = lv.obj()
btn = lv.btn(scr)
btn.align(lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text("Button")
lv.scr_load(scr)