Exemplo n.º 1
0
#-*- coding:utf-8 -*-
from __future__ import division
from lampapp import LampApp

from lampapp.ledpixels import Color
from lampapp.wiimote import BTN_A

app = LampApp()
app.activate_wiimote()
app.wiimote.enable_acc()

couleur = None
i = None

def acc_to_color():
    acc = [app.wiimote.get_acc_x(), app.wiimote.get_acc_y(), app.wiimote.get_acc_z()]
    acc = [min(255, max(0, (val-90)*3)) for val in acc]
    return Color(*acc)

@app.setup()
def setup():
    global couleur
    couleur = Color(255, 0, 0)

@app.every(0.1)
def every():
    global couleur, i
    couleur = acc_to_color()
    app.lamp.turn_on(color=couleur)
    #for i in range(1, 26):
    #    app.lamp.turn_on(i, couleur)
Exemplo n.º 2
0
#-*- coding:utf-8 -*-
from __future__ import division

from lampapp import LampApp
from lampapp.ledpixels import Color

colorTop = None
ColorBot = None
i = None

app = LampApp()

@app.every(2)
def every():
    global colorTop, ColorBot, i
    colorTop = Color.random()
    ColorBot = Color.random()
    for i in range(1, 26):
        app.lamp.turn_on(i, Color.blend(colorTop, ColorBot, i / 24))


if __name__ == "__main__":
    app.run()
Exemplo n.º 3
0
#-*- coding:utf-8 -*-
from __future__ import division

from lampapp import LampApp
from lampapp.ledpixels import Color

colorTop = None
ColorBot = None
i = None

app = LampApp()


@app.every(2)
def every():
    global colorTop, ColorBot, i
    colorTop = Color.random()
    ColorBot = Color.random()
    for i in range(1, 58):
        app.lamp.turn_on(i, Color.blend(colorTop, ColorBot, i / 24))
        app.wait((100) / 1000.)


if __name__ == "__main__":
    app.run()
Exemplo n.º 4
0
#-*- coding:utf-8 -*-
import time
from random import randint, gauss
from colorsys import hls_to_rgb

from lampapp import LampApp
from hardware.lamp import Color  #FIXME odd import..

app = LampApp()
app.need("lamp")
app.need("volume")


def randColor(light, sat, mu=0.3, sigma=0.06):
    hue = gauss(mu, sigma)
    c = [hue % 1, light, sat]
    c = [int(255 * val) for val in hls_to_rgb(*c)]
    return Color(*c)


@app.setup()
def setup():
    global on, count, saturation, light, colors
    on = False
    count = 0

    #colorsys.hls_to_rgb(h, l, s)
    saturation = 0.7
    light = 0.3

    colors = [
Exemplo n.º 5
0
#-*- coding:utf-8 -*-
from lampapp import LampApp
from ledpixels import Color

app = LampApp()
app.need("lamp")


@app.setup()
def setup():
    global on, count, position, sens, period, colors

    on = False
    count = 0
    position = [1, 20, 6, 15]
    sens = [1, -1, 1, -1]
    period = [14, 6, 25, 60]

    colors = [
        Color(202, 12, 105),
        Color(250, 200, 12),
        Color(12, 248, 15),
        Color(12, 127, 100),
    ]


@app.every(0.01)
def loop():
    global on, count, position, sens, period, colors
    # msg every 10 blink
Exemplo n.º 6
0
#-*- coding:utf-8 -*-
from lampapp import LampApp
from ledpixels import Color

app = LampApp()
app.need("lamp")

@app.setup()
def setup():
    global on, count, position, sens, period, colors
    
    on = False
    count = 0
    position = [1, 20, 6, 15]
    sens = [1, -1, 1, -1]
    period = [14, 6, 25, 60]
    
    colors = [
        Color(202,  12, 105),
        Color(250,  200, 12),
        Color(12,  248, 15),
        Color(12,  127, 100),
    ]
    
@app.every(0.01)
def loop():
    global on, count, position, sens, period, colors
    # msg every 10 blink
    
    count += 1
    app.lamp.off()
Exemplo n.º 7
0
#-*- coding:utf-8 -*-
from __future__ import division
from lampapp import LampApp

from lampapp.ledpixels import Color
from lampapp.wiimote import BTN_UP, BTN_DOWN

app = LampApp()
app.need("wiimote")
app.wiimote.enable_acc()

i = 1


@app.wiimote.pressed(BTN_UP)
def up():
    global i
    i = min(32, i + 1)


@app.wiimote.pressed(BTN_DOWN)
def down():
    global i
    i = max(1, i - 1)


@app.setup()
def setup():
    global couleur
    couleur = Color(255, 0, 0)
Exemplo n.º 8
0
#-*- coding:utf-8 -*-
from __future__ import division
from lampapp import LampApp

from lampapp.ledpixels import Color
from lampapp.wiimote import BTN_UP, BTN_DOWN

app = LampApp()
app.need("wiimote")
app.wiimote.enable_acc()

i = 1

@app.wiimote.pressed(BTN_UP)
def up():
    global i
    i = min(32, i+1)

@app.wiimote.pressed(BTN_DOWN)
def down():
    global i
    i = max(1, i-1)

@app.setup()
def setup():
    global couleur
    couleur = Color(255, 0, 0)

@app.every(0.1)
def every():
    global couleur, i
Exemplo n.º 9
0
#-*- coding:utf-8 -*-
import time
from random import randint, gauss
from colorsys import hls_to_rgb

from lampapp import LampApp
from hardware.lamp import Color #FIXME odd import..

app = LampApp()
app.need("lamp")
app.need("volume")

def randColor(light, sat, mu=0.3, sigma=0.06):
    hue = gauss(mu, sigma)
    c = [hue%1,  light, sat]
    c = [int(255*val) for val in hls_to_rgb(*c)]
    return  Color(*c)

@app.setup()
def setup():
    global on, count, saturation, light, colors
    on = False
    count = 0

    #colorsys.hls_to_rgb(h, l, s)
    saturation = 0.7
    light = 0.3
    
    colors = [ randColor(light, saturation, mu=0) for _ in range(0, app.lamp.nb_pixel) ]