Exemplo n.º 1
0
def play_video(media, sync=True):
    """ Plays video synchronously

    Plays video and wait for completion

    :param media: The media to play, relative to the media root folder
    """
    Expecter().send('video.command.start', {"media": media})

    if sync:
        Expecter().expect('video.event.stop')
Exemplo n.º 2
0
def dmx_send_channels(channels, values):
    chandict = {}
    for x in range(len(channels)):
        chandict[channels[x]] = values[x]

    logging.info("Sending DMX array")
    Expecter().send('dmx.command.send', {"channels": chandict})
Exemplo n.º 3
0
def set_volume(level):
    """ Changes global volume

    Changes Griotte global volume

    :param level: The sound level, in percent (0 - 120)
    """
    Expecter().send('storage.set.sound_level', {"level": level})
Exemplo n.º 4
0
def play_image(media, duration=0):
    """ Displays image

    Plays displays image returns

    :param media: The image to show, relative to the media root folder
    """
    logging.info("Playing image %s" % media)
    Expecter().send('image.command.start', {"media": media})
Exemplo n.º 5
0
def set_background(strhex):
    """ Displays image

    Plays displays image returns

    :param media: The image to show, relative to the media root folder
    """
    logging.info("Setting background to %s" % strhex)
    Expecter().send('image.command.background', {"color": strhex})
Exemplo n.º 6
0
def wait_edge(port, style="any"):
    """ Waits for an edge (rising, falling, any) on a port

    This will block until an edge of the requested style is sensed on the requested port

    :param port: port to wait for
    :type port: str
    :param style: type of edge to wait for ('rising', 'falling' of 'any')
    :type style: str
    """
    if style not in ('rising', 'falling','any'):
        raise ValueError("edge argument can only be 'rising', 'falling' of 'any'")

    if style == 'any':
        data = Expecter().expect("gpio.event." + port + ".edge.*",
                                 flush = True)
    else:
        data = Expecter().expect("gpio.event." + port + ".edge." + style,
                                 flush = True)

    logging.debug("get_digital : received edge %s for port %s" % (data['value'], port))

    return data['value']
Exemplo n.º 7
0
def get_digital(port):
    """ Returns current digital value for port

    This will block until a digital value is received on the requested port

    :param port: port to wait for
    """
    data = Expecter().send_expect("gpio.command." + port + ".sample",
                                  "gpio.event." + port + ".sample",
                                  data  = { "every": 0.5 },
                                  flush = True)

    logging.debug("get_digital : received sample %s" % data['value'])

    return data['value']
Exemplo n.º 8
0
def rfid_read(tag):
    """ Returns when tag is read

    This will block until a tag is read on the RFID reader

    :param tag: tag to wait for. If None, will return first tag seen
    :rtype: string -- tag read on reader
    """

    while True:
        data = Expecter().expect("rfid.event.tag",
                                 flush = True)

        logging.debug("rfid_read : received tag %s" % data['tag'])

        if tag == None or tag == data['tag']:
            return data['tag']
Exemplo n.º 9
0
def __goodbye__():
    Expecter().quit()
Exemplo n.º 10
0
def stop_video():
    """ Stops currently playing video

    Sends a ws message asking for the video to stop
    """
    Expecter().send('video.command.stop')
Exemplo n.º 11
0
def dmx_blackout():
    logging.info("Sending DMX blackout")
    Expecter().send('dmx.command.clear', {"channels": []})