コード例 #1
0
def main():

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

    except KeyboardInterrupt:
        pass
コード例 #2
0
ファイル: phat1.py プロジェクト: acutesoftware/dev_setup
def main():

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

    except KeyboardInterrupt:
        pass
コード例 #3
0
ファイル: phat1.py プロジェクト: acutesoftware/dev_setup
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)
コード例 #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)
コード例 #5
0
ファイル: hue-control.py プロジェクト: wrestrtdr/phat-beat
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)
コード例 #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])
コード例 #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
コード例 #8
0
def hold_onoff(pin):
	os.system("sudo poweroff")
	phatbeat.set_all(255, 0, 0, brightness=1.0)