You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not reliably 100% of the time, but reliable enough if you hold your finger down.
I've got a Feather RP2040 (USB Host but any would do) connected to the 3.5" capacitive touch featherwing with an SD card in place. No USB device in the USB A port.
This code loads bmp files from SD and local flash. I've nicked a load of assets from learn repo for testing.
Tapping should change image, but it skips one or so randomly.
Hold your finger down instead of tapping and watch the serial, sometimes (often) it has both finger #0 and finger #1 (i've seen 0-2) but usually at very different coordinates. I've taken off the protective film and it's still happening, it's clean/new so hopefully easily reproduced. Running v9-rc0
code:
# 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 3.5" TFT FeatherWing V2 ## Now adapted for capacitive version instead
"""
import os
import board
import displayio
import adafruit_hx8357
import adafruit_ft5336
import storage
import adafruit_sdcard
import digitalio
# import adafruit_tsc2007
# Release any resources currently in use for the displays
displayio.release_displays()
# Use Hardware SPI
spi = board.SPI()
sd_cs = board.D5
tft_cs = board.D9
tft_dc = board.D10
display_width = 480
display_height = 320
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs )#, baudrate=60_000_000)
display = adafruit_hx8357.HX8357(display_bus, width=display_width, height=display_height)
i2c = board.STEMMA_I2C()
irq_dio = None
# tsc = adafruit_tsc2007.TSC2007(i2c, irq=irq_dio)
touch = adafruit_ft5336.Adafruit_FT5336(i2c)
groups = []
images = []
def list_files(path='/'):
for filename in os.listdir(path):
if filename.lower().endswith('.bmp') and not filename.startswith('.'):
images.append((path if path.endswith('/') else path+"/" )+filename)
def os_Exists(path):
try:
return os.stat(path) != None;
except:
return False
#attempt to mount sd card
# try:
def mountsd():
print("Attempting to mount SD card")
sdcs = digitalio.DigitalInOut(sd_cs)
sd = adafruit_sdcard.SDCard(spi, sdcs)
vfs = storage.VfsFat(sd)
storage.mount(vfs, "/sd")
# except:
# print("SD Card not found")
mountsd()
if os_Exists('/sd'):
print("SD Directory exists")
list_files('/sd')
# mount usb
list_files('/')
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]
print("displaying image %s" % images[index])
point={"x":0,"y":0,"finger":0}
while True:
if touch.touched and not touch_state:
try:
for i,tpoint in enumerate(touch.points):
print(tpoint)
point["x"] = tpoint[0]
point["y"] = tpoint[1]
point["finger"] = tpoint[2]
print("Touchpoint #%d: (%d, %d, %d)" % (i, point["x"], point["y"], point["finger"]))
# 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]
print("displaying image %s" % images[index])
except RuntimeError:
pass
touch_state = True
if not touch.touched and touch_state:
touch_state = False
The text was updated successfully, but these errors were encountered:
Not reliably 100% of the time, but reliable enough if you hold your finger down.
I've got a Feather RP2040 (USB Host but any would do) connected to the 3.5" capacitive touch featherwing with an SD card in place. No USB device in the USB A port.
This code loads bmp files from SD and local flash. I've nicked a load of assets from learn repo for testing.
Tapping should change image, but it skips one or so randomly.
Hold your finger down instead of tapping and watch the serial, sometimes (often) it has both finger #0 and finger #1 (i've seen 0-2) but usually at very different coordinates. I've taken off the protective film and it's still happening, it's clean/new so hopefully easily reproduced. Running v9-rc0
code:
The text was updated successfully, but these errors were encountered: