#Using Adafruit_st7789 library on lilygo_tdisplay_s3

1 messages · Page 1 of 1 (latest)

narrow socket
#

Bit of a noob here on this device. I just loaded circuitpython 9.0.4 on a lilygo_tdisplay_s3 device. Install went fine. I grabbed the adafruit_ST7789 library file and attempted to run the example from https://docs.circuitpython.org/projects/st7789/en/latest/examples.html. However this device does not have an SPI object under board. if I perfom a dir(board) I get:
['class', 'name', 'BATTERY', 'BUTTON0', 'BUTTON1', 'DISPLAY', 'IO0', 'IO1', 'IO10', 'IO11', 'IO12', 'IO13', 'IO14', 'IO16', 'IO17', 'IO18', 'IO2', 'IO21', 'IO3', 'IO43', 'IO44', 'LCD_BCKL', 'LCD_CS', 'LCD_D0', 'LCD_D1', 'LCD_D2', 'LCD_D3', 'LCD_D4', 'LCD_D5', 'LCD_D6', 'LCD_D7', 'LCD_DC', 'LCD_POWER_ON', 'LCD_RD', 'LCD_RST', 'LCD_WR', 'STEMMA_SCL', 'STEMMA_SDA', 'TOUCH_INT', 'TOUCH_RES', 'TOUCH_SCL', 'TOUCH_SDA', 'dict', 'board_id']. Note that there is no SPI object. Is that library not compatible with this board? If so, how will I write to the display?

true hatch
#

You should be able to just use board.DISPLAY and start drawing stuff by settings the root_group to a Group that you want to display. I haven't actually run it but something like this should work I think:


import board
import terminalio
import displayio
from adafruit_display_text import label

display = board.DISPLAY

# Make the display context

splash = displayio.Group()

display.root_group = splash

color_bitmap = displayio.Bitmap(240, 240, 1)

color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00  # Bright Green

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)


# Draw a smaller inner rectangle
inner_bitmap = displayio.Bitmap(200, 200, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0xAA0088  # Purple
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
splash.append(inner_sprite)


# Draw a label
text_group = displayio.Group(scale=2, x=50, y=120)
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
text_group.append(text_area)  # Subgroup for text scaling
splash.append(text_group)


while True:
    pass

One caveat being, if you already ran the other code that contains displayio.release_displays() then you will need to powercycle the device after you change your code.py file to not have that anymore.

narrow socket
#

Thanks. I will give that a shot and let you know.

high marsh
#

Just for future reference, there is no SPI object because that display isn't an SPI display. It's an 8 bit parallel (i80) display. Easiest to use the initialized display from the board.DISPLAY, but you can also manually re-initialize it if you need to, using the paralleldisplay bus library, instead of the spi/fourwire library as the bus.