def quit(screensaver=True): head.aim(1430, 1200) head.laser(False) if screensaver: oled.clear_buffer() oled.write("Booted.") oled.refresh() time.sleep(0.2) else: oled.clear() time.sleep(0.2) duino.disable()
def halt(): duino.enable() time.sleep(0.1) tries = 0 while not duino.online() and tries < 5: print "Resetting..." duino.reset() time.sleep(2) tries += 1 duino.shutdown() terminal.info("Shutting down Lobsang...") log.log("Halting Lobsang. Raspbian is shutting down.") log.new_log() # If Lobsang halted through this code (it generally does) then create a new logfile. oled.clear_buffer() oled.write("Shutting down Lobsang...", pos=(0,0)) oled.write("Wait until Duino light goes out before switching off.", pos=(0, 24)) oled.refresh() os.system("sudo halt")
print "Auto Run: No GPIO access." sys.exit() if boot_errors >= 4: # > 4 == 'camera offline'. boot_errors -= 4 # Remove 'camera offline' code. camera_online = False if boot_errors >= 2: # > 2 == 'oled_offline'. boot_errors -= 2 # Remove 'oled offline' code. oled_online = False if boot_errors >= 1: # >= 1 == 'duino offline' code. boot_errors -= 1 # Now $boot_errors should == 0 duino_online = False if boot_errors != 0: # This should never happen! print "Auto Run: Error checking for boot errors. Wrong error code returned from boot.py? Error code == %i" %boot_errors if duino_online: if oled_online: Oled.clear_buffer() Oled.write("Auto Run: %i/4 systems online." %(camera_online + oled_online + duino_online + 1)) # Display the number of systems online (+ 1 because Pi is online) Oled.refresh() Oled.command(Oled.on) print "Auto Run: Success! System is stable." os.system("sudo python piwars_menu.py") else: # Duino is offline. print "Auto Runx: Cannot boot Lobsang!" if oled_online: Oled.write("Auto Run: Cannot boot Lobsang!") Oled.refresh() # Runs after piwars_menu.py exits or on 'system not stable' error. print "Auto Run: Please login with passkey or USB stick." if oled_online: