-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrainbow_remote.py
39 lines (31 loc) · 1.28 KB
/
rainbow_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
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 RainbowRemote(BaseRemoteStrip):
"""Generate rainbow wheel equally distributed over strip."""
def __init__(self, layout, start=0, end=-1, **args):
super(RainbowRemote, self).__init__(layout, start, end, **args)
def pre_run(self):
self._step = 0
def step(self, amt=1):
for i in range(self._size):
chunk_size = MidiTransform.remap_cc_value(self.count_control, 1, 20)
chunks = self._size / chunk_size
color = bp_colors.hue_helper(i, chunks, self._step)
brightness_level = MidiTransform.remap_cc_value(self.brightness_control, 0, 256)
color = bp_colors.color_scale(color, brightness_level)
self.layout.set(self._start + i, color)
self._step += amt
overflow = self._step - 256
if overflow >= 0:
self._step = overflow
delay_time = MidiTransform.remap_cc_value(self.delay_control, 0, 1)
time.sleep(delay_time)