forked from seanbechhofer/raspberrypi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpiboot.py
More file actions
executable file
·63 lines (60 loc) · 1.95 KB
/
piboot.py
File metadata and controls
executable file
·63 lines (60 loc) · 1.95 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
"""
Code that allows selection of varios functions on boot.
SWITCH1 = Radio
SWITCH2 = Trains
"""
import humble
import piplayer
import jukebox
import trains
import time
import os
BIGBUTTON = 2
def main():
humble.init()
hdt = humble.HumbleDisplayThread(humble.data)
hdt.start()
humble.data.setLine(0,"Select Function")
humble.data.setLine(1,"1:Music;2:Trains")
while (True):
if humble.switch(0):
time.sleep(0.2)
carryOn = True
while (carryOn):
humble.data.setLine(0,"Select Function")
humble.data.setLine(1,"1:Radio;2:Jukebox")
time.sleep(0.2)
if humble.switch(0):
piplayer.doStuff()
humble.data.setLine(0,"Select Function")
humble.data.setLine(1,"1:Music;2:Trains")
if humble.switch(1):
jukebox.doStuff()
humble.data.setLine(0,"Select Function")
humble.data.setLine(1,"1:Radio;2:Jukebox")
if humble.switch(2):
carryOn = False
time.sleep(0.2)
time.sleep(0.2)
humble.data.setLine(0,"Select Function")
humble.data.setLine(1,"1:Music;2:Trains")
time.sleep(0.2)
if humble.switch(1):
time.sleep(0.1)
trains.doStuff()
humble.data.setLine(0,"Select Function")
humble.data.setLine(1,"1:Music;2:Trains")
time.sleep(0.2)
if humble.switch(2):
time.sleep(BIGBUTTON)
if (humble.switch(2)):
humble.data.setLine(1, "")
humble.scroll(0, "Shutting Down...")
humble.data.setLine(0, "Shutting Down...")
humble.data.setLine(0, "")
os.system("sudo halt")
time.sleep(0.1)
hdt.done()
if __name__ == '__main__':
main()