Skip to content

Commit bdbd778

Browse files
Melissa LeBlanc-WilliamsMelissa LeBlanc-Williams
authored andcommitted
Linting
1 parent f7eaaf0 commit bdbd778

1 file changed

Lines changed: 15 additions & 19 deletions

File tree

PyBadge_Conference_Badge/code.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
the PyBadge. Feel free to customize it to your heart's content.
44
"""
55

6-
import board
76
import time
7+
from math import sqrt, cos, sin, radians
8+
import board
89
from micropython import const
910
import displayio
1011
import digitalio
11-
from math import sqrt, cos, sin, radians
1212
import neopixel
1313
from gamepadshift import GamePadShift
1414
from adafruit_display_shapes.rect import Rect
@@ -130,22 +130,6 @@ def rotate(degrees):
130130
for x in range(0, NEOPIXEL_COUNT):
131131
pixels.append(x * 360 // NEOPIXEL_COUNT)
132132

133-
# Respond to the buttons
134-
def check_buttons(buttons):
135-
global direction, speed, brightness
136-
if (buttons & BUTTON_RIGHT) > 0:
137-
direction = -1
138-
elif (buttons & BUTTON_LEFT) > 0:
139-
direction = 1
140-
elif (buttons & BUTTON_UP) > 0 and speed < 10:
141-
speed += 1
142-
elif (buttons & BUTTON_DOWN) > 0 and speed > 1:
143-
speed -= 1
144-
elif (buttons & BUTTON_A) > 0 and brightness < 0.5:
145-
brightness += 0.025
146-
elif (buttons & BUTTON_B) > 0 and brightness > 0.025:
147-
brightness -= 0.025
148-
149133
# Main Loop
150134
current_buttons = pad.get_pressed()
151135
last_read = 0
@@ -165,5 +149,17 @@ def check_buttons(buttons):
165149
buttons = pad.get_pressed()
166150
last_read = time.monotonic()
167151
if current_buttons != buttons:
168-
check_buttons(buttons)
152+
# Respond to the buttons
153+
if (buttons & BUTTON_RIGHT) > 0:
154+
direction = -1
155+
elif (buttons & BUTTON_LEFT) > 0:
156+
direction = 1
157+
elif (buttons & BUTTON_UP) > 0 and speed < 10:
158+
speed += 1
159+
elif (buttons & BUTTON_DOWN) > 0 and speed > 1:
160+
speed -= 1
161+
elif (buttons & BUTTON_A) > 0 and brightness < 0.5:
162+
brightness += 0.025
163+
elif (buttons & BUTTON_B) > 0 and brightness > 0.025:
164+
brightness -= 0.025
169165
current_buttons = buttons

0 commit comments

Comments
 (0)