Skip to content

Instantly share code, notes, and snippets.

@romeokienzler
Created June 27, 2016 13:43
Show Gist options
  • Save romeokienzler/37af48279469c4e7a5052e07125d37a7 to your computer and use it in GitHub Desktop.
Save romeokienzler/37af48279469c4e7a5052e07125d37a7 to your computer and use it in GitHub Desktop.
import numpy as np
import sys
'''
Created on Apr 8, 2016
@author: romeokienzler
'''
class SenseHat():
index = 0
leftValid = [10,18,26,34,42,50,9,17,25]
rightValid = [14,22,30,38,46,54,13,21,29]
R = [255, 0, 0] # Red
W = [255, 255, 255] # White
G = [0, 255, 0] # Green
def __init__(self):
pass
#Ensure nothing is set which is not allowed to
def ensureBlank(self,pixelMap):
pass
def extractNumber(self,pixelMap):
pixelNumber = (sum(map(lambda a : a[0]&a[1]&a[2],pixelMap[self.leftValid]==self.W))*10)+sum(map(lambda a : a[0]&a[1]&a[2],pixelMap[self.rightValid]==self.W))
#print(map(lambda a : a[0]&a[1]&a[2],pixelMap[self.leftValid]==self.W))
#print(pixelMap[self.leftValid]==self.R)
#print(pixelMap[self.leftValid])
if (pixelNumber == 20) | (pixelNumber == 30):
pass
else:
sys.exit(2)
def set_pixels(self,pixelMap):
pm = np.array(pixelMap)
self.extractNumber(pm)
def get_temperature(self):
self.index = self.index + 1
if self.index % 7 == 0:
return 30.3
else:
return 20.3
def clear(self):
pass
def get_humidity(self):
return 60.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment