-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfireflies_remote.py
46 lines (35 loc) · 1.4 KB
/
fireflies_remote.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
import random
import time
import os
import sys
file_dir = os.path.dirname(__file__)
sys.path.append(file_dir)
from base_remote_strip import BaseRemoteStrip
from base_remote_strip import MidiTransform
from base_remote_strip import NumberUtils
from base_remote_strip import ColorMidiUtils
from bibliopixel import colors as bp_colors
class FireFliesRemote(BaseRemoteStrip):
def __init__(self, layout, start=0, end=-1, **args):
super(FireFliesRemote, self).__init__(layout, start, end, **args)
self.max_count = self.layout.numLEDs / 2
self.max_width = self.layout.numLEDs / 2
self.colors = []
def pre_run(self):
self._step = 0
def step(self, amt=1):
amt = 1
if self._step > self.layout.numLEDs:
self._step = 0
self.layout.all_off()
self.get_color()
scaled_count = int(MidiTransform.remap_cc_value(self.count_control, 1, self.max_count))
scaled_width = int(MidiTransform.remap_cc_value(self.width_control, 1, self.max_width))
for i in range(scaled_count):
pixel = random.randint(0, self.layout.numLEDs - 1)
for i in range(scaled_width):
if pixel + i < self.layout.numLEDs:
self.layout.set(pixel + i, self._color)
self._step += amt
delay_time = MidiTransform.remap_cc_value(self.delay_control, 0, 1)
time.sleep(delay_time)