Example #1
0
def main():

    print('ACTIVATED')
    try:
        while True:
            time.sleep(1)
            phatbeat.set_all(0, 0, 0)

    except KeyboardInterrupt:
        pass
Example #2
0
def main():

    print('ACTIVATED')
    try:
        while True:
            time.sleep(1)
            phatbeat.set_all(0,0,0)

    except KeyboardInterrupt:
        pass
Example #3
0
def rainbow():
    SPEED = 300
    BRIGHTNESS = 64
    SPREAD = 20

    #while True:
    for cycles in range(1, 200):
        for x in range(phatbeat.CHANNEL_PIXELS):
            h = (time.time() * SPEED + (x * SPREAD)) % 360 / 360.0
            r, g, b = [int(c*BRIGHTNESS) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
            phatbeat.set_pixel(x, r, g, b, channel=0)
            phatbeat.set_pixel(x, r, g, b, channel=1)

        phatbeat.show()
        time.sleep(0.001)
    time.sleep(0.1)
    phatbeat.set_all(0,0,0)
Example #4
0
def rainbow():
    SPEED = 300
    BRIGHTNESS = 64
    SPREAD = 20

    #while True:
    for cycles in range(1, 200):
        for x in range(phatbeat.CHANNEL_PIXELS):
            h = (time.time() * SPEED + (x * SPREAD)) % 360 / 360.0
            r, g, b = [
                int(c * BRIGHTNESS) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)
            ]
            phatbeat.set_pixel(x, r, g, b, channel=0)
            phatbeat.set_pixel(x, r, g, b, channel=1)

        phatbeat.show()
        time.sleep(0.001)
    time.sleep(0.1)
    phatbeat.set_all(0, 0, 0)
Example #5
0
def set_channel_hue(channel, hue):

    r, g, b = [
        int(x * 255) for x in colorsys.hsv_to_rgb(hue / 360.0, 1.0, 1.0)
    ]
    phatbeat.set_all(r, g, b, channel=channel)
Example #6
0
    log("PHAT BEAT {} running with PID: {}".format("daemon" if daemonize else "process",pid))

    stdin = file("/dev/null", 'r')
    stdout = file(LOGFILE, 'a+')
    stderr = file(ERRFILE, 'a+')

    os.dup2(stdin.fileno(), sys.stdin.fileno())
    os.dup2(stdout.fileno(), sys.stdout.fileno())
    os.dup2(stderr.fileno(), sys.stderr.fileno())

    vlc = VLC(host=VLC_HOST, port=VLC_PORT)

    if vlc.connect():
        import phatbeat
        phatbeat.set_all(0,128,0,0.1)
        phatbeat.show()
        time.sleep(1)
        phatbeat.clear()
        phatbeat.show()

        read_state()
        #init vol
        if 'volume' in phatbeatd_state:
            log('set init volume: %d' % phatbeatd_state['volume'])
            log(vlc.communicate( "volume %d" % phatbeatd_state['volume']))

        def store_volume(cmd_response):
            vol = [int(s) for s in cmd_response.split() if s.isdigit()]
            if len(vol) >=1 :
                write_state('volume', vol[0])
Example #7
0
    print("Play/Pause pressed!")


@phatbeat.on(phatbeat.BTN_VOLUP)
def fast_forward(pin):
    print("Volume Up pressed!")


@phatbeat.on(phatbeat.BTN_VOLDN)
def fast_forward(pin):
    print("Volume Down pressed!")


@phatbeat.on(phatbeat.BTN_ONOFF)
def fast_forward(pin):
    print("Power On/Off  pressed!")
    phatbeat.clear()
    phatbeat.show()
    sys.exit("exiting...")


try:
    while True:
        phatbeat.set_all(0, 128, 0, 0.1, channel=0)
        phatbeat.set_all(255, 155, 0, 0.1, channel=1)
        phatbeat.show()
        time.sleep(1)

except KeyboardInterrupt:
    pass
Example #8
0
def hold_onoff(pin):
	os.system("sudo poweroff")
	phatbeat.set_all(255, 0, 0, brightness=1.0)