Beispiel #1
0
def main():
    global conf
    global theme
    global updated
    try:
        load_nickname()
        conf = config.Config()
        theme = THEMES[conf.themeid]
        with display.open() as d:
            last_secs, secs = 0, 0
            last_msecs, msecs = 0, 0
            while True:
                updated = False

                bs = checkButtons()
                saveConfig = (MODE != DISPLAY)
                CTRL_FNS[MODE](bs)
                if saveConfig and MODE == DISPLAY:
                    conf.writeConfig()  # store config on leaving settings

                last_secs, secs = secs, utime.time_monotonic()
                if updated or secs > last_secs:
                    render(d)

                last_msecs, msecs = msecs, utime.time_monotonic_ms()
                if msecs - last_msecs < BUTTON_UPDATE_TIME:
                    utime.sleep_ms(BUTTON_UPDATE_TIME - (msecs - last_msecs))
    except KeyboardInterrupt:
        pass
Beispiel #2
0
def checkButtons():
    global pressed_prev

    t = utime.time_monotonic_ms()
    pressed = buttons.read(buttons.BOTTOM_LEFT | buttons.TOP_RIGHT
                           | buttons.BOTTOM_RIGHT)
    cur_buttons = 0

    cur_buttons |= checkButton(BUTTON_SEL, BUTTON_SEL_LONG,
                               buttons.BOTTOM_LEFT, pressed, t)
    cur_buttons |= checkButton(BUTTON_UP, BUTTON_UP_LONG, buttons.TOP_RIGHT,
                               pressed, t)
    cur_buttons |= checkButton(BUTTON_DOWN, BUTTON_DOWN_LONG,
                               buttons.BOTTOM_RIGHT, pressed, t)

    pressed_prev = pressed
    return cur_buttons
Beispiel #3
0
def main():
    global updated
    try:
        load_nickname()
        with display.open() as d:
            last_secs, secs = 0, 0
            last_msecs, msecs = 0, 0
            while True:
                updated = False

                bs = checkButtons()
                CTRL_FNS[MODE](bs)

                last_secs, secs = secs, utime.time_monotonic()
                if updated or secs > last_secs:
                    render(d)

                last_msecs, msecs = msecs, utime.time_monotonic_ms()
                if msecs - last_msecs < BUTTON_UPDATE_TIME:
                    utime.sleep_ms(BUTTON_UPDATE_TIME - (msecs - last_msecs))
    except KeyboardInterrupt:
        pass