Skip to content

Instantly share code, notes, and snippets.

@arvydas
Created April 19, 2014 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arvydas/11077638 to your computer and use it in GitHub Desktop.
Save arvydas/11077638 to your computer and use it in GitHub Desktop.
pro_rainbow.py
import time
import math
import colorsys
from blinkstick_pro import BlinkStickPro
class Main(BlinkStickPro):
def init_rainbow(self, intensiveness):
for y in range(0, self.rows):
for x in range(0, self.cols):
amplitude = math.sin(math.radians(360. / self.cols * x))
#if x > self.cols / 2:
# amplitude = 0
r, g, b = map(lambda d: int(round(d * 255)),
colorsys.hls_to_rgb(float(y) / self.rows, amplitude * amplitude * intensiveness, 1))
self.set_color(x, y, r, g, b)
def run(self, shift=False):
self.init_rainbow(0.01)
self.send_data_all()
while shift:
self.shift_left()
self.send_data_all()
self.print_fps()
main = Main(columns=8 * 1, rows=8, channels=1, delay=0.002)
if main.connect():
main.run(False)
else:
print "No BlinkSticks found"
print "exit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment