Exemplo n.º 1
0
def main():
    port = ser2neo.open_port('/dev/ttyUSB0')
    neo = ser2neo.NeoPixels(port)

    random.seed()
    dt = 0.02 + random.random() * 0.02
    gain = 0.05
    at = 1
    run = 0

    while dt < 0.4:
        neo.clear()
        for i in range(0, at):
            neo.set(angle2idx(neo, i, at) + run, ser2neo.Colour.Red)

        neo.send()
        neo.wait()

        at += 1
        if at == 7:
            at = 1
        # Also rotate the dice to make it look nicer.
        run += 1

        time.sleep(dt)
        # Slowly bring the dice to a stop.
        dt += dt * gain

    time.sleep(2)
Exemplo n.º 2
0
def main():
    port = ser2neo.open_port("/dev/ttyUSB0")
    neo = ser2neo.NeoPixels(port)

    random.seed()
    dt = 0.02 + random.random() * 0.02
    gain = 0.05
    at = 1
    run = 0

    while dt < 0.4:
        neo.clear()
        for i in range(0, at):
            neo.set(angle2idx(neo, i, at) + run, ser2neo.Colour.Red)

        neo.send()
        neo.wait()

        at += 1
        if at == 7:
            at = 1
        # Also rotate the dice to make it look nicer.
        run += 1

        time.sleep(dt)
        # Slowly bring the dice to a stop.
        dt += dt * gain

    time.sleep(2)
Exemplo n.º 3
0
def main():
    port = ser2neo.open_port('/dev/ttyUSB0')
    neo = ser2neo.NeoPixels(port)

    offset = 0
    anim = ser2neo.Animator()
    while anim.run_for(5):
        neo.clear()

        for i in range(neo.nleds):
            hue = offset + i / neo.nleds
            hue %= 1.0
            neo.set(i, ser2neo.RGB(*colorsys.hsv_to_rgb(hue, 1, 0.1)))

        offset += 0.003
        neo.send()
        neo.wait()
Exemplo n.º 4
0
def main():
    port = ser2neo.open_port('/dev/ttyUSB0')
    neo = ser2neo.NeoPixels(port)

    at = 0
    anim = ser2neo.Animator()
    while anim.run_for(5):
        neo.clear()
        neo.set(at, ser2neo.Colour.Green)
        neo.set(at - 1, ser2neo.Colour.Green / 4)
        neo.set(at - 2, ser2neo.Colour.Green / 16)

        neo.set(at + neo.nleds / 2, ser2neo.Colour.Green)
        neo.set(at + neo.nleds / 2 - 1, ser2neo.Colour.Green / 4)
        neo.set(at + neo.nleds / 2 - 2, ser2neo.Colour.Green / 16)

        at += 1
        neo.send()
        neo.wait()

        time.sleep(0.05)
Exemplo n.º 5
0
def main():
    port = ser2neo.open_port('/dev/ttyUSB0')
    neo = ser2neo.NeoPixels(port)

    at = 0
    anim = ser2neo.Animator()
    while anim.run_for(5):
        neo.clear()
        neo.set(at, ser2neo.Colour.Green)
        neo.set(at - 1, ser2neo.Colour.Green / 4)
        neo.set(at - 2, ser2neo.Colour.Green / 16)

        neo.set(at + neo.nleds / 2, ser2neo.Colour.Green)
        neo.set(at + neo.nleds / 2 - 1, ser2neo.Colour.Green / 4)
        neo.set(at + neo.nleds / 2 - 2, ser2neo.Colour.Green / 16)

        at += 1
        neo.send()
        neo.wait()

        time.sleep(0.05)
Exemplo n.º 6
0
def main():
    port = ser2neo.open_port("/dev/ttyUSB0")
    neo = ser2neo.NeoPixels(port)

    p0 = 0
    p1 = 5

    anim = ser2neo.Animator()
    while anim.run_for(5):
        neo.clear()
        neo.set(p0, ser2neo.Colour.Red)
        neo.set(p0 + 1, ser2neo.Colour.Red / 4)
        neo.set(p0 + 2, ser2neo.Colour.Red / 16)
        p0 -= 0.5

        neo.set(p1, ser2neo.Colour.Blue)
        neo.set(p1 - 1, ser2neo.Colour.Blue / 4)
        neo.set(p1 - 2, ser2neo.Colour.Blue / 16)
        p1 += 0.2

        neo.send()
        neo.wait()
Exemplo n.º 7
0
def main():
    port = ser2neo.open_port('/dev/ttyUSB0')
    neo = ser2neo.NeoPixels(port)

    anim = ser2neo.Animator()
    while anim.run_for(5):
        now = datetime.datetime.now()

        neo.clear()
        neo.set(angle2idx(neo, now.hour, 12), ser2neo.Colour.Blue)
        neo.set(angle2idx(neo, now.minute, 60), ser2neo.Colour.Red)

        # The quarter-hour ticks.
        top = ser2neo.Colour.Purple / 10
        mark = top / 4
        neo.set(angle2idx(neo, 0, 360), top)
        neo.set(angle2idx(neo, 90, 360), mark)
        neo.set(angle2idx(neo, 180, 360), mark)
        neo.set(angle2idx(neo, 270, 360), mark)

        neo.send()
        neo.wait()
        time.sleep(1)
Exemplo n.º 8
0
def main():
    port = ser2neo.open_port('/dev/ttyUSB0')
    neo = ser2neo.NeoPixels(port)

    anim = ser2neo.Animator()
    while anim.run_for(5):
        now = datetime.datetime.now()

        neo.clear()
        neo.set(angle2idx(neo, now.hour, 12), ser2neo.Colour.Blue)
        neo.set(angle2idx(neo, now.minute, 60), ser2neo.Colour.Red)

        # The quarter-hour ticks.
        top = ser2neo.Colour.Purple / 10
        mark = top / 4
        neo.set(angle2idx(neo, 0, 360), top)
        neo.set(angle2idx(neo, 90, 360), mark)
        neo.set(angle2idx(neo, 180, 360), mark)
        neo.set(angle2idx(neo, 270, 360), mark)

        neo.send()
        neo.wait()
        time.sleep(1)