-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlightControllerMain.py
More file actions
45 lines (39 loc) · 873 Bytes
/
Copy pathlightControllerMain.py
File metadata and controls
45 lines (39 loc) · 873 Bytes
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
import subprocess
import sys
def get_percent(perc):
percent = {
100: 255,
95: 242,
90: 229,
85: 217,
80: 204,
75: 191,
70: 178,
65: 166,
60: 153,
55: 140,
50: 127,
45: 115,
40: 102,
35: 89,
30: 76,
25: 64,
20: 51,
15: 38,
10: 25,
5: 12,
4: 10,
3: 8,
2: 5,
1: 2,
0: 0
}
return percent[int(perc)]
def light_control():
if sys.argv[1] == "true":
subprocess.run(["saberlight", "white", "FF:FF:F0:01:24:AF", "255"])
elif sys.argv[1] == "false":
subprocess.run(["saberlight", "white", "FF:FF:F0:01:24:AF", "0"])
else:
subprocess.run(["saberlight", "white", "FF:FF:F0:01:24:AF", str(get_percent(sys.argv[1]))])
light_control()