From 090a41549d0da4359f5ec9c53fd726a7794bf1f0 Mon Sep 17 00:00:00 2001 From: Frank DeMarco Date: Fri, 21 Sep 2018 13:09:23 -0400 Subject: [PATCH] disconnect --- NS.py | 16 ++++++++++++++++ resource/scores | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/NS.py b/NS.py index ca50f3c..3a21580 100644 --- a/NS.py +++ b/NS.py @@ -7,6 +7,7 @@ from glob import iglob from os.path import basename, join from threading import Thread from serial import Serial +from serial.tools import list_ports from pygame import Surface, Color from pygame.event import clear @@ -75,6 +76,12 @@ class NS(Game, Animation): self.serial_kill = False self.serial_data = 0 self.serial_reader = Serial(self.get_configuration("input", "arduino-port"), timeout=.1) + # for port in list_ports.comports(): + # print port.device + # print "---" + # ports = list_ports.grep(self.get_configuration("input", "arduino-port")) + # for port in ports: + # print port.device self.serial_thread = Thread(target=self.read_serial) self.serial_thread.start() self.last_press = get_ticks() @@ -94,6 +101,9 @@ class NS(Game, Animation): def read_serial(self): while not self.serial_kill: + name = self.get_configuration("input", "arduino-port") + if name not in (port.device for port in list_ports.comports()): + print "%s disconnected" % name output = self.serial_reader.readline().strip() if output: self.serial_data = int(output, 2) @@ -103,6 +113,7 @@ class NS(Game, Animation): def end(self, evt): if evt.type == QUIT or self.delegate.compare(evt, "quit"): + print "kill serial" self.serial_kill = True Game.end(self, evt) @@ -804,6 +815,10 @@ class Platform(GameChild): def __init__(self, parent): GameChild.__init__(self, parent) + dsr = self.get_display_surface().get_rect() + self.border = Sprite(self) + self.border.load_from_path(self.get_resource("DancePadClear.png"), True) + self.border.location.midbottom = dsr.centerx, dsr.bottom self.lights = [ Light(self, "cyan", NS.LNW), Light(self, "magenta", NS.LNE), @@ -931,6 +946,7 @@ class Platform(GameChild): if self.active: for light in self.lights: light.update() + # self.border.update() for light in self.lights: light.draw_glow() diff --git a/resource/scores b/resource/scores index d4c0f1d..2952f3a 100644 --- a/resource/scores +++ b/resource/scores @@ -15,3 +15,14 @@ 171204 256769 312561 +242763 +230604 +234298 +335281 +156682 +234931 +184682 +237113 +254185 +209634 +150791