44"""
55PyPortal implementation of Busy Simulator notification sound looper.
66"""
7+ import time
78import board
89import displayio
910import adafruit_touchscreen
1011from adafruit_displayio_layout .layouts .grid_layout import GridLayout
1112from adafruit_displayio_layout .widgets .icon_widget import IconWidget
12- import time
1313from audiocore import WaveFile
1414from audioio import AudioOut
15- from vectorio import Circle
1615
1716# How many seconds to wait between playing samples
1817# Lower time means it will play faster
@@ -128,16 +127,17 @@ def check_for_touch(_now):
128127
129128 :param int _now: The current time in seconds. Used for cool down enforcement
130129 """
130+ # pylint: disable=global-statement, too-many-nested-blocks, consider-using-enumerate
131131 global CUR_LOOP_INDEX
132132 global LOOP
133133 global LAST_PRESS_TIME
134134 global WAS_TOUCHED
135135
136136 # read the touch data
137- p = ts .touch_point
137+ touch_point = ts .touch_point
138138
139139 # if anything is touched
140- if p :
140+ if touch_point :
141141 # if the touch just began. We ignore further events until
142142 # after the touch has been lifted
143143 if not WAS_TOUCHED :
@@ -152,16 +152,16 @@ def check_for_touch(_now):
152152 LAST_PRESS_TIME = time .monotonic ()
153153
154154 # loop over the icons
155- for i in range (len (_icons )):
155+ for _ in range (len (_icons )):
156156 # lookup current icon in the grid layout
157- icon = layout .get_cell ((i % 4 , i // 4 ))
157+ cur_icon = layout .get_cell ((_ % 4 , _ // 4 ))
158158
159159 # 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 (_ ))
162162
163163 # if it's the stop icon
164- if _icons [i ][0 ] == "Stop" :
164+ if _icons [_ ][0 ] == "Stop" :
165165
166166 # empty out the loop
167167 LOOP = []
@@ -171,7 +171,7 @@ def check_for_touch(_now):
171171
172172 else : # any other icon
173173 # insert the touched icons sample index into the loop
174- LOOP .insert (CUR_LOOP_INDEX , i )
174+ LOOP .insert (CUR_LOOP_INDEX , _ )
175175
176176 # print(LOOP)
177177
0 commit comments