Last active
June 2, 2017 22:49
-
-
Save dglaude/5f1549e85957a543f6dc6c88acf8b4f4 to your computer and use it in GitHub Desktop.
HSV color control of the Blinkt! from a Blue Dot.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from bluedot import BlueDot | |
import colorsys | |
import time | |
import blinkt | |
def move(pos): | |
# print("The Blue Dot x={} y={} d={} a={}".format(pos.x, pos.y, pos.distance, pos.angle)) | |
h=((pos.angle+180) % 360) / 360 | |
s=pos.distance | |
v=1.0 | |
r, g, b = [int(c*255) for c in colorsys.hsv_to_rgb(h, s, v)] | |
for x in range(blinkt.NUM_PIXELS): | |
blinkt.set_pixel(x, r, g, b) | |
blinkt.show() | |
blinkt.set_brightness(0.1) | |
blinkt.set_clear_on_exit() | |
bd = BlueDot() | |
bd.wait_for_press() | |
bd.when_pressed = move | |
bd.when_moved = move | |
while True: | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
New with double click to turn off the Blinkt! LED.