-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpi.py
More file actions
36 lines (28 loc) · 708 Bytes
/
pi.py
File metadata and controls
36 lines (28 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import time,os
import signal
import gadget
from RPi import GPIO
import Adafruit_SSD1306
from libs.menu import OledMenuController
from menus import getMenus
def killhandle(signum, frame):
GPIO.cleanup()
exit(0)
def shutdown():
os.system('sudo shutdown -h now')
killhandle(0,0);
gadget.initPi()
load = getMenus(shutdown)
disp = Adafruit_SSD1306.SSD1306_128_64(rst=24)
controller = OledMenuController(load,disp,17,22,5,6)
load.setCtl(controller)
if __name__ == "__main__":
disp.begin()
disp.clear()
disp.display()
signal.signal(signal.SIGTERM, killhandle)
try:
while True:
controller.loop()
except (KeyboardInterrupt, SystemExit):
killhandle(1,0)