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