Пример #1
0
from adafruit_ble_eddystone import uid, url

radio = adafruit_ble.BLERadio()

# Reuse the BLE address as our Eddystone instance id.
eddystone_uid = uid.EddystoneUID(radio.address_bytes)

# List of URLs to broadcast here:
ad_url = [("https://circuitpython.org", "CirPy"),
          ("https://adafru.it/discord", "DISCORD"),
          ("https://forums.adafruit.com", "Forums"),
          ("https://learn.adafruit.com", "Learn")]
pick = 0  # use to increment url choices

pybadger.play_tone(1600, 0.25)
pybadger.show_business_card(image_name="cluebeacon.bmp")

while True:
    pybadger.auto_dim_display(delay=3, movement_threshold=4)
    eddystone_url = url.EddystoneURL(ad_url[pick][0])

    if pybadger.button.a and not pybadger.button.b:  # Press button A to show QR code
        pybadger.play_tone(1200, 0.1)
        pybadger.brightness = 1
        pybadger.show_qr_code(data=ad_url[pick][0])  # Tests QR code
        time.sleep(0.1)  # Debounce

    elif pybadger.button.b and not pybadger.button.a:  # iterate through urls to broadcast
        pybadger.play_tone(1600, 0.2)
        pick = (pick + 1) % len(ad_url)
        pybadger.brightness = 1
                                my_name_is_scale=2,
                                name_scale=3)
            try_refresh()

    if prev_b and not cur_b:
        pybadger.pixels.fill(0x000000)
        if SHOWING != "qr":
            print("changing to qr")
            SHOWING = "qr"
            pybadger.show_qr_code(data="https://www.adafruit.com/product/4800")
            try_refresh()

    if prev_c and not cur_c:
        pybadger.pixels.fill(0x000000)
        if SHOWING != "card":
            print("changing to card")
            SHOWING = "card"
            pybadger.show_business_card(
                image_name="Blinka_MagTag.bmp",
                name_string="Blinka",
                name_scale=2,
                email_string_one="blinka@",
                email_string_two="adafruit.com",
            )
            # show_business_card() calls refresh() internally

    prev_a = cur_a
    prev_b = cur_b
    prev_c = cur_c
    time.sleep(1)
#!/usr/bin/env python3
"""Simple PyBadge NameBadge Example."""

from adafruit_pybadger import pybadger

pybadger.show_badge(name_string="FASW",
                    hello_scale=1,
                    my_name_is_scale=1,
                    name_scale=3)

while True:
    pybadger.auto_dim_display(delay=10)
    if pybadger.button.a:
        pybadger.show_business_card(image_name="faswlogo.bmp",
                                    name_string="FASW",
                                    name_scale=2)
    elif pybadger.button.b:
        pybadger.show_qr_code(data="https://circuitpython.org")
    elif pybadger.button.start:
        pybadger.show_badge(
            name_string="Hello World",
            hello_scale=2,
            my_name_is_scale=2,
            name_scale=2,
        )