Esempio n. 1
0
#!/usr/bin/python
# Copyright (c) 2016 Michiel Fokke
# Author: Michiel Fokke <*****@*****.**>
# vim: set ts=4 sw=4 expandtab si:

from volumio_buddy import VolumioClient

def print_state(client):
    print client.state

client=VolumioClient()
client.set_callback(print_state, client)
client.wait()
Esempio n. 2
0
    print "seek: " + str(seek)
    print "volume: " + str(volume)

def show_menu(display):
# Display the menu modal for 3 sec
    display.menu(3)

# LED pins (WiringPi numbering)
LED_RED = 23
LED_GREEN = 26
LED_BLUE = 22

# SSD3106 reset pin (not used)
RESET_PIN = 26

led = RGBLED(LED_RED, LED_GREEN, LED_BLUE)
led.set(0, 0, 10)

display = Display(RESET_PIN)
display.image(path.dirname(path.realpath(filename)) + "/volumio.ppm")
display.start_updates()

while True:
# Ensure client restarts after network disconnection
    print "start websocket connection"
    client=VolumioClient()
    client.set_callback(print_state, client, display, led)
# Wait for event from either one of the buttons or the websocket connection
    client.wait()
    print "lost websocket connection"
Esempio n. 3
0
pipe = PipeWriter()

if fork() != 0:
    pipe.close(PipeWriter.OUT)
    led = RGBLED(LED_RED, LED_GREEN, LED_BLUE)
    led.set(0, 0, 10)

    display = Display(RESET_PIN)
    display.image(path.dirname(path.realpath(filename)) + "/volumio.ppm")
    display.start_updates()

    while True:
        # Ensure client restarts after network disconnection
        print "start websocket connection"
        client = VolumioClient()
        client.set_callback(print_state, client, display, led)

        # Wait for events from the websocket connection in separate thread
        client.wait()
        while True:
            print 'waiting for command'
            command = '%s' % pipe.read()
            print 'recieved command: %s' % command
            if command == 'volume_up':
                client.volume_up()
            elif command == 'volume_down':
                client.volume_down()
            elif command == 'next_song':
                client.next()
            elif command == 'previous_song':
Esempio n. 4
0
# Rotary encoder 2 pins (WiringPi numbering)
PB2 = 7
ROT_ENC_2A = 4
ROT_ENC_2B = 5

# LED pins (WiringPi numbering)
LED_RED = 23
LED_GREEN = 26
LED_BLUE = 22

# SSD3106 reset pin (not used)
RESET_PIN = 26

push_button = PushButton(PB1)
push_button2 = PushButton(PB2)
rotary_encoder = RotaryEncoder(ROT_ENC_1A, ROT_ENC_1B)
rotary_encoder2 = RotaryEncoder(ROT_ENC_2A, ROT_ENC_2B)

client = VolumioClient()

push_button.set_callback(toggle_play, client)
push_button2.set_callback(toggle_play, client)

rotary_encoder.set_callback(update_volume, rotary_encoder, client)
rotary_encoder2.set_callback(previous_next, rotary_encoder2, client)

# Wait for event from either one of the buttons
while True:
    delay(2000)