Ejemplo n.º 1
0
from tree import RGBXmasTree
from colorzero import Hue
from random import random

tree = RGBXmasTree()
tree.brightness = 0.1


def random_color():
    r = random()
    g = random()
    b = random()
    return (r, g, b)


def random_colors(n):
    return [random_color() for i in range(n)]


while True:
    tree.value = random_colors(25)
Ejemplo n.º 2
0
from tree import RGBXmasTree
from colorzero import Color

tree = RGBXmasTree()
tree.brightness = 0.05
tree.color = Color('red')
Ejemplo n.º 3
0
from tree import RGBXmasTree
from colorzero import Color

tree = RGBXmasTree()
tree.brightness = 0.1

colors = [Color('red'), Color('green'), Color('blue')]  # add more if you like

while True:
    for color in colors:
        tree.color = color
Ejemplo n.º 4
0
from tree import RGBXmasTree
from colorzero import Color

tree = RGBXmasTree()

colors = [Color('red'), Color('green'), Color('blue')]  # add more if you like

try:
    while True:
        for color in colors:
            for pixel in tree:
                pixel.color = color
except KeyboardInterrupt:
    tree.close()
Ejemplo n.º 5
0
from tree import RGBXmasTree
from colorzero import Hue,Color
from random import random
from time import sleep
import time

tree = RGBXmasTree()
tree.brightness = 0.1
ShowFor = 60
Period = 1

def huecycle():
	tree.color = Color('red')

	timeout = time.time() + ShowFor
	while True:
		tree.color += Hue(deg=5)
		if time.time() > timeout:
			break;

def onebyone():
	colors = [Color('red'), Color('green'), Color('blue')] # add more if you like

	timeout = time.time() + ShowFor
	while True:
		for color in colors:
			for pixel in tree:
				pixel.color = color
		if time.time() > timeout:
			break;
Ejemplo n.º 6
0
from tree import RGBXmasTree
from time import sleep
import sys
from colorzero import Hue, Color
from random import randint, random, choice

tree = RGBXmasTree()
tree.brightness = 0.05


def red_to_blue(duration):
    hue = 1.0
    t = 0
    tree.color = Color.from_hsv(hue, 1.0, 0.5)
    while t < duration * 20:
        relt = t % 100
        if relt > 50:
            hue = 1.0 - ((100 - relt) / 50.0 * 0.4)
        else:
            hue = 1.0 - (relt / 50.0 * 0.4)
        tree.color = Color.from_hsv(hue, 1.0, 0.5)
        t = t + 1
        sleep(0.05)


