Skip to content

Instantly share code, notes, and snippets.

@buxtonpaul
Created July 4, 2017 12:47
Show Gist options
  • Save buxtonpaul/0625f3f9be0ec6add0229cce9d28447d to your computer and use it in GitHub Desktop.
Save buxtonpaul/0625f3f9be0ec6add0229cce9d28447d to your computer and use it in GitHub Desktop.
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