예제 #1
0
def setBrightness(currenttime):
    currenthour = currenttime.tm_hour
    # if it's between 10 am and 8 pm,
    # use dimmer brightness
    if (currenthour < 10 or currenthour > 20):
        rainbow.brightness(0.5)
    else:
        rainbow.brightness(0.8)
예제 #2
0
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 background(x, y, step):
예제 #3
0
파일: drop.py 프로젝트: zoerab/Rainbow-HAT
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:
예제 #4
0
파일: test.py 프로젝트: zoerab/Rainbow-HAT
#!/usr/bin/env python

import time

import rainbowhat as rainbow

print("""Simple

Turns each pixel on in turn and updates 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.HAT)
#rainbow.set_layout(rainbow.AUTO)
rainbow.rotation(0)
rainbow.brightness(0.3)
width, height = rainbow.get_shape()

for y in range(height):
    for x in range(width):
        rainbow.set_pixel(x, y, 0, 0, 254)
        rainbow.show()
        time.sleep(0.05)

time.sleep(1)
예제 #5
0
#!/usr/bin/env python

import rainbowhat as rainbow
import time, colorsys
import numpy as np
import random

rainbow.brightness(0.4)


def make_gaussian(fwhm, x0, y0):
    x = np.arange(0, 8, 1, float)
    y = x[:, np.newaxis]
    fwhm = fwhm
    gauss = np.exp(-4 * np.log(2) * ((x - x0)**2 + (y - y0)**2) / fwhm**2)
    return gauss


while True:
    x0 = random.random() * 8
    y0 = random.random() * 8
    h = random.random()
    for z in range(1, 5)[::-1] + range(1, 10):
        fwhm = 5.0 / z
        gauss = make_gaussian(fwhm, x0, y0)
        for y in range(8):
            for x in range(8):
                s = 0.8
                v = gauss[x, y]
                rgb = colorsys.hsv_to_rgb(h, s, v)
                r = int(rgb[0] * 255.0)
예제 #6
0
#!/usr/bin/env python

import rainbowhat as rainbow
from random import randint
import time

rainbow.brightness(0.20)
rainbow.rotation(90)

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):
                rainbow.set_pixel(person[0], y, rgb[0], rgb[1], rgb[2])
            y += 1
        person[1] -= 1
    rainbow.show()
    time.sleep(0.1)
    clock += 1
    if clock % 5 == 0:
예제 #7
0
파일: demo.py 프로젝트: zoerab/Rainbow-HAT
import rainbowhat as rainbow

print("""Demo

This pixel shading demo transitions between 4 classic graphics demo effects.

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.set_layout(rainbow.HAT)
rainbow.rotation(0)  # tested on pHAT/HAT with rotation 0, 90, 180 & 270
#rainbow.brightness(0.4)
rainbow.brightness(1.0)
u_width, u_height = rainbow.get_shape()


# twisty swirly goodness
def swirl(x, y, step):
    x -= (u_width / 2)
    y -= (u_height / 2)

    dist = math.sqrt(pow(x, 2) + pow(y, 2)) / 2.0
    angle = (step / 10.0) + (dist * 1.5)
    s = math.sin(angle)
    c = math.cos(angle)

    xs = x * c - y * s
    ys = x * s + y * c
예제 #8
0
 def __init__(self, rotation, brightness):
     rainbow.set_layout(rainbow.PHAT)
     rainbow.rotation(rotation)
     rainbow.brightness(brightness)
     self.width, self.height = rainbow.get_shape()