Debug the exit problem with Serial on Rpi

master
JeanotP1314 2017-01-11 14:11:48 -08:00
parent b2a4be3baf
commit 32629a2a3a
2 changed files with 11 additions and 28 deletions

View File

@ -384,30 +384,18 @@ def camera_update():
CAMERA.relocate(rot, -tilt, point=[xm, map1.height(xm, zm)+5, zm], distance=camRad) CAMERA.relocate(rot, -tilt, point=[xm, map1.height(xm, zm)+5, zm], distance=camRad)
draw() 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 # Main loop
while DISPLAY.loop_running() and keep_running: while DISPLAY.loop_running() and keep_running:
handler.mykeys.do_input_events() handler.mykeys.do_input_events()
keep_running = handler.read_exit()
if not keep_running:
DISPLAY.destroy()
DISPLAY.stop()
update_position() update_position()
update_avatar() update_avatar()
camera_update() camera_update()
handler.update() handler.update()
#engine.stats() #engine.stats()
keep_running = handler.read_exit()
DISPLAY.destroy()
DISPLAY.stop()

View File

@ -235,18 +235,6 @@ class handlers:
if self.mykeys.key_state("KEY_P"): #112: #key p picture if self.mykeys.key_state("KEY_P"): #112: #key p picture
pi3d.screenshot("BeYourHero" + str(scshots) + ".jpg") pi3d.screenshot("BeYourHero" + str(scshots) + ".jpg")
scshots += 1 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: if orientation == 1:
self.body_orientation = 0 self.body_orientation = 0
@ -266,6 +254,13 @@ class handlers:
self.body_orientation = 315 self.body_orientation = 315
def read_exit(self): 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 return self.keep_running