LCD

hub.lcd (hub._lcd_module) drives an ST7735 128x160 SPI panel plus an LVGL display layer on top.

Init

The C firmware initialises the panel hardware and LVGL before your program starts. import lvgl as lv is usable immediately — LVGL is already running when user code begins executing.

init() re-initialises LVGL from scratch. Only call it if you explicitly tore LVGL down with lv.deinit(); calling it when LVGL is already alive is unnecessary.

Rendering loop

During the menu phase the C firmware calls lv_timer_handler automatically. During user program execution the C menu loop is suspended — your program must drive LVGL itself:

import lvgl as lv, time

while True:
    lv.timer_handler()
    time.sleep_ms(5)

Backlight

Backlight is driven by the shared PCA9685:

hub.lcd.on()             # full
hub.lcd.off()            # off
hub.lcd.backlight(64)    # 0..255 → PCA9685 duty

Raw panel access

Useful before LVGL is up, or when bringing up a new panel variant:

hub.lcd.fill(0xF800)             # solid red (RGB565)
hub.lcd.setInvert(True)          # INVON
hub.lcd.setMadctl(0xA8)          # MY MV BGR
hub.lcd.setOffset(2, 3)          # GreenTab column/row offsets
hub.lcd.cmd(0x21, b"")           # arbitrary command
hub.lcd.reset()                  # pulse RESET + re-init

MADCTL bits (see ST7735 datasheet): MY=0x80, MX=0x40, MV=0x20, ML=0x10, BGR=0x08.

Soft reset

The port takes care of LVGL teardown on MicroPython soft-reset. You do not need to call lv_deinit yourself.