/
main.py
executable file
·31 lines (25 loc) · 904 Bytes
/
main.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
#!/usr/bin/python3
import display as d
import re
import os
import time
def getstuff(cmd):
return [s.strip("\n") for s in os.popen(cmd).readlines()]
d1 = d.display('/dev/ttyUSB0', 2400)
d1.cursor(0)
mpc_cmd = "mpc -h 192.168.0.2 -P password | unidecode -e utf8"
d1.add("song", d.scrolltext(0, 39, "foo", "m"))
d1.add("prog", d.pbar(45, 29, 0))
d1.add("curtime", d.text(40, 5, "", "l"))
d1.add("tottime", d.text(74, 5, "", "r"))
while 1:
#date = rpad(getstuff("date"), 40)
status = getstuff(mpc_cmd)
d1.fields["curtime"].change(re.search("(\d+:\d+)\/(\d+:\d+)", status[1]).group(1))
d1.fields["tottime"].change(re.search("(\d+:\d+)\/(\d+:\d+)", status[1]).group(2))
d1.fields["prog"].change(int(re.search("\((\d+)\%\)", status[1]).group(1)))
d1.fields["song"].change(status[0])
#d1.printd(pos(0) + date)
d1.update()
d1.fields["song"].shift()
time.sleep(1)