auto reset
This commit is contained in:
parent
51bc4e97ab
commit
8d31f80ba0
23
NS.py
23
NS.py
|
@ -43,6 +43,7 @@ class NS(Game, Animation):
|
||||||
FRONT = 300
|
FRONT = 300
|
||||||
STEP = .4
|
STEP = .4
|
||||||
IDLE_TIMEOUT = 60000 * 5
|
IDLE_TIMEOUT = 60000 * 5
|
||||||
|
NO_RESET_TIMEOUT = 3000
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Game.__init__(self)
|
Game.__init__(self)
|
||||||
|
@ -116,7 +117,7 @@ class NS(Game, Animation):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.handle_garbage(transmission)
|
self.handle_garbage(transmission)
|
||||||
self.reset_arduino()
|
self.reset_arduino()
|
||||||
self.idle_elapsed = 0
|
self.idle_elapsed = 0
|
||||||
elif len(transmission) > 0:
|
elif len(transmission) > 0:
|
||||||
try:
|
try:
|
||||||
int(transmission, 2)
|
int(transmission, 2)
|
||||||
|
@ -131,9 +132,10 @@ class NS(Game, Animation):
|
||||||
self.serial_reader.reset_input_buffer()
|
self.serial_reader.reset_input_buffer()
|
||||||
|
|
||||||
def reset_arduino(self):
|
def reset_arduino(self):
|
||||||
self.serial_reader.dtr = False
|
if self.serial_enabled():
|
||||||
self.serial_reader.reset_input_buffer()
|
self.serial_reader.dtr = False
|
||||||
self.serial_reader.dtr = True
|
self.serial_reader.reset_input_buffer()
|
||||||
|
self.serial_reader.dtr = True
|
||||||
|
|
||||||
def end(self, evt):
|
def end(self, evt):
|
||||||
if evt.type == QUIT or self.delegate.compare(evt, "quit"):
|
if evt.type == QUIT or self.delegate.compare(evt, "quit"):
|
||||||
|
@ -157,6 +159,7 @@ class NS(Game, Animation):
|
||||||
self.chemtrails.reset()
|
self.chemtrails.reset()
|
||||||
self.platform.reset()
|
self.platform.reset()
|
||||||
self.dialogue.reset()
|
self.dialogue.reset()
|
||||||
|
self.no_reset_elapsed = 0
|
||||||
|
|
||||||
def set_most_recent_time(self, score):
|
def set_most_recent_time(self, score):
|
||||||
self.most_recent_time = score
|
self.most_recent_time = score
|
||||||
|
@ -196,8 +199,16 @@ class NS(Game, Animation):
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
Animation.update(self)
|
Animation.update(self)
|
||||||
if self.serial_enabled():
|
last_frame_duration = self.time_filter.get_last_frame_duration()
|
||||||
self.apply_serial()
|
if self.serial_enabled() or True:
|
||||||
|
# self.apply_serial()
|
||||||
|
if self.title.active or self.introduction.active or self.ending.active or \
|
||||||
|
self.dialogue.active:
|
||||||
|
self.no_reset_elapsed += last_frame_duration
|
||||||
|
if self.no_reset_elapsed >= self.NO_RESET_TIMEOUT:
|
||||||
|
print "auto arduino reset triggered"
|
||||||
|
self.reset_arduino()
|
||||||
|
self.no_reset_elapsed = 0
|
||||||
self.title.update()
|
self.title.update()
|
||||||
self.introduction.update()
|
self.introduction.update()
|
||||||
self.ending.update()
|
self.ending.update()
|
||||||
|
|
|
@ -32,8 +32,8 @@ def move_to_executable():
|
||||||
if is_python_3():
|
if is_python_3():
|
||||||
launch_alternative(["python2", "python2.7", "python2.6"])
|
launch_alternative(["python2", "python2.7", "python2.6"])
|
||||||
|
|
||||||
if maxint >> 33:
|
# if maxint >> 33:
|
||||||
launch_alternative(["python-32", "python2-32", "python2.7-32", "python2.6-32"])
|
# launch_alternative(["python-32", "python2-32", "python2.7-32", "python2.6-32"])
|
||||||
|
|
||||||
if not can_import("pygame"):
|
if not can_import("pygame"):
|
||||||
launch_alternative(["python2.7", "python2.6"])
|
launch_alternative(["python2.7", "python2.6"])
|
||||||
|
|
2
lib/pgfw
2
lib/pgfw
|
@ -1 +1 @@
|
||||||
Subproject commit 41b4df6326afbad64aa5dc00ac5d3dc854e8096f
|
Subproject commit 91fcfbc6bfca6da2a9243c179850b5c4ff4e5ad8
|
Loading…
Reference in New Issue