Skip to content
Snippets Groups Projects
Commit 26c92b15 authored by Adimote's avatar Adimote
Browse files

fix linting errors

parent e803d28b
No related branches found
No related tags found
No related merge requests found
Pipeline #3509 failed
......@@ -16,13 +16,17 @@ COLOR_ORANGE=(255,125,0)
COLOR_WHITE = (255, 255, 255)
ACCELEROMETER = bhi160.BHI160Accelerometer()
class JoustSensor:
NUM_READINGS = 1
def __init__(self):
self.sensor = ACCELEROMETER
self.last_accels = []
self.jerk = 0.0
self.threshold = 1.8
def get_jerk(self):
readings = list()
while not readings:
......@@ -35,9 +39,11 @@ class JoustSensor:
jerk_z = sum([a.z for a in self.last_accels]) / JoustSensor.NUM_READINGS
self.jerk = (jerk_x ** 2 + jerk_y ** 2 + jerk_z ** 2) ** 0.5
return self.jerk
def too_fast(self):
return self.get_jerk() > self.threshold
def wait_button():
utime.sleep_ms(1000)
while True:
......@@ -56,45 +62,56 @@ def wait_button():
return "UL"
return "??"
def joining_game():
set_display("JOIN ?", COLOR_WHITE)
set_color(COLOR_WHITE)
def status_in_game():
set_display("IN GAME", COLOR_GREEN)
set_color(COLOR_GREEN)
def status_out_game():
set_display("DROPPED", COLOR_RED)
set_color(COLOR_RED)
def set_display(text, colr):
with display.open() as disp:
disp.clear()
disp.print(text, fg = colr, bg = (0, 0, 0), posx = 30, posy = 30)
disp.update()
def set_color(colr):
for i in range(15):
leds.prep(i, colr)
leds.update()
def countdown(n):
colr = COLOR_WHITE
for i in range(n, 0, -1):
if i == 3: colr = COLOR_RED
elif i == 2: colr = COLOR_ORANGE
elif i == 1: colr = COLOR_GREEN
if i == 3:
colr = COLOR_RED
elif i == 2:
colr = COLOR_ORANGE
elif i == 1:
colr = COLOR_GREEN
set_display("START: %d" % i, colr)
leds.clear()
vibra.vibrate(300)
utime.sleep_ms(1000)
vibra.vibrate(1000)
def change_status(status):
status()
vibra.vibrate(1000)
def run():
print("Starting ...")
acc = JoustSensor()
......@@ -113,4 +130,5 @@ def run():
elif current_status == status_out_game:
wait_button()
run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment