-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton_functions.py
More file actions
135 lines (108 loc) · 3.77 KB
/
button_functions.py
File metadata and controls
135 lines (108 loc) · 3.77 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import sys, time, threading, requests
sys.path.append("../catkin_ws/src/scr_control/scripts/blinds")
sys.path.append("../catkin_ws/src/scr_control/scripts/lights")
import SCR_blind_client as blind_control
import SCR_OctaLight_client as light_control
server_ip = 'http://192.168.0.2:5000'
log_presses = True
def SetCctColor(cct):
for x in range(10):
requests.post(server_ip + '/Status_Lights', json={"light": x, "val": cct})
def log(arg):
requests.post(server_ip + '/Script_Run', json={"name": "log", "arg": arg})
def button_on(touch):
log("on")
light_control.cct_all(3500, 1000)
SetCctColor(3500)
def button_off(touch):
log("off")
light_control.cct_all(0, 0)
SetCctColor(10000)
def button_sliders(touch):
log("cct:" + str(touch.cctSlider.get()))
log("int:" + str(touch.intSlider.get()))
light_control.cct_all(int(touch.cctSlider.get()), int(touch.intSlider.get()))
def button_cct(touch):
pass
def button_int(touch):
pass
def button_auto(touch):
pass
def button_grad(touch):
light_control.sources(0, 0, 100, 0, 0, 0, 0, 0, 0, 0)
light_control.sources(0, 2, 100, 0, 0, 0, 0, 0, 0, 0)
light_control.sources(1, 1, 0, 100, 0, 0, 0, 0, 0, 0)
light_control.sources(2, 0, 0, 0, 100, 0, 0, 0, 0, 0)
light_control.sources(2, 2, 0, 0, 0, 100, 0, 0, 0, 0)
light_control.sources(3, 0, 0, 0, 0, 0, 100, 0, 0, 0)
light_control.sources(3, 2, 0, 0, 0, 0, 0, 100, 0, 0)
light_control.sources(4, 1, 0, 0, 0, 0, 0, 0, 100, 0)
light_control.sources(5, 0, 0, 0, 0, 0, 0, 0, 0, 100)
light_control.sources(5, 2, 0, 0, 0, 0, 0, 0, 0, 100)
def button_sun(touch):
log("sun")
requests.post(server_ip + '/Script_Run', json={"name": "sun"})
def button_circ(touch):
log("circ")
requests.post(server_ip + '/Script_Run', json={"name": "circ"})
def button_sat(touch):
log("sat")
light_control.sources_all(21, 14, 4, 73, 22, 100, 22, 4)
def button_fid(touch):
log("fid")
light_control.sources_all(39, 6, 25, 56, 57, 100, 3, 6)
def button_dul(touch):
log("dul")
light_control.sources_all(41, 2, 25, 53, 38, 100, 2, 0)
def button_lift(touch):
log("lift")
blind_control.lift_all(100)
def button_open(touch):
log("open")
blind_control.tilt_all(50)
def button_close(touch):
log("close")
blind_control.tilt_all(100)
time.sleep(2)
blind_control.lift_all(0)
def slider_cct(touch, value):
if touch.slidersActive:
light_control.cct_all(int(value), int(touch.intSlider.get()))
SetCctColor(int(value))
def slider_int(touch, value):
if touch.slidersActive:
light_control.cct_all(int(touch.cctSlider.get()), int(value))
def setButtons(buttons, i):
if i in range(12, 15):
for j in range(12, 15):
buttons[j].setOff()
else:
for j in range(0, 12):
buttons[j].setOff()
buttons[i].setOn()
def setSliders(touch, i):
requests.post(server_ip + '/Script_Kill', json={"name": "sun"})
requests.post(server_ip + '/Script_Kill', json={"name": "circ"})
if i < 12:
if i==2:
touch.cctSlider.config(troughcolor='SlateGray2')
touch.intSlider.config(troughcolor='SlateGray2')
touch.slidersActive = True
else:
touch.cctSlider.config(troughcolor='ivory3')
touch.intSlider.config(troughcolor='ivory3')
touch.slidersActive = False
def pressButton(touch, i):
setButtons(touch.buttons, i)
setSliders(touch, i)
button_functions[i](touch)
button_functions = [button_on, button_off, button_sliders,
button_cct, button_int, button_auto,
button_grad, button_sun, button_circ,
button_sat, button_fid, button_dul,
button_lift, button_open, button_close]
button_names = ["On", "Off", "Enable\nSliders",
"Dynamic\nCCT", "Dynamic\nInt", "Auto",
"Gradient", "Sun", "Circ",
"Sat", "Fid","Dul",
"Lift\nBlinds", "Open\nBlinds", "Close\nBlinds"]