-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsolriser.py
148 lines (118 loc) · 3.61 KB
/
solriser.py
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
136
137
138
139
140
141
142
143
144
145
146
import sys
import random
import config
import time
from birdfish.input.osc import OSCDispatcher
from birdfish.effects import Blink, Pulser, ColorShift
from birdfish.lights import LightElement, RGBLight, PulseChase, LightShow
from birdfish.output.solriserdmx import SolRiserDmx
from birdfish import tween
from solrgb import SolRgb
from solshow import SolShow
from soleffects import SolHueShift
# 0.1 lighting is stable on both host and yun systems
NUM_ADDRESSES = 93
NUM_CHANNELS = 31
channel_names = {
1: 'nose_front',
2: 'nose_mid',
3: 'nose_rear',
4: 'nose_sides_lower',
5: 'nose_sides_upper',
6: 'wings',
7: '',
8: '',
9: 'windshield',
10: 'beak_front',
11: 'beak_rear',
12: 'ray_mid_inner',
13: 'ray_midleft_inner',
14: 'ray_midright_inner',
15: 'ray_left_inner',
16: 'ray_right_inner',
17: 'ray_mid_outer',
18: 'ray_midleft_outer',
19: 'ray_midright_outer',
20: 'ray_left_outer',
21: 'ray_right_outer',
22: 'arc',
23: 'sides_front',
24: 'sides_mid',
25: 'sides_rear',
26: 'rails_front',
27: 'rails_mid',
28: 'rails_rear',
29: 'canopy_front',
30: 'canopy_rear',
31: 'stairs'
}
# create a light show - manages the updating of all lights
show = SolShow()
# Create a network - in this case, the SolRiser DMX shield over serial
#dmx = SolRiserDmx('/dev/ttyATH0')
dmx = SolRiserDmx(config.SERIAL_PORT)
# add the network to the show
show.networks.append(dmx)
# create an input interface
# dispatcher = MidiDispatcher("MidiKeys")
dispatcher = OSCDispatcher(('0.0.0.0', 8998))
# the effect is configured by how many times it should pulse per second
# 1 is the default
#pulser = Pulser()
hueShift = SolHueShift()
hueShift.width = 0.3
#raySwiper = SolSwiper()
#hueShift.add_hue_shift()
show.effects.append(hueShift)
#show.effects.append(raySwiper)
# if you wanted to give the pulse a different characteristic
# pulser = Pulser(on_shape=tween.IN_CIRC, off_shape=tween.OUT_CIRC)
for i in range(1,NUM_CHANNELS + 1):
l = SolRgb(
start_channel=i * 3 - 2,
#name="pulse_%s" % elementid,
name=channel_names[i],
#attack_duration=0.5,
#release_duration=0,
#sustain_value=1,
#simple=True
)
#l.hue = random.random() # * 255
#l.hue = .74
l.hue = (1.0 / NUM_CHANNELS) * (NUM_CHANNELS - (i - 1.0))
l.intensity = 1
l.saturation = 1
#l.update_rgb()
show.add_element(l, network=dmx)
hueShift.add_element(l)
# add the light to the network
#dmx.add_element(l)
#p.elements.append(l)
dispatcher.add_map('/global/intensity', l, 'intensity')
dispatcher.add_map('/1/fader1', l, 'intensity')
dispatcher.add_map('/global/hue', l, 'hue')
#l.effects.append(pulser)
# set the input interface to trigger the element
# midi code 41 is the "Q" key on the qwerty keyboard for the midikeys app
#dispatcher.add_observer((0,41), single)
dispatcher.add_trigger('/global/active', l)
dispatcher.add_trigger('/1/push1', l)
#dispatcher.add_trigger('/global/active', l)
# if i in range(12,21):
# raySwiper.add_element(l)
dispatcher.add_map('/global/speed', hueShift, 'speed')
dispatcher.add_map('/1/fader2', hueShift, 'speed')
inners = [15, 13, 12, 14, 16]
outers = [20, 18, 17, 19, 21]
# startup the midi communication - runs in its own thread
# dispatcher.start()
dispatcher.start()
# start the show in a try block so that we can catch ^C and stop the midi
# dispatcher thread
try:
show.run()
except KeyboardInterrupt:
# cleanup
# dispatcher.stop()
dispatcher.stop()
sys.exit(0)