LVGL *must* be compiled with LV_COLOR_DEPTH=16

I built the lv_micropython firmware using instructions GitHub - lvgl/lv_micropython: Micropython bindings to LVGL for Embedded devices, Unix and JavaScript
and when I ran (blink) main.py on the pico with that firmware that worked.
So changed main.py to run

from machine import Pin
from utime import sleep
import machine
from driver.generic.st77xx import *
spi=machine.SPI(
    0,
    baudrate=24_000_000,
    polarity=0,
    phase=0,
    sck=machine.Pin(2,machine.Pin.OUT),
    mosi=machine.Pin(3,machine.Pin.OUT)
)

import lvgl as lv
lv.init()

lcd=St7789(rot=3,res=(240,320),spi=spi,cs=1,dc=0,rst=4,rp2_dma=None,factor=8)
lcd.set_backlight(30)

scr=lv.obj()
btn=lv.btn(scr)
lbl=lv.label(btn)
lbl.set_text("Press me!")
btn.center()
btn.add_event(lambda event: print('Button clicked!'),lv.EVENT.CLICKED,None)
lv.scr_load(scr)

and got error in VSCode repl

>>> 
Traceback (most recent call last):
  File "<stdin>", line 24, in <module>
  File "driver/generic/st77xx.py", line 472, in __init__
  File "driver/generic/st77xx.py", line 448, in __init__
RuntimeError: LVGL *must* be compiled with LV_COLOR_DEPTH=16 (currently LV_COLOR_DEPTH=32.

in GitHub - lvgl/lv_micropython: Micropython bindings to LVGL for Embedded devices, Unix and JavaScript
suggested command is

make -j -C ports/rp2 BOARD=PICO USER_C_MODULES=../../lib/lv_bindings/bindings.cmake

I modified it to

make -j -C ports/rp2 LV_CFLAGS="-DLV_COLOR_DEPTH=16" BOARD=PICO USER_C_MODULES=../../lib/lv_bindings/bindings.cmake

based on something I had seen in esp32 instructions when targeting the ILI9341 at GitHub - lvgl/lv_micropython: Micropython bindings to LVGL for Embedded devices, Unix and JavaScript

Should that have worked? I still get the same error

LVGL *must* be compiled with LV_COLOR_DEPTH=16

I’ll try editing lv_conf.h and rebuilding.

Is there a way to tell what value the firmware contains when built without first having to deploy to the microcontroller?

Edit this file manually:

lv_micropython/lib/lv_bindings/lv_conf.h

Change this place to 16, and then recompile the firmware.

#define LV_COLOR_DEPTH 32

yup, did that and it worked

1 Like