Created
October 1, 2015 11:25
-
-
Save kcranley1/13e4cec1a141cb51d642 to your computer and use it in GitHub Desktop.
KC Python script to indicate roll & pitch on the Sense HAT LED array
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/python3 | |
from sense_hat import SenseHat | |
sense = SenseHat() | |
sense.clear() | |
old_x = old_y = 0 | |
while True: | |
o = sense.get_orientation() | |
pitch = o["pitch"] | |
roll = o["roll"] | |
pitch_position = int(pitch/10.0) | |
roll_position = int(roll/10.0) | |
x = pitch_position % 8 | |
y = roll_position % 8 | |
if x <> old_x: | |
sense.set_pixel(old_x, old_y, 0, 0, 0) | |
if y <> old_y: | |
sense.set_pixel(old_x, old_y, 0, 0, 0) | |
old_x = x | |
old_y - y | |
sense.set_pixel(x, y, 255, 255, 255) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment