forked from sleeepyjack/RPi_AdafruitLCD_Menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testMenu.py
55 lines (43 loc) · 1.79 KB
/
testMenu.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#Daniel Juenger, github.com/sleeepyjack
from time import sleep
import Adafruit_CharLCD as LCD
from Menu import Menu
lcd = LCD.Adafruit_CharLCDPlate()
menu = Menu()
#The menu can show strings, bash and python expressions
# topElement( Name , Type of content , Lower row content)
top1 = menu.topElement("< Netzwerk >", "STRING", " v")
top2 = menu.topElement("< System >", "STRING", " v")
top3 = menu.topElement("< top3 >", "STRING", " v")
top4 = menu.topElement("< top4 >", "STRING", " v")
top5 = menu.topElement("< top5 >", "STRING", " v")
sub11 = menu.subElement("Netzw.>Signal", "BASH", "iwconfig wlan0 | awk -F'[ =]+' '/Signal level/ {print $7}' | cut -d/ -f1")
sub12 = menu.subElement("Netzw.>SSID", "BASH", "iwconfig wlan0 | grep 'ESSID:' | awk '{print $4}' | sed 's/ESSID://g'")
sub13 = menu.subElement("Netzw.>Internet", "BASH", "ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || echo error")
sub21 = menu.subElement("System>CPU", "PYTHON", 'str(str(psutil.cpu_percent()) + "%")')
sub22 = menu.subElement("System>CPU-Temp.", "STRING", "TODO")
sub23 = menu.subElement("System>RAM", "PYTHON", 'str(str(psutil.virtual_memory()[2])+"% used")')
#Adding elements to the menu
menu.addTopElement(top1)
menu.addTopElement(top2)
menu.addTopElement(top3)
menu.addTopElement(top4)
menu.addTopElement(top5)
menu.addSubElement(top1, sub11)
menu.addSubElement(top1, sub12)
menu.addSubElement(top1, sub13)
menu.addSubElement(top2, sub21)
menu.addSubElement(top2, sub22)
menu.addSubElement(top2, sub23)
#initializing display
lcd.clear()
lcd.set_color(0,1,1)
#little loading animation
i = 0
lcd.message("LOADING\n")
while(i < 16):
lcd.message(chr(219))
sleep(.1)
i += 1
#starting the menu
menu.startMenu(lcd)