from colorsys import hsv_to_rgb import random import numpy as np import os if os.access("/dev/spidev1.0", os.R_OK | os.W_OK): from LedMatrix_ws2803 import LedMatrix #from LedMatrix_n5110 import LedMatrix else: from LedMatrix_pygame import LedMatrix #from LedMatrix_ascii import LedMatrix print "TEST BEGINNING" SIZE = (29, 6) lm = LedMatrix(SIZE) fb = Image.new('RGB', SIZE, (0, 0, 0)) class DemoText: text = 'RedMountainMakers' textSpeed = 10.0 backdropSpeed = 27.0 font = None gradient = None backdrop = None def __init__(self, fb): self.font = ImageFont.load('6by6tall.pil')
response = urlopen(url) json_obj = load(response) print "the story is" + str(json_obj) text = "" for story in json_obj['list']['story']: text += story['title']['$text'].upper() + " " textSpeed = 15.0 frameRate = 100.0 backdropSpeed = 27.0 lm = LedMatrix(SIZE) fb = Image.new('RGB', SIZE, (0,0,0)) font = ImageFont.load('6by6tall.pil') textSize = font.getsize(text) textimg = Image.new('RGB', (textSize[0] + 2, textSize[1]), (0,0,0)) textdraw = ImageDraw.Draw(textimg) textdraw.text((0, 0), text, font=font, fill=(255, 255, 255)) gradient = np.ndarray(shape=(SIZE[1], SIZE[0], 3), dtype='uint8') colnorm = 1.0 / (SIZE[0] - 1.0) rownorm = 1.0 / (SIZE[1] - 1.0) for row in range(0, SIZE[1]): nrow = row * rownorm for col in range(0, SIZE[0]): ncol = col * colnorm
import math import os if os.access("/dev/spidev1.0", os.R_OK|os.W_OK): from LedMatrix_ws2803 import LedMatrix #from LedMatrix_n5110 import LedMatrix else: from LedMatrix_pygame import LedMatrix #from LedMatrix_ascii import LedMatrix SIZE = (29, 6) frameRate = 15.0 lm = LedMatrix(SIZE) fb = Image.new('RGB', SIZE, (0,0,0)) x_steps = 15 # steps for one full wave (in pixels) y_steps = SIZE[1] sin_table = [[(0, 0, 0) for y in range(y_steps)] for x in range(x_steps)] colors = [ (0, 0, 0), (0, 255, 0), (255, 255, 0), (255, 0, 0), (255, 0, 0), (255, 0, 0), (255, 0, 0), (255, 0, 0)
def enum(*sequential, **named): enums = dict(zip(sequential, range(len(sequential))), **named) return type('Enum', (), enums) SIZE = (29, 6) hueSpeed = 30.0 hueColSkew = 210.0 hueRowSkewMax = 25.0 hueRowSkewSpeed = 7.0 frameRate = 60.0 lm = LedMatrix(SIZE) fb = Image.new('RGB', SIZE, (0, 0, 0)) stickPos = { "x": 0, "y": 0 } playerPos = { "x": 0, "y": 0 } pHist = [(0, 0)]