Skip to content

Commit 4090101

Browse files
kattnitannewt
authored andcommitted
Touch implemented
Created images for each touchpad. Added touchio to conf.py
1 parent a890f5e commit 4090101

9 files changed

+137
-1
lines changed

_static/capacitive_touch_pad_A1.jpg

698 KB
Loading

_static/capacitive_touch_pad_A2.jpg

698 KB
Loading

_static/capacitive_touch_pad_A3.jpg

698 KB
Loading

_static/capacitive_touch_pad_A4.jpg

698 KB
Loading

_static/capacitive_touch_pad_A5.jpg

697 KB
Loading

_static/capacitive_touch_pad_A6.jpg

698 KB
Loading

_static/capacitive_touch_pad_A7.jpg

698 KB
Loading

adafruit_circuitplayground/express.py

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import math
88
import neopixel
99
import time
10+
import touchio
1011

1112

1213
class Photocell:
@@ -50,6 +51,141 @@ def __init__(self):
5051
self.sample = None
5152
self.sine_wave = None
5253

54+
# Define touch:
55+
self._touch_A1 = None
56+
self._touch_A2 = None
57+
self._touch_A3 = None
58+
self._touch_A4 = None
59+
self._touch_A5 = None
60+
self._touch_A6 = None
61+
self._touch_A7 = None
62+
63+
@property
64+
def touch_A1(self):
65+
"""Detect touch on capacitive touch pad A1.
66+
67+
.. image :: /_static/capacitive_touch_pad_A1.jpg
68+
69+
.. code-block:: python
70+
71+
from adafruit_circuitplayground.express import cpx
72+
73+
while True:
74+
if cpx.touch_A1:
75+
print('Touched pad A1')
76+
"""
77+
if self._touch_A1 is None:
78+
self._touch_A1 = touchio.TouchIn(board.A1)
79+
return self._touch_A1.value
80+
81+
@property
82+
def touch_A2(self):
83+
"""Detect touch on capacitive touch pad A2.
84+
85+
.. image :: /_static/capacitive_touch_pad_A2.jpg
86+
87+
.. code-block:: python
88+
89+
from adafruit_circuitplayground.express import cpx
90+
91+
while True:
92+
if cpx.touch_A2:
93+
print('Touched pad A2')
94+
"""
95+
if self._touch_A2 is None:
96+
self._touch_A2 = touchio.TouchIn(board.A2)
97+
return self._touch_A2.value
98+
99+
@property
100+
def touch_A3(self):
101+
"""Detect touch on capacitive touch pad A3.
102+
103+
.. image :: /_static/capacitive_touch_pad_A3.jpg
104+
105+
.. code-block:: python
106+
107+
from adafruit_circuitplayground.express import cpx
108+
109+
while True:
110+
if cpx.touch_A3:
111+
print('Touched pad A3')
112+
"""
113+
if self._touch_A3 is None:
114+
self._touch_A3 = touchio.TouchIn(board.A3)
115+
return self._touch_A3.value
116+
117+
@property
118+
def touch_A4(self):
119+
"""Detect touch on capacitive touch pad A4.
120+
121+
.. image :: /_static/capacitive_touch_pad_A4.jpg
122+
123+
.. code-block:: python
124+
125+
from adafruit_circuitplayground.express import cpx
126+
127+
while True:
128+
if cpx.touch_A4:
129+
print('Touched pad A4')
130+
"""
131+
if self._touch_A4 is None:
132+
self._touch_A4 = touchio.TouchIn(board.A4)
133+
return self._touch_A4.value
134+
135+
@property
136+
def touch_A5(self):
137+
"""Detect touch on capacitive touch pad A5.
138+
139+
.. image :: /_static/capacitive_touch_pad_A5.jpg
140+
141+
.. code-block:: python
142+
143+
from adafruit_circuitplayground.express import cpx
144+
145+
while True:
146+
if cpx.touch_A5:
147+
print('Touched pad A5')
148+
"""
149+
if self._touch_A5 is None:
150+
self._touch_A5 = touchio.TouchIn(board.A5)
151+
return self._touch_A5.value
152+
153+
@property
154+
def touch_A6(self):
155+
"""Detect touch on capacitive touch pad A6.
156+
157+
.. image :: /_static/capacitive_touch_pad_A6.jpg
158+
159+
.. code-block:: python
160+
161+
from adafruit_circuitplayground.express import cpx
162+
163+
while True:
164+
if cpx.touch_A6:
165+
print('Touched pad A6')
166+
"""
167+
if self._touch_A6 is None:
168+
self._touch_A6 = touchio.TouchIn(board.A6)
169+
return self._touch_A6.value
170+
171+
@property
172+
def touch_A7(self):
173+
"""Detect touch on capacitive touch pad A7.
174+
175+
.. image :: /_static/capacitive_touch_pad_A7.jpg
176+
177+
.. code-block:: python
178+
179+
from adafruit_circuitplayground.express import cpx
180+
181+
while True:
182+
if cpx.touch_A7:
183+
print('Touched pad A7')
184+
"""
185+
if self._touch_A7 is None:
186+
self._touch_A7 = touchio.TouchIn(board.A7)
187+
return self._touch_A7.value
188+
53189
@property
54190
def pixels(self):
55191
"""Sequence like object representing the ten NeoPixels around the outside

conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
'NeoPixel': ('https://circuitpython.readthedocs.io/projects/neopixel/en/latest/', None)}
2121

2222
# Libraries we depend on but don't need for generating docs.
23-
autodoc_mock_imports = ["board", "analogio", "digitalio", "neopixel", "adafruit_thermistor", "audioio"]
23+
autodoc_mock_imports = ["board", "analogio", "digitalio", "neopixel", "adafruit_thermistor", "audioio", "touchio"]
2424

2525
# Add any paths that contain templates here, relative to this directory.
2626
templates_path = ['_templates']

0 commit comments

Comments
 (0)