4
4
"""
5
5
PyPortal implementation of Busy Simulator notification sound looper.
6
6
"""
7
+ import time
7
8
import board
8
9
import displayio
9
10
import adafruit_touchscreen
10
11
from adafruit_displayio_layout .layouts .grid_layout import GridLayout
11
12
from adafruit_displayio_layout .widgets .icon_widget import IconWidget
12
- import time
13
13
from audiocore import WaveFile
14
14
from audioio import AudioOut
15
- from vectorio import Circle
16
15
17
16
# How many seconds to wait between playing samples
18
17
# Lower time means it will play faster
@@ -128,16 +127,17 @@ def check_for_touch(_now):
128
127
129
128
:param int _now: The current time in seconds. Used for cool down enforcement
130
129
"""
130
+ # pylint: disable=global-statement, too-many-nested-blocks, consider-using-enumerate
131
131
global CUR_LOOP_INDEX
132
132
global LOOP
133
133
global LAST_PRESS_TIME
134
134
global WAS_TOUCHED
135
135
136
136
# read the touch data
137
- p = ts .touch_point
137
+ touch_point = ts .touch_point
138
138
139
139
# if anything is touched
140
- if p :
140
+ if touch_point :
141
141
# if the touch just began. We ignore further events until
142
142
# after the touch has been lifted
143
143
if not WAS_TOUCHED :
@@ -152,16 +152,16 @@ def check_for_touch(_now):
152
152
LAST_PRESS_TIME = time .monotonic ()
153
153
154
154
# loop over the icons
155
- for i in range (len (_icons )):
155
+ for _ in range (len (_icons )):
156
156
# lookup current icon in the grid layout
157
- icon = layout .get_cell ((i % 4 , i // 4 ))
157
+ cur_icon = layout .get_cell ((_ % 4 , _ // 4 ))
158
158
159
159
# check if it's being touched
160
- if icon .contains (p ):
161
- print ("icon {} touched" .format (i ))
160
+ if cur_icon .contains (touch_point ):
161
+ print ("icon {} touched" .format (_ ))
162
162
163
163
# if it's the stop icon
164
- if _icons [i ][0 ] == "Stop" :
164
+ if _icons [_ ][0 ] == "Stop" :
165
165
166
166
# empty out the loop
167
167
LOOP = []
@@ -171,7 +171,7 @@ def check_for_touch(_now):
171
171
172
172
else : # any other icon
173
173
# insert the touched icons sample index into the loop
174
- LOOP .insert (CUR_LOOP_INDEX , i )
174
+ LOOP .insert (CUR_LOOP_INDEX , _ )
175
175
176
176
# print(LOOP)
177
177
0 commit comments