Created
July 4, 2017 12:47
-
-
Save buxtonpaul/0625f3f9be0ec6add0229cce9d28447d to your computer and use it in GitHub Desktop.
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
from sense_hat import SenseHat | |
sense = SenseHat() | |
r = (255, 0, 0) | |
o = (255, 127, 0) | |
y = (255, 255, 0) | |
g = (0, 255, 0) | |
b = (0, 0, 255) | |
i = (75, 0, 130) | |
v = (159, 0, 255) | |
e = (0, 0, 0) | |
def getScrollImage(offset, image): | |
stride = int(len(image)/8) | |
if offset + 8 < stride: | |
line0 = image[offset+0*stride:offset+0*stride+8] | |
line1 = image[offset+1*stride:offset+1*stride+8] | |
line2 = image[offset+2*stride:offset+2*stride+8] | |
line3 = image[offset+3*stride:offset+3*stride+8] | |
line4 = image[offset+4*stride:offset+4*stride+8] | |
line5 = image[offset+5*stride:offset+5*stride+8] | |
line6 = image[offset+6*stride:offset+6*stride+8] | |
line7 = image[offset+7*stride:offset+7*stride+8] | |
else : | |
print ("not handling wrapping around yet") | |
line0 = image[0+0*stride:0+0*stride+8] | |
line1 = image[0+1*stride:0+1*stride+8] | |
line2 = image[0+2*stride:0+2*stride+8] | |
line3 = image[0+3*stride:0+3*stride+8] | |
line4 = image[0+4*stride:0+4*stride+8] | |
line5 = image[0+5*stride:0+5*stride+8] | |
line6 = image[0+6*stride:0+6*stride+8] | |
line7 = image[0+7*stride:0+7*stride+8] | |
output = line0 + line1 + line2 + line3+line4+line5+line6+line7 | |
return output | |
image = [ | |
e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e, | |
e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e, | |
e,e,i,e,e,e,e,e,e,e,e,o,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e, | |
e,e,i,e,e,e,e,e,e,e,e,o,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e, | |
e,e,i,e,e,e,e,e,o,o,o,o,o,o,o,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e, | |
e,e,i,e,e,e,e,e,e,e,e,o,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e, | |
e,e,i,e,e,e,e,e,e,e,e,o,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e, | |
e,e,i,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e, | |
] | |
offset = 0 | |
while True: | |
scrollimage=getScrollImage(offset,image) | |
sense.set_pixels(scrollimage) | |
x=input("+,- or q to quit") | |
if x=='+': | |
offset+=1 | |
if x == '-': | |
offset-=1 | |
if offset>=len(image)/8: | |
offset=0 | |
if offset<0: | |
offset = len(image)/8 -1 | |
if x=='q': | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment