2019-09-27 16:26:02 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
from phue import Bridge
|
|
|
|
import time
|
2019-09-28 15:24:38 +00:00
|
|
|
import random
|
|
|
|
|
2019-09-27 21:45:39 +00:00
|
|
|
b = Bridge('172.18.130.12')
|
2019-09-27 16:26:02 +00:00
|
|
|
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:
|
|
|
|
|
2019-09-27 21:45:39 +00:00
|
|
|
exec(open("edgecodes.py").read())
|
2019-09-27 16:26:02 +00:00
|
|
|
|
|
|
|
edges = [ b[code] for code in edgecode ]
|
|
|
|
|
2019-09-27 20:54:15 +00:00
|
|
|
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
|
2019-09-28 15:24:38 +00:00
|
|
|
[0,1/2) to [0,1/6) and [1/2,1) to [9/20,14/20)
|
2019-09-27 20:54:15 +00:00
|
|
|
'''
|
|
|
|
frac = frac % 1
|
|
|
|
if frac < 0.5: return hueint(frac/3);
|
2019-09-28 15:24:38 +00:00
|
|
|
else: return hueint((frac + 0.4)/2);
|
2019-09-27 20:54:15 +00:00
|
|
|
|
|
|
|
def vivid(hue): return {'hue' : hue, 'bri' : fullbright, 'sat' : fullsat}
|
2019-09-27 16:26:02 +00:00
|
|
|
|
|
|
|
# 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)];
|
2019-09-27 20:54:15 +00:00
|
|
|
thevoid = (alltogether, [black])
|
|
|
|
deepblue = (alltogether, [vivid(hueint(2/3))])
|
|
|
|
yelorng = (alltogether, [vivid(hueint(1/6))])
|
|
|
|
redred = (alltogether, [vivid(hueint(0))])
|
2019-09-27 16:26:02 +00:00
|
|
|
|
|
|
|
# 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],
|
2019-09-28 15:24:38 +00:00
|
|
|
[(0,1,0), (1,40,40),
|
|
|
|
(2,1,10), (1,1,10), (2,1,10), (1,1,10), (2,1,10), (1,1,10), (2,1,10),
|
|
|
|
(3,60,40), (0,30,5)])
|
2019-09-27 20:54:15 +00:00
|
|
|
|
2019-09-28 15:24:38 +00:00
|
|
|
interlude = ([thevoid], [(0,30,10),(0,30,10)])
|
2019-09-27 16:26:02 +00:00
|
|
|
|
|
|
|
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]
|
2019-09-28 15:24:38 +00:00
|
|
|
nsubs = len(subs)
|
2019-09-27 16:26:02 +00:00
|
|
|
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)
|
2019-09-28 15:24:38 +00:00
|
|
|
time.sleep((transition_to + hold_time)/10)
|
2019-09-27 16:26:02 +00:00
|
|
|
|
2019-09-28 15:24:38 +00:00
|
|
|
#runsimple(intro)
|
2019-09-27 20:54:15 +00:00
|
|
|
|
2019-09-28 15:24:38 +00:00
|
|
|
# The most symmetric five-coloring of edges
|
|
|
|
fivecs = [];
|
2019-09-27 20:54:15 +00:00
|
|
|
|
2019-09-28 15:24:38 +00:00
|
|
|
fivecs.append([[0,17, 12,22, 9,25], [3,11, 16,21, 8,26], [1,20, 10,15, 7,27],
|
|
|
|
[2,23, 13,18, 5,29], [4,14, 19,24, 6,28]]);
|
2019-09-27 20:54:15 +00:00
|
|
|
|
2019-09-28 15:24:38 +00:00
|
|
|
exec(open("fivecolor.py").read())
|
2019-09-27 20:54:15 +00:00
|
|
|
|
2019-09-28 15:24:38 +00:00
|
|
|
#runsimple(interlude)
|
|
|
|
#runsimple(jmsshow1)
|
|
|
|
#runsimple(interlude)
|
|
|
|
#runsimple(jmsshow2)
|
2019-09-27 20:54:15 +00:00
|
|
|
|
2019-09-28 15:24:38 +00:00
|
|
|
# Let's identify the stars:
|
|
|
|
stars = [[0,1,8,24,13], [17,20,26,19,18], [0,4,5,10,21], [17,14,29,15,16],
|
|
|
|
[1,2,6,12,16], [20,23,28,22,21], [2,3,9,15,19], [23,11,25,10,24],
|
|
|
|
[3,4,7,18,22], [11,14,27,13,12], [5,6,7,8,9], [29,28,27,26,25]]
|
2019-09-27 20:54:15 +00:00
|
|
|
|
2019-09-28 15:24:38 +00:00
|
|
|
starsettings = []
|
|
|
|
for off in [0,2]:
|
|
|
|
for s in range(0,12):
|
|
|
|
starsettings.append(([stars[s]],
|
|
|
|
[{'hue': fshue((off+s)/4 + random.uniform(0,1/4)),
|
|
|
|
'sat': random.randint(191,254),
|
|
|
|
'bri': fullbright}]))
|
|
|
|
starshow = (starsettings, [(n,10,30) for n in range(0,24)])
|
|
|
|
|
|
|
|
#runsimple(interlude)
|
|
|
|
#runsimple(starshow)
|
|
|
|
|
|
|
|
# Tour of 5-colorings suggested by Henry Segerman implemented by Henry
|
|
|
|
# Segerman and Glen Whitney, based on
|
|
|
|
# http://www.weddslist.com/writing/icos/listc.html
|
|
|
|
# The keys in basehues are Nick's color symbols,
|
|
|
|
# even though they correspond to
|
|
|
|
# Red, orangeY, Goldenrod, cyanoBlue, and darKblue
|
|
|
|
# Map from Nick's vertex pairs to FireStar edge numbers:
|
|
|
|
#
|
|
|
|
|
|
|
|
basehues = {'R': 0, 'Y': 5461, 'G': 10923, 'B': 32768, 'K': 43691}
|
|
|
|
|
|
|
|
def vb(ltr): return vivid(basehues[ltr])
|
|
|
|
|
|
|
|
fivecolors = [vb(c) for c in ['R', 'Y', 'G', 'B', 'K']]
|
|
|
|
|
|
|
|
# Nick's coloring (NC) "0"
|
|
|
|
fivetour = [(fivecs[0], fivecolors)]
|
|
|
|
# Step NC "0" to NC "1"
|
|
|
|
fivetour.append(([[3,21,26],[4,19,28]], [vb('K'),vb('Y')]))
|
|
|
|
# Step NC "1" to NC "0"
|
|
|
|
fivetour.append(([[3,21,26],[4,19,28]], [vb('Y'),vb('K')]))
|
|
|
|
|
|
|
|
tour5show = (fivetour, [(0,30,20),(1,5,5),(2,5,5),(1,5,5),(2,5,5),(1,5,30)])
|
2019-09-27 20:54:15 +00:00
|
|
|
|
|
|
|
runsimple(interlude)
|
2019-09-28 15:24:38 +00:00
|
|
|
runsimple(tour5show)
|