Skip to content

Instantly share code, notes, and snippets.

@HDR
Last active July 25, 2018 22:22
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 HDR/3e6d2932abd6f3f2dc2b77f4a3e5ef7b to your computer and use it in GitHub Desktop.
Save HDR/3e6d2932abd6f3f2dc2b77f4a3e5ef7b to your computer and use it in GitHub Desktop.
Blinkt single pixel RGB & brightness
#!/usr/bin/env python
import sys
import blinkt
def usage():
print("Usage: {} <pixel(0-7)> <r> <g> <b> <brightness(0-10)>".format(sys.argv[0]))
sys.exit(1)
if len(sys.argv) != 6: usage()
try:
p, r, g, b, y = [int(x) for x in sys.argv[1:]]
except ValueError: usage()
if p > 7: usage()
if max(r, g, b) > 255: usage()
if y > 10: usage()
print("Setting Pixel {p} to {r},{g},{b} with {y} brightness".format(p=p, r=r, g=g, b=b, y=y))
if y == 0: brightness = 0.0
if y == 1: brightness = 0.1
if y == 2: brightness = 0.2
if y == 3: brightness = 0.3
if y == 4: brightness = 0.4
if y == 5: brightness = 0.5
if y == 6: brightness = 0.6
if y == 7: brightness = 0.7
if y == 8: brightness = 0.8
if y == 9: brightness = 0.9
if y == 10: brightness = 1.0
blinkt.set_clear_on_exit(False)
blinkt.set_brightness(brightness)
blinkt.set_pixel(p, r, g, b)
blinkt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment