Using the 2.4" TFT FeatherWing V2 with CircuitPython involves plugging a Feather board into the FeatherWing. Then, you load the code and necessary libraries onto your Feather board to run the example.
This page uses the Feather RP2040 for demonstrating CircuitPython usage. You can use the same concepts to get going with any classic Feather board.
Plug your Feather into the FeatherWing. The bottom of the Feather will be above the FeatherWing STEMMA QT port.
CircuitPython Usage
To use with CircuitPython, you need to first install the necessary libraries, and their dependencies, into the lib folder on your CIRCUITPY drive. Then you need to update code.py with the example script.
Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file.
Connect the microcontroller to your computer via a known-good USB power+data cable. The board shows up as a thumb drive named CIRCUITPY. Copy the entire lib folder, the bitmap image files, and the code.py file to your CIRCUITPY drive.
Your CIRCUITPY/lib folder should contain the following folder and files:
- /adafruit_bus_device
- adafruit_ili9341.mpy
- adafruit_tsc2007.mpy
Once you have copied over the necessary folders and files, your CIRCUITPY drive should resemble the following:
# SPDX-FileCopyrightText: 2023 Liz Clark for Adafruit Industries # SPDX-License-Identifier: MIT """ This test will initialize the display using displayio and display a bitmap image. The image advances when the touch screen is touched. Pinouts are for the 2.4" TFT FeatherWing V2 """ import os import board import displayio import adafruit_ili9341 import adafruit_tsc2007 # Release any resources currently in use for the displays displayio.release_displays() # Use Hardware SPI spi = board.SPI() tft_cs = board.D9 tft_dc = board.D10 display_width = 320 display_height = 240 display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs) display = adafruit_ili9341.ILI9341(display_bus, width=display_width, height=display_height) i2c = board.STEMMA_I2C() irq_dio = None tsc = adafruit_tsc2007.TSC2007(i2c, irq=irq_dio) groups = [] images = [] for filename in os.listdir('/'): if filename.lower().endswith('.bmp') and not filename.startswith('.'): images.append("/"+filename) print(images) for i in range(len(images)): splash = displayio.Group() bitmap = displayio.OnDiskBitmap(images[i]) tile_grid = displayio.TileGrid(bitmap, pixel_shader=bitmap.pixel_shader) splash.append(tile_grid) groups.append(splash) index = 0 touch_state = False display.root_group = groups[index] while True: if tsc.touched and not touch_state: point = tsc.touch print("Touchpoint: (%d, %d, %d)" % (point["x"], point["y"], point["pressure"])) # left side of the screen if point["y"] < 2000: index = (index - 1) % len(images) display.root_group = groups[index] # right side of the screen else: index = (index + 1) % len(images) display.root_group = groups[index] touch_state = True if not tsc.touched and touch_state: touch_state = False
Once everything is saved to the CIRCUITPY drive, connect to the serial console to see the data printed out!
The code will open all of the bitmap files that are on the CIRCUITPY drive and add them to the images
array. The first image will then be displayed on the TFT. In the loop, if you touch the screen you'll see the coordinates and pressure print to the serial console.
If you press on the left side of the screen, the display will show the previous bitmap in the array. If you press on the right side of the screen, the display will show the next bitmap in the array.
Text editor powered by tinymce.