コード例 #1
0
ファイル: effect.py プロジェクト: acolomba/ledstrip
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)
コード例 #2
0
ファイル: effect.py プロジェクト: acolomba/ledstrip
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
コード例 #3
0
ファイル: effect.py プロジェクト: acolomba/ledstrip
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
コード例 #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)