from sys import exit try: import glib except ImportError: exit("This script requires the glib module") try: import gudev except ImportError: exit("This script requires the gudev module") import rainbowhat as rainbow rainbow.set_layout(rainbow.HAT) rainbow.rotation(0) rainbow.brightness(0.5) sin_off = [[0] * 8 for i in range(8)] for y in range(8): for x in range(8): sin_off[x][y] = random.random() * (math.pi * 2) tick_mask = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 1, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] steps_per = 16
import rainbowhat as uh import time from random import randint uh.rotation(0) uh.brightness(0.5) heights = [] def setup(): global heights heights = [] for b in range(0, 6): heights.append(0) uh.off() for b in range(0, 8): uh.set_pixel(0, b, 255, 255, 255) for b in range(0, 8): uh.set_pixel(7, b, 255, 255, 255) for b in range(1, 7): uh.set_pixel(b, 0, 255, 255, 255) uh.show() def drop_ball(): ball_colour = [randint(100, 255), randint(100, 255), randint(100, 255)] ball_column = randint(0, 5) while heights[ball_column] == 7:
#!/usr/bin/env python import time from random import randint import rainbowhat as rainbow print("""Matrix Follow the white rabbit... """) rainbow.set_layout(rainbow.HAT) rainbow.rotation(90) rainbow.brightness(0.5) wrd_rgb = [[154, 173, 154], [0, 255, 0], [0, 200, 0], [0, 162, 0], [0, 145, 0], [0, 96, 0], [0, 74, 0], [ 0, 0, 0, ]] clock = 0 blue_pilled_population = [[randint(0, 7), 7]] while True: for person in blue_pilled_population: y = person[1] for rgb in wrd_rgb: if (y <= 7) and (y >= 0):
exit( "This script requires the numpy module\nInstall with: sudo pip install numpy" ) import rainbowhat as rainbow print("""Rainbow Blinky Blinks a rainbow from the center of the display. If you're using a Rainbow HAT and only half the screen lights up, edit this example and change 'rainbow.AUTO' to 'rainbow.HAT' below. """) rainbow.set_layout(rainbow.AUTO) rainbow.rotation(0) # tested on pHAT/HAT with rotation 0, 90, 180 & 270 rainbow.brightness(0.5) width, height = rainbow.get_shape() if height == width: delta = 0 else: delta = 2 def make_gaussian(fwhm): x = numpy.arange(0, 8, 1, float) y = x[:, numpy.newaxis] x0, y0 = 3.5, 3.5 fwhm = fwhm gauss = numpy.exp(-4 * numpy.log(2) * ((x - x0)**2 + (y - y0)**2) /
def __init__(self, rotation, brightness): rainbow.set_layout(rainbow.PHAT) rainbow.rotation(rotation) rainbow.brightness(brightness) self.width, self.height = rainbow.get_shape()