Programming Adafruit Feather LCD in CircuitPython

For anyone else who got an Adafruit ESP32-S3 Reverse TFT Feather over the holidays and wants to program its display from CircuitPython, the following is the incantation needed to get everything set up:

import adafruit_st7789
import board
import digitalio
import displayio

# Take control of the display.
displayio.release_displays()

# Turn on the display's backlight.
display_backlight = digitalio.DigitalInOut(board.TFT_BACKLIGHT)
display_backlight.direction = digitalio.Direction.OUTPUT
display_backlight.value = True

# Set up a driver object for the display.
spi = board.SPI()
display_bus = displayio.FourWire(spi, command=board.TFT_DC, chip_select=board.TFT_CS)
display = adafruit_st7789.ST7789(
    display_bus,
    rotation=270,
    width=240,
    height=135,
    rowstart=40,
    colstart=53,
)

# Set up graphics on the display.
root = displayio.Group()
display.root_group = root

# Add a white background to the display.
bg_bitmap = displayio.Bitmap(display.width, display.height, 1)
bg_palette = displayio.Palette(1)
bg_palette[0] = 0xFFFFFF

bg_sprite = displayio.TileGrid(bg_bitmap, pixel_shader=bg_palette, x=0, y=0)
root.append(bg_sprite)

You will need the adafruit_st7789 library from the Adafruit CircuitPython Bundle. Either install it with pip3 or copy it directly to the lib directory on your feather. If you followed the CircuitPython quick start guide for your board, you will need to select the 8.x version of the bundle on the releases page as of 2023-12-31.

I based this code on Adafruit’s quick start guide for the ST7789 display. The guide did not have the correct pins for the feather and did not cover turning the backlight on after taking control of the display.

Note: If you want to flip the display to be portrait orientation, swap the values of width and height when creating the ST7789 object.