Beispiel #1
0
except ImportError:
    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
Beispiel #2
0
import time
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
 def __init__(self, rotation, brightness):
     rainbow.set_layout(rainbow.PHAT)
     rainbow.rotation(rotation)
     rainbow.brightness(brightness)
     self.width, self.height = rainbow.get_shape()