-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathposnetnp.py
47 lines (40 loc) · 846 Bytes
/
posnetnp.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
#!/usr/bin/python
import time
import pyposnet
import xmmscontrol.client
conn = xmmscontrol.client.connect("pass", "hostname")
kasa = pyposnet.posnet("/dev/usb/tts/0")
width = 20
ov = None
state = 1
current = 0
while True:
np = conn.nowPlaying()
l = len(np)
if l <= 20:
kasa.display_client_string(np, upper = True)
current = 0
else:
if current < 0:
current = 0
state = 2
elif current+20 > l:
current = l-20
state = 2
kasa.display_client_string(np[current:current+20], upper = True)
if state == 1:
current += 1
elif state == 2:
time.sleep(1)
if current != 0:
state = 3
else:
state = 1
elif state == 3:
current -= 1
v = conn.volume()
if v != ov:
ov = v
v = int(v[1:v.find(',')])
kasa.display_client_string("Vol %i%%" % v, lower = True)
time.sleep(1)