144 lines
4.4 KiB
Python
144 lines
4.4 KiB
Python
#!/usr/bin/python3
|
|
from phue import Bridge
|
|
import time
|
|
b = Bridge('172.18.152.190')
|
|
Nedges = 30;
|
|
edgecode = [None] * Nedges;
|
|
|
|
# The edges are numbered as in info/SSDedges.obj; enter the two-letter code for
|
|
# the lightstrip inserted through each edge in the block below:
|
|
|
|
edgecode[ 0] = 'XX';
|
|
edgecode[ 1] = 'XX';
|
|
edgecode[ 2] = 'XX';
|
|
edgecode[ 3] = 'XX';
|
|
edgecode[ 4] = 'XX';
|
|
edgecode[ 5] = 'XX';
|
|
edgecode[ 6] = 'XX';
|
|
edgecode[ 7] = 'XX';
|
|
edgecode[ 8] = 'XX';
|
|
edgecode[ 9] = 'XX';
|
|
edgecode[10] = 'XX';
|
|
edgecode[11] = 'XX';
|
|
edgecode[12] = 'XX';
|
|
edgecode[13] = 'XX';
|
|
edgecode[14] = 'XX';
|
|
edgecode[15] = 'XX';
|
|
edgecode[16] = 'XX';
|
|
edgecode[17] = 'XX';
|
|
edgecode[18] = 'XX';
|
|
edgecode[19] = 'XX';
|
|
edgecode[20] = 'XX';
|
|
edgecode[21] = 'XX';
|
|
edgecode[22] = 'XX';
|
|
edgecode[23] = 'XX';
|
|
edgecode[24] = 'XX';
|
|
edgecode[25] = 'XX';
|
|
edgecode[26] = 'XX';
|
|
edgecode[27] = 'XX';
|
|
edgecode[28] = 'XX';
|
|
edgecode[29] = 'XX';
|
|
|
|
# End of edge codes; show automation follows
|
|
|
|
edges = [ b[code] for code in edgecode ]
|
|
|
|
lasthue = 65535
|
|
fullbright = 254
|
|
fullsat = 254
|
|
|
|
# some color preliminaries
|
|
white = {'hue' : 0, 'bri' : fullbright, 'sat' : 0}
|
|
black = {'bri' : 0, 'sat' : 0}
|
|
|
|
def hueint(frac): return int((frac % 1)*lasthue)
|
|
|
|
def fshue(frac):
|
|
'''Returns a hue number based on the fractional part of frac, warping
|
|
[0,1/2) to [0,1/6) and [1/2,1) to [1/2,2/3]
|
|
'''
|
|
frac = frac % 1
|
|
if frac < 0.5: return hueint(frac/3);
|
|
else: return hueint((frac+1)/3);
|
|
|
|
def vivid(hue): return {'hue' : hue, 'bri' : fullbright, 'sat' : fullsat}
|
|
|
|
# A "setting" is a pair of a list of N lists of edges, and a list of N dicts
|
|
# understandable by Bridge.set_light,
|
|
# e.g. {'bri' : 127, 'hue' : 43690, 'sat' : 224},
|
|
# which means to set the ith list of edges to the ith dict.
|
|
# Note the list of lists does not have to be a partition; edges not mentioned
|
|
# in any list will be left alone.
|
|
|
|
alltogether = [range(0,Nedges)];
|
|
thevoid = (alltogether, [black])
|
|
deepblue = (alltogether, [vivid(hueint(2/3))])
|
|
yelorng = (alltogether, [vivid(hueint(1/6))])
|
|
redred = (alltogether, [vivid(hueint(0))])
|
|
|
|
# A "simpleshow" is a pair of a list of settings, and a list of triples of
|
|
# integers: (setting_index, transition_to, hold_time)
|
|
# where setting_index is an index into the list of settings, and transition_to
|
|
# and hold_time are times in deciseconds to take to morph to the given
|
|
# setting, and then hold at the given setting before the next step of the
|
|
# simpleshow.
|
|
|
|
intro = ([thevoid, deepblue, yelorng, redred],
|
|
[(0,1,0), (1,30,20),
|
|
(2,1,3), (1,1,3), (2,1,3), (1,1,3), (2,1,3), (1,1,3), (2,1,0),
|
|
(3,50,20), (0,30,5)])
|
|
|
|
interlude = ([thevoid], [(0,30,10)])
|
|
|
|
def runsimple(ss):
|
|
'''Takes one argument, a simple show; causes the simple show to be
|
|
executed on the FireStar
|
|
'''
|
|
settings = ss[0]
|
|
for (setting_index, transition_to, hold_time) in ss[1]:
|
|
theset = settings[setting_index]
|
|
subs = theset[0]
|
|
cmds = theset[1]
|
|
nsubs = length(subs)
|
|
for i in range(0,nsubs):
|
|
thiscmd = cmds[i].copy()
|
|
thiscmd['transitiontime'] = transition_to
|
|
b.set_light([edges[e].light_id for e in subs[i]], thiscmd)
|
|
time.sleep(hold_time/10)
|
|
|
|
runsimple(intro)
|
|
|
|
# Tour of 5-colorings by Henry Segerman
|
|
basehues = {'Red': 0, 'Orange': 5461, 'Yellow': 10923, 'Cyan': 32768,
|
|
'Blue': 43691}
|
|
|
|
fivehues = [basehues[c] for c in ['Red', 'Orange', 'Yellow', 'Cyan', 'Blue']]
|
|
|
|
fivecolors = [vivid(h) for h in fivehues]
|
|
|
|
fivecs = [];
|
|
|
|
fivecs.append([[0,22,9,12,25,17], [27,20,10,7,1,15], [26,11,21,8,3,16],
|
|
[29,23,13,18,5,2], [28,24,4,6,14,19]]);
|
|
|
|
#fivecs.append(([[0,22,9,12,25,17], [27,20,15,24,6,4], [26,11,21,8,3,16],
|
|
# [29,23,13,18,5,2], [28,14,19,10,1,7]], fivecolors));
|
|
#fivecs.append(([[12,25,17,8,3,21], [27,20,15,24,6,4], [26,11,16,0,9,22],
|
|
# [29,23,13,18,5,2], [28,14,19,10,1,7]], fivecolors));
|
|
#fivecs.append(([[12,17,8,3,28,10], [27,20,15,24,6,4], [26,11,16,0,9,22],
|
|
# [29,23,13,18,5,2], [14,19,1,7,25,21]], fivecolors));
|
|
#fivecs.append(([[12,17,8,3,28,10], [27,20,24,4,16,9], [26,11,0,22, ,15,6],[29,23,13,18,5,2],[14,19, 1,7, 25,21]]
|
|
#
|
|
#"5"
|
|
#[[17, 3, 28, 0,6,11],[27,20, 24,4, 16,9],[26, 22, 15, 8,12,10 ],[29,23,13,18,5,#2],[14,19, 1,7, 25,21]]
|
|
#
|
|
#"6"
|
|
#[[17, 3, 28, 0,6,11],[27, 24, 16, 7,19,21],[26, 22, 15, 8,12,10 ],[29,23,13,18,5,2],[14, 1, 25, 4,9,20]]
|
|
|
|
exec(open("fivecolor.py").read())
|
|
|
|
runsimple(interlude)
|
|
runsimple(jmsshow1)
|
|
runsimple(interlude)
|
|
runsimple(jmsshow2)
|