def showAuthScreen():

    # start
    bt81x.dl_start()
    bt81x.clear(1, 1, 1)

    # image
    image = bt81x.Bitmap(
        1, 0, (bt81x.ARGB4, 420 * 2),
        (bt81x.BILINEAR, bt81x.BORDER, bt81x.BORDER, 420, 480))
    image.prepare_draw()
    image.draw((0, 0), vertex_fmt=0)

    # text
    txt = bt81x.Text(
        590,
        220,
        28,
        bt81x.OPT_CENTERX | bt81x.OPT_CENTERY,
        "Press the push-link button of the Hue",
    )
    bt81x.add_text(txt)
    txt.text = "bridge you want to connect to"
    txt.x = 590
    txt.y = 260
    bt81x.add_text(txt)

    # display
    bt81x.display()
    bt81x.swap_and_empty()
Beispiel #2
0
def widget_selection():
    bt81x.dl_start()
    bt81x.clear(1, 1, 1)

    txt.font = 31
    txt.text = "Choose a widget"
    txt.x = bt81x.display_conf.width // 2
    txt.y = (bt81x.display_conf.height * 2) // 11
    bt81x.add_text(txt)

    bt81x.track(bt81x.display_conf.width // 5,
                (bt81x.display_conf.height * 3) // 11, 500, 100, 0)
    bt81x.add_keys(bt81x.display_conf.width // 5,
                   (bt81x.display_conf.height * 3) // 11, 500, 100, 31, 0,
                   widget_selection_keys)

    if widget_choice:
        print('> displaying', widgets[widget_choice - 1][0])
        widgets[widget_choice - 1][1](*widgets[widget_choice - 1][2:])

    bt81x.display()
    bt81x.swap_and_empty()

    widget_choice_evt.wait()
    widget_choice_evt.clear()
def showSpinner(msg):

    # start
    bt81x.dl_start()
    bt81x.clear(1, 1, 1)

    # text
    txt = bt81x.Text(
        400,
        350,
        30,
        bt81x.OPT_CENTERX | bt81x.OPT_CENTERY,
        msg,
    )
    bt81x.add_text(txt)

    # spinner
    bt81x.spinner(400, 240, bt81x.SPINNER_CIRCLE, 0)

    # display
    bt81x.display()
    bt81x.swap_and_empty()

    # wait a second - just to improve UI experience ;)
    sleep(1000)
def displayUpdate():

    global cpu_temp
    global cpu_load

    image_1 = bt81x.Bitmap(
        1, 0, (bt81x.ARGB4, RLOGO_W * 2),
        (bt81x.BILINEAR, bt81x.BORDER, bt81x.BORDER, RLOGO_W, RLOGO_H))
    bt81x.dl_start()
    bt81x.load_image(0, 0, 'rlogo.png')
    bt81x.clear(1, 1, 1)
    bt81x.set_background(255, 255, 255)
    image_1.prepare_draw()
    image_1.draw((248, 35), vertex_fmt=0)
    txt_temp = bt81x.Text(
        500,
        260,
        31,
        bt81x.OPT_RIGHTX | bt81x.OPT_CENTERY,
        "Temperature : %2.1f" % cpu_temp,
    )
    txt_load = bt81x.Text(
        500,
        320,
        31,
        bt81x.OPT_RIGHTX | bt81x.OPT_CENTERY,
        "Load : %2.1f" % cpu_load,
    )
    bt81x.add_text(txt_temp)
    bt81x.add_text(txt_load)
    bt81x.display()
    bt81x.swap_and_empty()
def showScreensaver(x, y):

    # start
    bt81x.dl_start()
    bt81x.clear_color(rgb=(0x00, 0x00, 0x00))
    bt81x.clear(1, 1, 1)

    # image
    image = bt81x.Bitmap(1, 0, (bt81x.ARGB4, (300) * 2),
                         (bt81x.BILINEAR, bt81x.BORDER, bt81x.BORDER, 300, 75))
    image.prepare_draw()
    image.draw((x, y), vertex_fmt=0)

    # display
    bt81x.display()
    bt81x.swap_and_empty()
Beispiel #6
0
def draw_networks(networks, pressed=None):
    bt81x.dl_start()
    bt81x.clear(1, 1, 1)

    for i, ssid_sec in enumerate(networks):
        if i == MAX_NET:
            # do not display more networks than MAX_NET
            break
        btn.palette = palette_pressed if i == pressed else palette_default
        btn.text = ("%s::%s") % (ssid_sec[0], ssid_sec[1])
        btn.y = i * BTN_HEIGHT
        bt81x.track(0, btn.y, BTN_WIDTH, BTN_HEIGHT, TAG_BASE + i)
        bt81x.tag(TAG_BASE + i)
        bt81x.add_button(btn)

    bt81x.display()
    bt81x.swap_and_empty()
def showMessage(text):

    # start
    bt81x.dl_start()
    bt81x.clear(1, 1, 1)

    #text
    txt = bt81x.Text(
        400,
        240,
        31,
        bt81x.OPT_CENTERX | bt81x.OPT_CENTERY,
        text,
    )
    bt81x.add_text(txt)

    # display
    bt81x.display()
    bt81x.swap_and_empty()
def showLogo():

    # start
    bt81x.dl_start()
    bt81x.clear_color(rgb=(0xff, 0xff, 0xff))
    bt81x.clear(1, 1, 1)

    # image
    image = bt81x.Bitmap(
        1, 0, (bt81x.ARGB4, 642 * 2),
        (bt81x.BILINEAR, bt81x.BORDER, bt81x.BORDER, 642, 144))
    image.prepare_draw()
    image.draw(((bt81x.display_conf.width - 642) // 2,
                (bt81x.display_conf.height - 144) // 2),
               vertex_fmt=0)

    # display
    bt81x.display()
    bt81x.swap_and_empty()
def pinScreen(pin):

    pin_masked = "****"
    pin_length = len(pin)

    # start
    bt81x.dl_start()
    bt81x.clear(1, 1, 1)

    #text
    #drawing instructions
    txt = bt81x.Text(
        200,
        150,
        31,
        bt81x.OPT_CENTERX | bt81x.OPT_CENTERY,
        "Enter Pin:",
    )
    bt81x.add_text(txt)

    #drawing user pin
    txt.text = pin_masked[:pin_length]
    txt.x = 200
    txt.y = 200
    txt.font = 31
    bt81x.add_text(txt)

    # keys
    bt81x.track(430, 50, 350, 70, 0)
    bt81x.add_keys(430, 50, 350, 70, 30, 0, "123")
    bt81x.add_keys(430, 130, 350, 70, 30, 0, "456")
    bt81x.add_keys(430, 210, 350, 70, 30, 0, "789")
    bt81x.add_keys(430, 290, 350, 70, 30, 0, ".0C")

    # connect button
    btn = bt81x.Button(430, 370, 350, 70, 30, 0, "Connect")
    bt81x.tag(1)
    bt81x.add_button(btn)

    # display
    bt81x.display()
    bt81x.swap_and_empty()
Beispiel #10
0
def showAddrScreen(ip):

    # start
    bt81x.dl_start()
    bt81x.clear(1, 1, 1)

    # image
    image = bt81x.Bitmap(
        1, 0, (bt81x.ARGB4, 200 * 2),
        (bt81x.BILINEAR, bt81x.BORDER, bt81x.BORDER, 200, 200))
    image.prepare_draw()
    image.draw((0, 255), vertex_fmt=0)

    # text
    txt = bt81x.Text(
        225,
        120,
        29,
        bt81x.OPT_CENTERX | bt81x.OPT_CENTERY,
        "Enter IP address of HUE Bridge:",
    )
    bt81x.add_text(txt)
    txt.text = ip
    txt.x = 225
    txt.y = 195
    txt.font = 31
    bt81x.add_text(txt)

    # keys
    bt81x.track(450, 350, 280, 60, 0)
    bt81x.add_keys(450, 70, 280, 60, 30, 0, "123")
    bt81x.add_keys(450, 140, 280, 60, 30, 0, "456")
    bt81x.add_keys(450, 210, 280, 60, 30, 0, "789")
    bt81x.add_keys(450, 280, 280, 60, 30, 0, ".0C")

    # connect button
    btn = bt81x.Button(450, 350, 280, 60, 30, 0, "Connect")
    bt81x.tag(1)
    bt81x.add_button(btn)

    bt81x.display()
    bt81x.swap_and_empty()
def displaySpinner(operation, info):
    bt81x.dl_start()
    bt81x.clear(1, 1, 1)
    txt_oper = bt81x.Text(
        400,
        260,
        24,
        bt81x.OPT_CENTERX | bt81x.OPT_CENTERY,
        operation,
    )
    txt_info = bt81x.Text(
        400,
        300,
        24,
        bt81x.OPT_CENTERX | bt81x.OPT_CENTERY,
        info,
    )
    bt81x.add_text(txt_oper)
    bt81x.add_text(txt_info)
    bt81x.spinner(400, 160, bt81x.SPINNER_LINE, 0)
    bt81x.display()
    bt81x.swap_and_empty()
Beispiel #12
0
def showMainMenu(saturation, hue, brightness):

    # start
    bt81x.dl_start()
    bt81x.clear(1, 1, 1)

    # image
    image = bt81x.Bitmap(1, 0, (bt81x.ARGB4, 800 * 2),
                         (bt81x.BILINEAR, bt81x.BORDER, bt81x.BORDER, 800, 50))
    image.prepare_draw()
    image.draw((0, 0), vertex_fmt=0)

    # buttons
    btn = bt81x.Button(0, 0, 170, 70, 31, 0, "")
    for button in buttons:
        btn.text = button["text"]
        btn.font = button["size"]
        btn.x = button["x_cord"]
        btn.y = button["y_cord"]
        btn.width = button["width"]
        btn.height = button["height"]
        bt81x.track(btn.x, btn.y, button["width"], button["height"],
                    button["tag_id"])
        bt81x.tag(button["tag_id"])
        bt81x.add_button(btn)

    # text labels
    txt = bt81x.Text(0, 0, 0, 30, "")
    for label in labels:
        txt.text = label["text"]
        txt.x = label["x_cord"]
        txt.y = label["y_cord"]
        txt.font = label["size"]
        txt.options = label["options"]
        bt81x.add_text(txt)

    # saturation value label
    txt.text = str(int((saturation / 240) * 100)) + '%'
    txt.x = 622
    txt.y = 175
    txt.font = 30
    txt.options = bt81x.OPT_CENTER
    bt81x.add_text(txt)

    # hue value label
    txt.text = str(int((hue / 65500) * 100)) + '%'
    txt.x = 622
    txt.y = 275
    txt.font = 30
    txt.options = bt81x.OPT_CENTER
    bt81x.add_text(txt)

    # brightness value label
    txt.text = str(int((brightness / 240) * 100)) + '%'
    txt.x = 622
    txt.y = 375
    txt.font = 30
    txt.options = bt81x.OPT_CENTER
    bt81x.add_text(txt)

    # display
    bt81x.display()
    bt81x.swap_and_empty()
Beispiel #13
0
from bridgetek.bt81x import bt81x

streams.serial()

new_resource('RiverdiLogo.png')

LOGO_W = 642
LOGO_H = 144
linestride = LOGO_W * 2  # with ARGB1555 and ARGB4 formats, 2 bytes per pixel

layout = (bt81x.ARGB4, linestride)  # choose this layout for RiverdiLogo.png

riverdi_logo = bt81x.Bitmap(
    1, 0, layout, (bt81x.BILINEAR, bt81x.BORDER, bt81x.BORDER, LOGO_W, LOGO_H))

bt81x.init(SPI0, D4, D5, D34)

bt81x.load_image(0, 0, 'RiverdiLogo.png')

bt81x.dl_start()
bt81x.clear_color(rgb=(0xff, 0xff, 0xff))
bt81x.clear(1, 1, 0)

riverdi_logo.prepare_draw()
riverdi_logo.draw(((bt81x.display_conf.width - LOGO_W) // 2,
                   (bt81x.display_conf.height - LOGO_H) // 2),
                  vertex_fmt=0)

bt81x.display()
bt81x.swap_and_empty()