-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmenutest.py
37 lines (34 loc) · 1.28 KB
/
menutest.py
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
import sys
from time import sleep
from Oled.Menu import Menu, MenuAction, MenuParent
from Oled.Rotary import Rotary
m = Menu([
MenuAction("First line", lambda: print("First line")),
MenuAction("A second menu option", lambda: print("Second line")),
MenuParent("Now to the third", [
MenuAction("First sub-option", lambda: print("First sub-option")),
MenuAction("Second sub-option", lambda: print("Second sub-option")),
MenuParent("Third sub-option", [
MenuAction("First sub-sub-option", lambda: print("First sub-sub-option")),
MenuAction("Second sub-sub-option", lambda: print("Second sub-sub-option")),
]),
MenuAction("Fourth sub-option", lambda: print("Fourth sub-option")),
]),
MenuAction("On to the forth", lambda: print("Fourth option")),
MenuAction("Follow the fifth", lambda: print("Fifth option")),
MenuAction("Support the sixth", lambda: print("Sixth option")),
])
try:
Rotary(**{'menu': m, 'clk': 16, 'dt': 18, 'btn': 22})
if len(sys.argv) > 1:
if sys.argv[1] == 'clear':
m.blank(True)
else:
m.set_highlight(int(sys.argv[1]))
m.render()
else:
m.render()
while True:
sleep(1)
except KeyboardInterrupt:
m.blank(True)