From 32629a2a3a303da580069f315df6210a0a90e68e Mon Sep 17 00:00:00 2001 From: JeanotP1314 Date: Wed, 11 Jan 2017 14:11:48 -0800 Subject: [PATCH] Debug the exit problem with Serial on Rpi --- src/RUN.py | 20 ++++---------------- src/inputs.py | 19 +++++++------------ 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/RUN.py b/src/RUN.py index 3f57944..32eeb52 100755 --- a/src/RUN.py +++ b/src/RUN.py @@ -384,30 +384,18 @@ def camera_update(): CAMERA.relocate(rot, -tilt, point=[xm, map1.height(xm, zm)+5, zm], distance=camRad) draw() - #if rot: - #print(rot, body_orientation, body_orientation_diff) - #CAMERA.relocate(rot, tilt, point=[-5, 84.5, -0], distance=camRad) - #tt, rrot = CAMERA.point_at() - #tt, rrot, rr = CAMERA.get_direction() - #print(tt, body_orientation) - #rot = 0 - #body_orientation_diff = body_orientation - #CAMERA.rotateZ(roll) - - # Main loop while DISPLAY.loop_running() and keep_running: handler.mykeys.do_input_events() - keep_running = handler.read_exit() - if not keep_running: - DISPLAY.destroy() - DISPLAY.stop() update_position() update_avatar() camera_update() handler.update() #engine.stats() - + keep_running = handler.read_exit() + +DISPLAY.destroy() +DISPLAY.stop() diff --git a/src/inputs.py b/src/inputs.py index 2dbeda9..578129e 100755 --- a/src/inputs.py +++ b/src/inputs.py @@ -235,18 +235,6 @@ class handlers: if self.mykeys.key_state("KEY_P"): #112: #key p picture pi3d.screenshot("BeYourHero" + str(scshots) + ".jpg") scshots += 1 - if self.mykeys.key_state("KEY_ESC"): #Escape key to exit - print("***** EXIT *****") - #os.system('xset r on') - - self.keep_running = False - - #self.mykeys.release() - if self.USE_SERIAL: - self.ser.stop() - #mymouse.stop() - #DISPLAY.destroy() - #DISPLAY.stop() if orientation == 1: self.body_orientation = 0 @@ -266,6 +254,13 @@ class handlers: self.body_orientation = 315 def read_exit(self): + if self.mykeys.key_state("KEY_ESC"): #Escape key to exit + print("***** EXIT *****") + self.keep_running = False + self.mykeys.release() + if self.USE_SERIAL: + self.ser.stop() + return self.keep_running