some more clients and test code for arduino

master
Gunstick 2015-02-21 17:47:04 +01:00
parent 1c8e41e8ad
commit ea4264fc34
4 changed files with 109 additions and 7 deletions

39
clients/cellular55.py Normal file
View File

@ -0,0 +1,39 @@
# Client program "cellular"
import sys, time
from math import *
from random import randint
from s2llib import *
# setup window area, channels and segments
seg_windows = 12
segments = 8 # number of segments in a window (7 + period/dot/point)
width = 6
height = 5
zlevel = 20
segchannels = 4 # RGBA
cell = syndelights_canvas("s2l\n<8<18 ", zlevel, width, height, seg_windows, "10.2.113.175", 8888, "10.2.113.161", 8888, 2)
cell.connect()
# reset/initialize map
cell.reset_windows(0, 0, 0, 0, 0)
cell.reset_segment_windows(0, 255, 255, 255, 255)
# main loop
while True:
# set start seed
# get random location
rx = randint(0, width - 1)
ry = randint(0, height - 1)
cell.setwin_xy_srgba_array(rx, ry, [0, randint(0,127), randint(0, 127), randint(0, 127), 255])
cell.draw()
time.sleep(0.1)
# end of main animation loop
cell.disconnect()

View File

@ -10,12 +10,12 @@ local_port = 5004
# direct html udp port # direct html udp port
remote_port = 4422 remote_port = 4422
# production port # production port
remote_port = 4321 remote_port = 8888
zlevel=15 zlevel=15
# TODO: autodetect interface address for remote application # TODO: autodetect interface address for remote application
outgoing_if = "127.0.0.1" outgoing_if = "10.2.113.175"
remote_host = "127.0.0.1" remote_host = "10.2.113.161"
# udp is the default for DGRAM # udp is the default for DGRAM
UDPSock = socket(AF_INET, SOCK_DGRAM) UDPSock = socket(AF_INET, SOCK_DGRAM)
@ -28,7 +28,7 @@ UDPSock.bind((outgoing_if, local_port))
# goes down or refuses connection # goes down or refuses connection
#UDPSock.connect((remote_host, remote_port)) #UDPSock.connect((remote_host, remote_port))
hash = "s2l\n<8<18 " # 10 bytes hash = "s2l\n55<18 " # 10 bytes
alpha = chr(55) alpha = chr(55)

62
clients/scan55.py Normal file
View File

@ -0,0 +1,62 @@
# Client program "cellular"
import sys, time
from math import *
from random import randint
from s2llib import *
# setup window area, channels and segments
seg_windows = 12
segments = 8 # number of segments in a window (7 + period/dot/point)
width = 5
height = 5
zlevel = 20
segchannels = 4 # RGBA
cell = syndelights_canvas("s2l\n55<18 ", zlevel, width, height, seg_windows, "10.2.113.175", 8888, "10.2.113.161", 8888, 2)
cell.connect()
# reset/initialize map
cell.reset_windows(0, 0, 0, 0, 0)
cell.reset_segment_windows(0, 255, 255, 255, 255)
# main loop
x = 0
y = 0
w = 0
s = 0
c = []
for i in xrange(width * height):
# define colour
if i%3 == 0:
c = [0, 255, 0, 0, 255]
elif i%3 == 1:
c = [0, 0, 255, 0, 255]
elif i%3 == 2:
c = [0, 0, 0, 255, 255]
# go to next floor
if x == width:
y = y + 1
x = 0
# go to next window
if s == segments:
w = w + 1
s = 0
cell.setwin_xy_srgba_array(x, y, c)
cell.setsegwin_ws_srgba_array(w, s, c)
cell.draw()
time.sleep(0.5)
cell.setwin_xy_srgba_array(x, y, [0, 0, 0, 0, 127])
cell.setsegwin_ws_srgba_array(w, s, [0, 0, 0, 0, 127])
# increment windows, segments
x = x + 1
s = s + 1
cell.disconnect()

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# test program # test program
# modify below the ethernet adress # modify below the ethernet adress
IP="$1"
# width and height are unfortunately hardcoded # width and height are unfortunately hardcoded
a=-1 a=-1
while true while true
@ -24,7 +25,7 @@ frame="$(
then then
printf "xyz " printf "xyz "
else else
printf "012 " printf " "
fi fi
i=$((i+1)) i=$((i+1))
done done
@ -45,6 +46,6 @@ frame="$(
# done # done
)" )"
echo "$frame" echo "$frame"
echo "$frame" | nc -w 1 -u 10.2.113.161 8888 echo "$frame" | nc -w 1 -u $IP 8888
sleep 1 # sleep 1
done done