def classical(duration):
    t = 0
    while (t < duration / 2):
        colors = []
        for i in range(len(tree)):
            colors.append(
Ejemplo n.º 7
0
#!/usr/bin/env python3
# XmasTree_WhichLEDIsWhich.py
# Helps identify which LED is which number - to aid development of patterns
# Running this code produces a grid window with 25 buttons - click each number
# to light up the corresponding LED.
from tree import RGBXmasTree
from tkinter import *
from functools import partial

# Instance the  RGBXmasTree
tree = RGBXmasTree(brightness=0.05)
tree.off()  # Start with all lights off


def flashLED(i):
    tree.off()  # Turn all other LEDs off
    tree[i].color = (1, 1, 1)  # Light up respective LED
    print('LED ', i)  # Print out result


master = Tk()
canvas = Canvas(master)
i = 0  # Note there are 25 LEDs on tree
for c in range(5):
    for r in range(5):
        button = Button(0)
        button.configure(text=i)
        button.configure(command=partial(flashLED, i))
        button.grid(row=r, column=c)
        i += 1
Ejemplo n.º 8
0
from time import sleep
from datetime import datetime
from tree import RGBXmasTree
from colorzero import Color
import random
import os
import signal

BRIGHTNESS = (int(os.environ["BRIGHTNESS"]) /
              100) if "BRIGHTNESS" in os.environ else 0.08
DELAY = float(os.environ["DELAY"]) if "DELAY" in os.environ else 0.5
STARTTIME = os.environ["STARTTIME"] if "STARTTIME" in os.environ else "0000"
STOPTIME = os.environ["STOPTIME"] if "STOPTIME" in os.environ else "2359"

tree = RGBXmasTree(brightness=BRIGHTNESS)


def random_color():
    colors = [
        Color('red'),
        Color('green'),
        Color('blue'),
        Color('yellow'),
        Color('purple')
    ]
    color = random.choice(colors)
    return color


class GracefulKiller:
    kill_now = False
Ejemplo n.º 9
0
from tree import RGBXmasTree
from colorzero import Color
from time import sleep

tree = RGBXmasTree()
tree.brightness = 0.05
#tree.color = Color('red')

colors = [Color('red'), Color('green'), Color('blue')]

try:
    while True:
        for color in colors:
            #tree.color = color
            for pixel in tree:
                #pixel.on()
                pixel.color = color
                #print pixel.color
                #sleep(1)
except KeyboardInterrupt:
    tree.close()
from guizero import App, Combo, Text, CheckBox, ButtonGroup, PushButton, info, Slider, TextBox, Window, ListBox
from tree import RGBXmasTree
from colorzero import Color
from time import sleep
import random
import keyboard

tree = RGBXmasTree()
y = 0


def random_color():
    r = random.random()
    g = random.random()
    b = random.random()
    return (r, g, b)


def brightness():
    tree.brightness = 0
    tree.on()
    tree.brightness = listbox.value


def length():
    n = slider.value


def run_tree():
    #t=0
    #n=t
Ejemplo n.º 11
0
#!/usr/bin/env python3

import argparse
from tree import RGBXmasTree
from time import sleep
from colorzero import Color, Hue

tree = RGBXmasTree()

tree.color = Color("red")

parser = argparse.ArgumentParser()
parser.add_argument("brightness",
                    help="brightness for all LEDs",
                    type=float,
                    default=0.1,
                    nargs="?")
parser.add_argument(
    "degrees",
    help="degrees of hue separation between steps",
    type=int,
    default=25,
    nargs="?",
)
args = parser.parse_args()

tree.brightness = args.brightness

try:
    while True:
        for count in range(32):
Ejemplo n.º 12
0
from tree import RGBXmasTree
from colorzero import Color, Hue

tree = RGBXmasTree()

tree.color = Color('red')

try:
    while True:
        tree.color += Hue(deg=1)
except KeyboardInterrupt:
    tree.close()
Ejemplo n.º 13
0
#!/usr/bin/env python3
# XmasTree_Swirl.py
# Multi-pattern designs
from tree import RGBXmasTree
from colorzero import Color
from time import sleep

# generate random floating point values
from random import random
from random import choice

# Instance the  RGBXmasTree
tree = RGBXmasTree(brightness=0.05)
# Named ranges
TOP_LED = 3
SPIRAL = [12,6,15,16,0,7,19,24,11,5,14,17,1,8,20,23,10,4,13,18,2,9,21,22,3]
LAYERS = [[12,6,15,16,0,7,19,24],[11,5,14,17,1,8,20,23],[10,4,13,18,2,9,21,22]]
ROTATE = [[12,11,10],[6,5,4],[15,14,13],[16,17,18],[0,1,2],[7,8,9],[19,20,21],[24,23,22]]
colors = [Color('cyan'), Color('red'), Color('purple'), Color('white'), Color('green'),
  Color('blue'), Color('yellow'), Color('magenta')]

# Function to return a random colour
def random_color():
    h = random()
    s = 1
    v = 1
    hsv = Color.from_hsv(h,s,v)
    rgb = hsv.rgb
    #
    return (rgb)
Ejemplo n.º 14
0
import argparse
from time import sleep
from tree import RGBXmasTree
from colorzero import Color

tree = RGBXmasTree(auto_update=False)

# create lists of tree pixel offsets for each row
bottom_row = [0, 6, 19, 24, 6, 12, 15, 16, 7]
middle_row = [1, 5, 20, 23, 5, 11, 14, 17, 8]
top_row = [2, 4, 21, 22, 4, 10, 13, 18, 9]
star = [3]

# list of rows in order from bottom to top
order = [bottom_row, middle_row, top_row, star]

# provide CLI parametes
parser = argparse.ArgumentParser(
    description="Colours flow up the RGB Xmas tree "
    "https://thepihut.com/products/3d-rgb-xmas-tree-for-raspberry-pi"
    " https://github.com/gilesknap/raspitree")
parser.add_argument("--brightness",
                    help="brightness for all LEDs",
                    type=float,
                    default=0.1)
parser.add_argument("--degrees",
                    help="hue separation between each row",
                    type=int,
                    default=80)
parser.add_argument("--pause",
                    help="pause after update in secs",
Ejemplo n.º 15
0
# Set ALL LEDs to same colour using list, set top LED white
from tree import RGBXmasTree
from colorzero import Color
from time import sleep

# generate random floating point values
from random import seed
from random import random
# seed random number generator
seed(1)

# Set to LED number for top of Xmas Tree. LEDs are numbered 0-24.
TOP_LED = 3

# Instance the  RGBXmasTree
tree = RGBXmasTree(brightness=0.05)

colors = [
    Color('cyan'),
    Color('yellow'),
    Color('purple'),
    Color('red'),
    Color('green'),
    Color('blue'),
    Color('magenta')
]  # add more if you like, see https://www.rapidtables.com/web/color/RGB_Color.html#color-table.

# main loop
try:
    while True:
        for color in colors:
Ejemplo n.º 16
0
from tree import RGBXmasTree
from colorzero import Color
from time import sleep

tree = RGBXmasTree()

colors = [Color('red'), Color('green'), Color('blue')] # add more if you like

try:
    while True:
        for color in colors:
            tree.color = color
            sleep(1)
except KeyboardInterrupt:
    tree.close()