def step(self, amt=1): self._led.all_off() t = time.localtime() hrs = t.tm_hour % 12 mins = t.tm_min sec = t.tm_sec h_hrs = hrs * (256 // 12) h_min = mins * (256 // 60) h_sec = sec * (256 // 60) grad = [] grad += colors.hue_gradient(h_hrs, h_min, self.half) if self.odd: grad += [h_min] grad += colors.hue_gradient(h_min, h_sec, self.half) log.debug('{}:{}:{}'.format(hrs, mins, sec)) for x in range(self.cdim): self._led.drawLine(x, 0, x, self._led.height - 1, colors.hue2rgb(grad[x])) self._step = 0
def step(self, amt=1): num_colors = int(MidiTransform.remap_cc_value(self.color_control, 1, 10)) hue = int(MidiTransform.remap_cc_value(self.color_control, 1, 255)) levels_count = int(MidiTransform.remap_cc_value(self.width_control, 5, 25)) self._levels = self.wave_range(30, 255, levels_count) if num_colors > 1: hues = bp_colors.hue_gradient(0, hue, num_colors) else: hues = [hue] self._colors = list(map(lambda x: bp_colors.hue2rgb(x), hues)) self._level_count = len(self._levels) self._color_count = len(self._colors) if self._step > self._level_count * self._color_count: self._step = 0 c_index = (self._step // self._level_count) % self._color_count l_index = (self._step % self._level_count) color = self._colors[c_index] self.layout.fill(bp_colors.color_scale(color, self._levels[l_index]), self._start, self._end) self._step += amt delay_time = MidiTransform.remap_cc_value(self.delay_control, 0, 1) time.sleep(delay_time)
def step(self, amt=1): self._tail = int(MidiTransform.remap_cc_value(self.count_control, 2, self._size)) hue = int(MidiTransform.remap_cc_value(self.color_control, 1, 255)) hues = bp_colors.hue_gradient(0, hue, 3) self._colors = list(map(lambda x: bp_colors.hue2rgb(x), hues)) self._ledcolors = [(0, 0, 0) for i in range(self._size)] self.layout.all_off() for i in range(0, 3): self._currentpos[i] = self._start + self._steps[i] # average the colors together so they blend self._ledcolors[self._currentpos[i]] = list(map(lambda x, y: (x + y) // 2, self._colors[i], self._ledcolors[self._currentpos[i]])) for j in range(1, self._tail): if self._currentpos[i] - j >= 0: self._ledcolors[self._currentpos[i] - j] = list(map(lambda x, y: (x + y) // 2, self._ledcolors[self._currentpos[i] - j], bp_colors.color_scale(self._colors[i], 255 - (self._fadeAmt * j)))) if self._currentpos[i] + j < self._size: self._ledcolors[self._currentpos[i] + j] = list(map(lambda x, y: (x + y) // 2, self._ledcolors[self._currentpos[i] + j], bp_colors.color_scale(self._colors[i], 255 - (self._fadeAmt * j)))) if self._start + self._steps[i] >= self._end: self._direction[i] = -1 elif self._start + self._steps[i] <= 0: self._direction[i] = 1 # advance each searchlight at a slightly different speed self._steps[i] += self._direction[i] * amt * int(random.random() > (i * 0.05)) for i, thiscolor in enumerate(self._ledcolors): self.layout.set(i, thiscolor) delay_time = MidiTransform.remap_cc_value(self.delay_control, 0, 1) time.sleep(delay_time)
def step(self, amt=1): num_colors = int( MidiTransform.remap_cc_value(self.count_control, 1, 10)) hue = int(MidiTransform.remap_cc_value(self.color_control, 1, 255)) self._width = int( MidiTransform.remap_cc_value(self.width_control, 1, 100)) if num_colors > 1: hues = bp_colors.hue_gradient(0, hue, num_colors) else: hues = [hue] self._colors = list(map(lambda x: bp_colors.hue2rgb(x), hues)) self._color_count = len(self._colors) self._total_width = self._width * self._color_count for i in range(self._size): cIndex = ((i + self._step) % self._total_width) // self._width self.layout.set(i, self._colors[cIndex]) self._step += amt * (1 if self._dir else -1) if self._dir and self._step >= self.layout.numLEDs: self._step = 0 elif not self._dir and self._step < 0: self._step = self.layout.numLEDs - 1 delay_time = MidiTransform.remap_cc_value(self.delay_control, 0, 1) time.sleep(delay_time)