Example #1
0
    "00FF00",  # green
    "0000FF",  # blue
    "FFFF00",  # yellow
    "00FFFF",  # cyan
    "FF00FF",  # magenta
    "FF8000",  # orange
    "8000FF",  # purple
    "0080FF",  # light blue
    "FF0080",  # pink
)

color = PALETTE[0]

enabled = {zone: False for zone in range(6)}

api = vibrance.Interface("Keypad Simple")


def recompute():
    global color, enabled
    for zone in enabled:
        if enabled[zone]:
            api.color(zone, color)
        else:
            api.color(zone, "000")


@api.on("keypad", "letter")
def onLetter(event):
    key = event["key"]
    global color
Example #2
0
import math
import time

import vibrance

api = vibrance.Interface("Fadetest")


def getColor(radians):
    red = 0x80 + int(0x79*math.sin(radians))
    green = 0x80 + int(0x79*math.sin(radians+math.pi*2/3))
    blue = 0x80 + int(0x79*math.sin(radians+math.pi*4/3))
    return f"{format(red, '02x')}{format(green, '02x')}{format(blue, '02x')}"


@api.onTelemetry
def onTelemetry(telemetry):
    print(telemetry)


frame = 0


@api.loop
def mainloop():
    global frame
    api.clear()
    for i in range(20):
        api.add(0, getColor(frame/50), delay=i*50)
        api.add(1, getColor(frame/50+math.pi*1/3), delay=i*50)
        api.add(2, getColor(frame/50+math.pi*2/3), delay=i*50)
Example #3
0
)

ZONEMAP = (
    (1, 0, 0, 0, 0, 0),  # oct -2
    (0, 1, 0, 0, 0, 0),  # oct -1
    (0, 0, 1, 0, 0, 0),  # oct 0
    (0, 0, 0, 1, 0, 0),  # oct 1
    (0, 0, 0, 0, 1, 0),  # oct 2
    (0, 0, 0, 0, 0, 1),  # oct 3
    (1, 1, 1, 1, 1, 1),  # oct 4
    (1, 0, 0, 1, 0, 0),  # oct 5
    (0, 1, 0, 0, 1, 0),  # oct 6
    (0, 0, 1, 0, 0, 1),  # oct 7
)

api = vibrance.Interface("Simple MIDI")


@api.on("midi", "note_on")
def test(event):
    print(event)
    if event["type"] == "note_on":
        octNote = event["note"] % 12
        octave = event["note"] // 12

        if octave > 9:
            return  # Reserved for future use

        color = PALETTE[octNote]
        zones = ZONEMAP[octave]
Example #4
0
    "FFFFFF",  # white
    "FF0000",  # red
    "00FF00",  # green
    "0000FF",  # blue
    "FFFF00",  # yellow
    "00FFFF",  # cyan
    "FF00FF",  # magenta
    "FF8000",  # orange
    "8000FF",  # purple
    "0080FF",  # light blue
    "FF0080",  # pink
)

ZONES = list(range(6))

api = vibrance.Interface("MIDI Animations")


@api.on("midi", "note_on_oct_-2")
def cycle(event):
    i = event["note"] % 12

    api.color((0, 3), PALETTE[i])
    api.color((1, 2, 4, 5), "000")
    api.wait(0.5)

    api.color((1, 4), PALETTE[i])
    api.color((0, 2, 3, 5), "000")
    api.wait(0.5)

    api.color((2, 5), PALETTE[i])
Example #5
0
    "FFFFFF",  # white
    "FF0000",  # red
    "00FF00",  # green
    "0000FF",  # blue
    "FFFF00",  # yellow
    "00FFFF",  # cyan
    "FF00FF",  # magenta
    "FF8000",  # orange
    "8000FF",  # purple
    "0080FF",  # light blue
    "FF0080",  # pink
)

ZONES = list(range(6))

api = vibrance.Interface("QWERTY Animations")

CYCLE_KEYS = ("q", "w", "e", "r", "t", "y", "u")
CHASE_KEYS = ("a", "s", "d", "f", "g", "h", "j")
EXPAND_KEYS = ("z", "x", "c", "v", "b", "n", "m")

BPM = 122 / 2

BEAT_TIME = 60 / BPM

@api.on("pygame", "keydown")
def keydown(event):
    key = event["key"]
    if key == ord(" "):
        clear()
    elif chr(key) in CYCLE_KEYS:
Example #6
0
)

ZONEMAP = (
    (1, 0, 0, 0, 0, 0),  # oct -2
    (0, 1, 0, 0, 0, 0),  # oct -1
    (0, 0, 1, 0, 0, 0),  # oct 0
    (0, 0, 0, 1, 0, 0),  # oct 1
    (0, 0, 0, 0, 1, 0),  # oct 2
    (0, 0, 0, 0, 0, 1),  # oct 3
    (1, 1, 1, 1, 1, 1),  # oct 4
    (1, 0, 0, 1, 0, 0),  # oct 5
    (0, 1, 0, 0, 1, 0),  # oct 6
    (0, 0, 1, 0, 0, 1),  # oct 7
)

api = vibrance.Interface("16 Colors")


@api.on("midi", "note_on")
def test(event):
    print(event)
    if event["type"] == "note_on":
        octNote = event["note"] % 12
        octave = event["note"] // 12

        if octave > 9:
            return  # Reserved for future use

        color = PALETTE[octNote]
        zones = ZONEMAP[octave]
Example #7
0
import math
import time

import vibrance

api = vibrance.Interface("Fading and Flashing")

MODE = 0
RADIANS = 0
FRAME = 0

UPDATE_INTERVAL = 2
BPM = 122
BEAT_TIME = 60 / BPM

PALETTE = ("FF8000", "00FF00", "FFFFFF")


