Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nbuchwitz
Created January 3, 2022 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbuchwitz/0d4f461a68790e01b11de67030cca09b to your computer and use it in GitHub Desktop.
Save nbuchwitz/0d4f461a68790e01b11de67030cca09b to your computer and use it in GitHub Desktop.
import os
import revpimodio2
class Application():
def __init__(self):
self.rpi = revpimodio2.RevPiModIO(autorefresh=True)
self.rpi.handlesignalend(self.cleanup_revpi)
self.rpi.core.x2in.reg_event(self.event_shutdown, edge=revpimodio2.RISING)
def __shutdown(self):
self.rpi.exit()
os.system("sudo shutdown -h now")
def cleanup_revpi(self):
self.rpi.core.a1green.value = False
def event_shutdown(self, ioname, iovalue):
self.__shutdown()
def start(self):
self.rpi.mainloop(blocking=False)
while not self.rpi.exitsignal.wait(0.5):
self.rpi.core.a1green.value = not self.rpi.core.a1green.value
if __name__ == "__main__":
app = Application()
app.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment