Exemplo n.º 1
0
def blerx(args):
    for x in args:
        ## Locate an optional value given by an '='
        nv = x.split('=', 1)
        name = nv[0]
        value = nv[1] if len(nv) > 1 else None

        ## Handle the received stuff.
        if name == 'emote':
            ## Select a random emote.
            if (not value) or (value == 'random'):
                emote.random()
                pyb.delay(2500)
            ## Parse a specific emote to draw.
            else:
                emstr = ubinascii.unhexlify(value).decode("ascii")
                emote.render(emstr)
                pyb.delay(2500)
        if name == 'awoo':
            ## Someone started a howl
            msg = animations.scroll(" AWOOOOOOOOOOOOOO")
            delay = 0
            while delay < 5000:
                msg.draw()
                pyb.delay(msg.interval)
                delay += msg.interval
Exemplo n.º 2
0
def check_ble():
    if not badge.ble:
        return
    
    flags = badge.ble.read(badge.ble.REG_FLAGS)
    if flags & badge.ble.FLAG_EMOTE:
        ## Remote emote extravaganza!
        value = badge.ble.read16(badge.ble.REG_EMOTE)
        color = badge.ble.color()
        if (value):
            try:
                emote.render(chr(value & 0xff) + chr(value >> 8), color)
            except Exception:
                emote.random(color)
        else:
            emote.random(color)
        pyb.delay(2500)

    if flags & badge.ble.FLAG_AWOO:
        ## Someone started a howl
        msg = animations.scroll(" AWOOOOOOOOOOOOOOOO")
        delay = 0
        while delay < 5000:
            msg.draw()
            pyb.delay(msg.interval)
            delay += msg.interval