Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Holland Computing Center
HCCPiCluster
Commits
131c7ae2
Commit
131c7ae2
authored
Jun 06, 2019
by
Caughlin Bohn
Browse files
Remote Activated lighting, listens to head on :80/control
parent
4daf9820
Changes
1
Hide whitespace changes
Inline
Side-by-side
Workers/workDir/LightPi.py
0 → 100755
View file @
131c7ae2
from
piglow
import
PiGlow
import
time
import
socket
import
subprocess
import
psutil
from
random
import
randint
import
urllib2
,
json
p
=
PiGlow
()
val
=
100
colour
=
1
def
sendCommand
(
command
):
p
=
subprocess
.
Popen
(
command
.
split
(
" "
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
(
stdout
,
stderr
)
=
p
.
communicate
()
def
getControlData
():
rawData
=
urllib2
.
urlopen
(
"http://192.168.1.1/control"
).
read
()
print
(
rawData
)
controls
=
json
.
loads
(
rawData
)
print
(
controls
)
host
=
socket
.
gethostname
()
print
(
controls
[
host
])
return
controls
[
host
]
while
True
:
#try:
p
.
all
(
0
)
if
getControlData
():
print
(
"in"
)
p
.
white
(
10
)
time
.
sleep
(
0.1
)
p
.
blue
(
20
)
time
.
sleep
(
0.1
)
p
.
green
(
30
)
time
.
sleep
(
0.1
)
p
.
yellow
(
40
)
time
.
sleep
(
0.1
)
p
.
orange
(
50
)
time
.
sleep
(
0.1
)
p
.
red
(
60
)
time
.
sleep
(
0.1
)
p
.
white
(
255
)
time
.
sleep
(
0.1
)
p
.
red
(
0
)
time
.
sleep
(
0.1
)
p
.
orange
(
0
)
time
.
sleep
(
0.1
)
p
.
yellow
(
0
)
time
.
sleep
(
0.1
)
p
.
green
(
0
)
time
.
sleep
(
0.1
)
p
.
blue
(
0
)
time
.
sleep
(
0.1
)
p
.
white
(
0
)
time
.
sleep
(
0.1
)
else
:
p
.
all
(
0
)
time
.
sleep
(
0.5
)
# except Exception as e:
# print(e)
# p.all(0)
# p.red(255)
# p.white(255)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment