Skip to content

ST7789 do not refresh when working with espcamera #8354

@StreakingJerry

Description

@StreakingJerry

CircuitPython version

Adafruit CircuitPython 8.2.4 on 2023-08-22; ESP32-S2-DevKitC-1-N4R2 with ESP32S2
Board ID:espressif_esp32s2_devkitc_1_n4r2
UID:0740D17F678D

Code/REPL

# https://learn.adafruit.com/adafruit-ov5640-camera-breakout/lcd-mirror-demo
from debugfun import breakpoint
import busio
import digitalio
import espcamera
import board
import displayio
from adafruit_st7789 import ST7789
import time


flash = digitalio.DigitalInOut(board.IO45)
flash.switch_to_output()
flash.value = False

displayio.release_displays()
spi = busio.SPI(clock=board.IO36,MOSI=board.IO35)
while not spi.try_lock():
    pass
spi.configure(baudrate=24000000) # Configure SPI for 24MHz
spi.unlock()
tft_cs = board.IO34
tft_dc = board.IO33
tft_rst = board.IO21
tft_bl = board.IO0

display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_rst)
display = ST7789(
    display_bus, 
    rotation=90, 
    width=240, 
    height=135, 
    rowstart=40, 
    colstart=53,
    backlight_pin=tft_bl,
    backlight_on_high=False,
    auto_refresh=False
    )



i2c = busio.I2C(scl=board.IO38, sda=board.IO37)
data_pin = [
    board.IO7,
    board.IO9,
    board.IO14,
    board.IO8,
    board.IO6,
    board.IO4,
    board.IO3,
    board.IO1,
]
cam = espcamera.Camera(
    data_pins=data_pin,
    pixel_clock_pin=board.IO5,
    vsync_pin=board.IO15,
    href_pin=board.IO16,
    i2c=i2c,
    external_clock_pin=board.IO2,
    # external_clock_frequency=16_000_000,
    # powerdown_pin=None,
    # reset_pin=None,
    # pixel_format=espcamera.PixelFormat.JPEG
    # frame_size=espcamera.FrameSize.QQVGA
    # jpeg_quality = 5,
    # framebuffer_count = 1,
    # grab_mode=espcamera.GrabMode.WHEN_EMPTY
)
frame = cam.take(1)
group = displayio.Group()
tg = displayio.TileGrid(frame,pixel_shader=displayio.ColorConverter(input_colorspace=displayio.Colorspace.RGB565_SWAPPED))
group.append(tg)
display.root_group = group
while True:
    frame = cam.take(1)
    display.refresh()

Behavior

My hardware is ESP32-S2-MINI-2-N4R2 module.

The image does not refresh.

But if I modify the main loop to the following one, It works.

while True:
    frame = cam.take(1)
    tg = displayio.TileGrid(frame,pixel_shader=displayio.ColorConverter(input_colorspace=displayio.Colorspace.RGB565_SWAPPED))
    group.append(tg)
    display.refresh()

Also, another small issue. I have external pull down resistor on the IO45. But when the circuitpython is running, the IO45 is still HIGH. That why I have to use digitalio to set it to LOW. But I have no idea about the reason.

Description

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions