Beispiel #1
0
def pulseEffect(duration, brightness = None):
    """
    pulses a random color over the given duration
    @param duration: duration of a full pulse in seconds
    @param brightness: brightness of the transition colors
    """
    with ledstrip.ledstrip() as ls:
        src = (0, 0, 0)

        while True:
            dst = randomColor(brightness = brightness)
            transitionAll(ls, src, dst, duration / 2.0)
            transitionAll(ls, dst, src, duration / 2.0)
Beispiel #2
0
def xtreeEffect(duration, brightness = None):
    """
    pulses each individual light from black to a random color
    and back over the given duration
    @param duration: duration of a full pulse in seconds
    @param brightness: brightness of the transition colors
    """
    with ledstrip.ledstrip() as ls:
        src = [randomColor(brightness = brightness) for _l in range(ledstrip.NLIGHTS)]

        while True:
            dst = [randomColor(brightness = brightness) for _l in range(ledstrip.NLIGHTS)]
            transition(ls, src, dst, duration)
            src = dst
Beispiel #3
0
def lavaEffect(duration, brightness = None):
    """
    Produces a lava lamp-like effect by transitioning the whole strip from a random
    color to another random color, and then from the latter to another random color,
    and so forth. Each transition is carried on over the given duration.
    @param duration: duration of a single transition in seconds
    @param brightness: brightness of the transition colors
    """
    with ledstrip.ledstrip() as ls:
        src = randomColor(saturation = 1.0, brightness = brightness)

        while True:
            dst = randomColor(saturation = 1.0, brightness = brightness)
            transitionAll(ls, src, dst, duration)
            src = dst
Beispiel #4
0
from flask import Flask, render_template, redirect, jsonify
from ledstrip import ledstrip

app = Flask(__name__)
leds = ledstrip()


@app.route('/')
def homepage():
    return render_template('index.html')


@app.route('/on', methods=['POST', 'GET'])
def on():
    print('On')
    leds.on()
    return jsonify(result="On")


@app.route('/off', methods=['POST', 'GET'])
def off():
    print('Off')
    leds.off()
    return jsonify(result="Off")


@app.route('/setcolor/<color>', methods=['POST', 'GET'])
def setColor(color):
    leds.set_color(color)
    print("Color: {}".format(color))
    return jsonify(result=color)