def getFadingColor(radians):
    red = max(0, int(0xFF * math.sin(radians + math.pi)))
    green = max(0, int(0xFF * math.sin(radians)))
    blue = 0xFF
    return f"{format(red, '02x')}{format(green, '02x')}{format(blue, '02x')}"


def getFlashingColor(frame):
    return PALETTE[frame % len(PALETTE)]


@api.on("uart", "d")
def down(event):
Example #8
0
import os
import readline
import atexit
import json

import vibrance

histfile = os.path.join(os.path.expanduser("~"), ".vibrance_history")

try:
    readline.read_history_file(histfile)
    readline.set_history_length(1000)
except FileNotFoundError:
    pass

atexit.register(readline.write_history_file, histfile)

api = vibrance.Interface("Terminal Composer")


@api.loop
def loop():
    i = input("Messages> ")
    api.messages = json.loads(i)
Example #9
0
PALETTE = (
    "000000",  # black
    "FFFFFF",  # white
    "FF0000",  # red
    "00FF00",  # green
    "0000FF",  # blue
    "FFFF00",  # yellow
    "00FFFF",  # cyan
    "FF00FF",  # magenta
    "FF8000",  # orange
    "8000FF",  # purple
    "0080FF",  # light blue
    "FF0080",  # pink
)

api = vibrance.Interface("Arduino Example")


@api.on("uart", "a")
def a(event):
    api.color(0, "FF0")
    api.color((1, 2), "000")
    api.wait(1)
    api.color(1, "FF0")
    api.color((0, 2), "000")
    api.wait(1)
    api.color(2, "FF0")
    api.color((0, 1), "000")


@api.on("uart", "b")
Example #10
0
    "FF0000",  # red
    "00FF00",  # green
    "0000FF",  # blue
    "FFFF00",  # yellow
    "00FFFF",  # cyan
    "FF00FF",  # magenta
    "FF8000",  # orange
    "8000FF",  # purple
    "0080FF",  # light blue
    "FF0080",  # pink
)

ZONES = list(range(6))

# haha, because it's the pipe input demo, and it's kinda broken...
api = vibrance.Interface("Broken Pipe")


@api.on("pipe", "cycle")
def cycle(event):
    i = event["color"]

    api.color((0, 3), PALETTE[i])
    api.color((1, 2, 4, 5), "000")
    api.wait(0.5)

    api.color((1, 4), PALETTE[i])
    api.color((0, 2, 3, 5), "000")
    api.wait(0.5)

    api.color((2, 5), PALETTE[i])
Example #11
0
PALETTE = (
    "000000",  # black
    "FFFFFF",  # white
    "FF0000",  # red
    "00FF00",  # green
    "0000FF",  # blue
    "FFFF00",  # yellow
    "00FFFF",  # cyan
    "FF00FF",  # magenta
    "FF8000",  # orange
    "8000FF",  # purple
    "0080FF",  # light blue
    "FF0080",  # pink
)

api = vibrance.Interface("Impulse")


@api.on("uart", "a")
def a(event):
    api.color(0, "FF0")
    api.color((1, 2), "000")
    api.wait(1)
    api.color(1, "FF0")
    api.color((0, 2), "000")
    api.wait(1)
    api.color(2, "FF0")
    api.color((0, 1), "000")


@api.on("uart", "b")
Example #12
0
    "FFFFFF",  # white
    "FF0000",  # red
    "00FF00",  # green
    "0000FF",  # blue
    "FFFF00",  # yellow
    "00FFFF",  # cyan
    "FF00FF",  # magenta
    "FF8000",  # orange
    "8000FF",  # purple
    "0080FF",  # light blue
    "FF0080",  # pink
)

ZONES = list(range(6))

api = vibrance.Interface("Octave Animations")

BPM = 122 / 2

BEAT_TIME = 60 / BPM


@api.on("midi", "note_on_oct_-2")
def cycle(event):
    i = event["note"] % 12

    api.color((1, 4), PALETTE[i])
    api.color((0, 2, 3, 5), "000")
    api.wait(BEAT_TIME / 2)

    api.color((2, 5), PALETTE[i])
Example #13
0
    "FFFFFF",  # white
    "FF0000",  # red
    "00FF00",  # green
    "0000FF",  # blue
    "FFFF00",  # yellow
    "00FFFF",  # cyan
    "FF00FF",  # magenta
    "FF8000",  # orange
    "8000FF",  # purple
    "0080FF",  # light blue
    "FF0080",  # pink
)

color = "000000"

api = vibrance.Interface("Color + Zone")

enabled = {zone: False for zone in range(6)}


def setEnabled(key, state):
    global enabled
    if key in (pygame.K_KP1, ord('1')):
        enabled[0] = state
        enabled[3] = state
    elif key in (pygame.K_KP2, ord('2')):
        enabled[1] = state
        enabled[4] = state
    elif key in (pygame.K_KP3, ord('3')):
        enabled[2] = state
        enabled[5] = state
Example #14
0
    "FFFFFF",  # white
    "FF0000",  # red
    "00FF00",  # green
    "0000FF",  # blue
    "FFFF00",  # yellow
    "00FFFF",  # cyan
    "FF00FF",  # magenta
    "FF8000",  # orange
    "8000FF",  # purple
    "0080FF",  # light blue
    "FF0080",  # pink
)

color = "000000"

api = vibrance.Interface("PyGame Example")

enabled = {zone: False for zone in range(6)}


def setEnabled(key, state):
    global enabled
    if key in (pygame.K_KP1, ord('1')):
        enabled[0] = state
        enabled[3] = state
    elif key in (pygame.K_KP2, ord('2')):
        enabled[1] = state
        enabled[4] = state
    elif key in (pygame.K_KP3, ord('3')):
        enabled[2] = state
        enabled[5] = state