Hello there,
I have been trying out different approaches for the last days and I cannot get things running. I need to get the basics done so that I can draw things on the display first. Currently I just end up with a black screen.
I have an ESP32C3 SuperMini and want to use it to draw things on my GC9A01-display.
I am very new to the topic and I cannot find a solution that works for me. Therefore I am reaching out here asking you for help and explanation, what I am doing and what’s wrong with what I am trying. Really appreciate your help!
That’s what I have done and tried:
- Get lvgl_micropython:
git clone https://github.com/lvgl-micropython/lvgl_micropython - Create a docker to build the firmware. That’s my Dockerfile:
# base image: Ubuntu 22.04
FROM ubuntu:22.04
# install dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
git \
wget \
cmake \
ninja-build \
python3 \
python3-pip \
python3-venv \
libusb-1.0-0 \
libusb-dev \
nano \
&& \
rm -rf /var/lib/apt/lists/*
# copy lvgl-micropython in docker
COPY . /lvm/
# use bash as standard shell
CMD ["/bin/bash"]
- Build container:
docker build -t micropython-lvgl . - Run container:
docker run -it --rm -v $(pwd)/build:/lvm/build micropython-lvgl - According to the readme.md from the github-page:
cd lvm/lvgl_micropython/
python3 make.py esp32 BOARD=ESP32_GENERIC_C3 DISPLAY=gc9a01 LV_CFLAGS="-DLV_COLOR_DEPTH=16" --flash-size=4
- Extract the firmware from the container, flash it using esptool
- According to the readme.md I tried the following main.py on my ESP32C3:
import lcd_bus # type:ignore
from micropython import const # type:ignore
import machine # type:ignore
# display settings
_WIDTH = const(240)
_HEIGHT = const(240)
_BL = const(3)
_RST = const(0)
_DC = const(1)
_MOSI = const(6)
_MISO = const(5)
_SCK = const(4)
_HOST = const(1)
_CS = const(10)
_LCD_FREQ = const(10_000_000)
spi_bus = machine.SPI.Bus(
host = _HOST,
mosi = _MOSI,
miso = _MISO,
sck = _SCK
)
display_bus = lcd_bus.SPIBus(
spi_bus = spi_bus,
freq = _LCD_FREQ,
dc = _DC,
cs = _CS,
)
import lvgl as lv # type:ignore
import gc9a01 # type:ignore
display = gc9a01.GC9A01(
data_bus = display_bus,
display_width = _WIDTH,
display_height = _HEIGHT,
backlight_pin = _BL
)
display.set_power(True)
display.init()
display.set_backlight(100)
scrn = lv.screen_active()
scrn.set_style_bg_color(lv.color_hex(0x000000), 0)
label = lv.label(scrn)
label.set_text('HELLO WORLD!')
label.align(lv.ALIGN.CENTER, 0, -50)