Skip to content

Commit 0e45e17

Browse files
authored
Merge pull request #2671 from adafruit/tft_featherwing_35
adding circuitpython example for the tft featherwing 3.5 inch v2
2 parents 98f0a2b + 4078fee commit 0e45e17

8 files changed

Lines changed: 75 additions & 5 deletions

File tree

Matrix_Portal_S3_SMS_Scroller/code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
# avoids repeating the same quote twice in a row
1010

1111
import time
12-
import board
1312
import random
1413
from collections import deque
14+
import board
1515
from adafruit_matrixportal.matrix import Matrix
1616
from adafruit_matrixportal.network import Network
1717
from messageboard import MessageBoard
@@ -76,8 +76,8 @@ def update_data():
7676

7777
# Results are returned in reverse order, so we reverse that and add to end of queue
7878
messages.reverse()
79-
for message in messages:
80-
message_queue.append(message)
79+
for m in messages:
80+
message_queue.append(m)
8181

8282
# Remove any messages that have been grabbed except the latest one if setting enabled
8383
start_index = 1 if KEEP_LATEST_MESSAGE else 0

Matrix_Portal_S3_SMS_Scroller/lib/messageboard/animations/scroll.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,15 @@ def out_to_bottom(self, message, duration=1):
171171
)
172172

173173
def right_to_left(self, message, duration=1):
174-
"""Scroll a message in from the right side of the display and then out the left side over a certain period of
175-
time. The final position is off-screen to the left.
174+
"""Scroll a message in from the right side of the display and then out the left side
175+
over a certain period of time. The final position is off-screen to the left.
176176
177177
:param message: The message to animate.
178178
:param float duration: (optional) The period of time to perform the animation
179179
over in seconds. (default=1)
180180
:type message: Message
181181
"""
182+
# pylint: disable=unused-variable
182183
center_x, center_y = self._get_centered_position(message)
183184
self.scroll_from_to(
184185
message, duration,
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# SPDX-FileCopyrightText: 2023 Liz Clark for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
"""
5+
This test will initialize the display using displayio and display
6+
a bitmap image. The image advances when the touch screen is touched.
7+
8+
Pinouts are for the 3.5" TFT FeatherWing V2
9+
"""
10+
import os
11+
import board
12+
import displayio
13+
import adafruit_hx8357
14+
import adafruit_tsc2007
15+
16+
# Release any resources currently in use for the displays
17+
displayio.release_displays()
18+
19+
# Use Hardware SPI
20+
spi = board.SPI()
21+
22+
tft_cs = board.D9
23+
tft_dc = board.D10
24+
25+
display_width = 480
26+
display_height = 320
27+
28+
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
29+
display = adafruit_hx8357.HX8357(display_bus, width=display_width, height=display_height)
30+
31+
i2c = board.STEMMA_I2C()
32+
33+
irq_dio = None
34+
tsc = adafruit_tsc2007.TSC2007(i2c, irq=irq_dio)
35+
36+
groups = []
37+
images = []
38+
for filename in os.listdir('/'):
39+
if filename.lower().endswith('.bmp') and not filename.startswith('.'):
40+
images.append("/"+filename)
41+
print(images)
42+
43+
for i in range(len(images)):
44+
splash = displayio.Group()
45+
bitmap = displayio.OnDiskBitmap(images[i])
46+
tile_grid = displayio.TileGrid(bitmap, pixel_shader=bitmap.pixel_shader)
47+
splash.append(tile_grid)
48+
groups.append(splash)
49+
50+
index = 0
51+
touch_state = False
52+
53+
display.root_group = groups[index]
54+
55+
while True:
56+
if tsc.touched and not touch_state:
57+
point = tsc.touch
58+
print("Touchpoint: (%d, %d, %d)" % (point["x"], point["y"], point["pressure"]))
59+
# left side of the screen
60+
if point["y"] < 2000:
61+
index = (index - 1) % len(images)
62+
display.root_group = groups[index]
63+
# right side of the screen
64+
else:
65+
index = (index + 1) % len(images)
66+
display.root_group = groups[index]
67+
touch_state = True
68+
if not tsc.touched and touch_state:
69+
touch_state = False
150 KB
Binary file not shown.
150 KB
Binary file not shown.
150 KB
Binary file not shown.
150 KB
Binary file not shown.
150 KB
Binary file not shown.

0 commit comments

Comments
 (0)