event handler sleep timer included, for less cpu usage

This commit is contained in:
Patrick Tschuchnig 2019-08-27 15:06:50 +02:00
parent a46cf22eb1
commit 43e0d0dc43

View File

@ -79,6 +79,8 @@ def handle_events():
else: else:
if event.type == pygame.QUIT or event.type == KEYDOWN: if event.type == pygame.QUIT or event.type == KEYDOWN:
exit_application() exit_application()
time.sleep(0.1)
return return
def exit_application(): def exit_application():
@ -90,11 +92,10 @@ def exit_application():
def shutdown_raspberry(): def shutdown_raspberry():
os.system("sudo shutdown -h now") os.system("sudo shutdown -h now")
return return
#signal handing for controlled exit via ctrl+c #signal handing for controlled exit via ctrl+c
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)
pygame.mouse.set_visible(False) # hide mouse pygame.mouse.set_visible(False) # hide mouse
screen = pygame.display.set_mode((screenSizeX, screenSizeY), pygame.FULLSCREEN) screen = pygame.display.set_mode((screenSizeX, screenSizeY), pygame.FULLSCREEN)