Skip to content

Instantly share code, notes, and snippets.

@fire-eggs
Created February 29, 2016 19:46
Show Gist options
  • Save fire-eggs/996778c5133b8a67f210 to your computer and use it in GitHub Desktop.
Save fire-eggs/996778c5133b8a67f210 to your computer and use it in GitHub Desktop.
A Python script to show a "hidden" feature of the Pimoroni Display-o-Tron HAT. Individual backlight LED control: marching hues
#!/usr/bin/env python
print("""
This example shows you a feature of the Dot HAT.
You should see colors step across the screen!
Press CTRL+C to exit.
""")
import dothat.backlight as backlight
import dothat.lcd as lcd
import atexit
import time
def tidyup():
backlight.off()
lcd.clear()
backlight.graph_off()
atexit.register(tidyup)
lcd.set_cursor_position(0,0)
lcd.write("the hues go marching one by one")
dVal = 0.05 # hue value delta - alter to taste
delta = dVal
hue = 0 # hue to use, range 0..1
y = 0
while True:
rgb = backlight.hue_to_rgb(hue)
# there are six RGB LEDs - the % (mod) operator insures range 0-5
backlight.single_rgb(y % 6, rgb[0], rgb[1], rgb[2])
y += 1 # next LED
time.sleep(0.5)
# toggle the hue "direction"
hue += delta
if (hue > 1.0):
delta = -dVal
hue = 1.0
if (hue < 0):
delta = dVal
hue = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment