Ejemplo n.º 1
0
def main():
    try:
        global mqtt_hostname, mqtt_server, wifi_ap
        _thread.start_new_thread("led-animation", ledThread, ())
        _buttons.register(0)
        _buttons.attach(0, buttonHandler)
        mqtt = MQTTClient(mqtt_hostname, mqtt_server)
        mqtt.set_callback(mqttHandler)

        while True:
            if wifi_ap:
                mqtt.disconnect()
                break
            if not wifi.status():
                connectToWiFi()
                mqtt.connect()
                mqtt.subscribe(b"hoera10jaar/+")
            else:
                mqtt.check_msg()
            time.sleep(0.1)
    except BaseException as e:
        print("MAIN THREAD CRASHED")
        print(e)
        time.sleep(2)
        system.home()
Ejemplo n.º 2
0
def onB(pressed):
	if pressed:
		display.drawFill(0x000000)
		drawMessageBox("Loading homescreen...")
		display.flush(display.FLAG_LUT_FASTEST)
		time.sleep(0.1)
		system.home()
Ejemplo n.º 3
0
def confirm(nickname):
    term.header(True, "Nickname setup")
    machine.nvs_setstr("badge", "nickname", nickname)
    print("New configuration has been saved.")
    print("")
    print("Nickname:\t\t" + nickname)
    print("Press any key to return to the homescreen")
    sys.stdin.read(1)
    system.home(True)
def confirm(nickname):
    term.header(True, "Nickname setup")
    nvs.set_blob("nickname", nickname)
    nvs.commit()
    print("New configuration has been saved.")
    print("")
    print("Nickname:\t\t" + nickname)
    print("Press any key to return to the homescreen")
    sys.stdin.read(1)
    system.home(True)
Ejemplo n.º 5
0
def confirm(ssid, password):
    term.header(True, "WiFi setup")
    machine.nvs_setstr("system", "wifi.ssid", ssid)
    machine.nvs_setstr("system", "wifi.password", password)
    print("New configuration has been saved.")
    print("")
    print("SSID:\t\t" + ssid)
    if len(password) < 1:
        print("No password")
    else:
        print("PASSWORD:\t" + password)
    print("")
    print("Press any key to return to the homescreen")
    sys.stdin.read(1)
    system.home(True)
Ejemplo n.º 6
0
def confirm(ssid, password):
    term.header(True, "WiFi setup")
    nvs = esp32.NVS("system")
    nvs.set_blob("wifi.ssid", ssid)
    nvs.set_blob("wifi.password", password)
    nvs.commit()
    print("New configuration has been saved.")
    print("")
    print("SSID:\t\t" + ssid)
    if len(password) < 1:
        print("No password")
    else:
        print("PASSWORD:\t" + password)
    print("")
    print("Press any key to return to the homescreen")
    sys.stdin.read(1)
    system.home(True)
Ejemplo n.º 7
0
def read(path, render="experimental", begin=0, lines=15):
    global view, start, read_lines, breaking_mode, parsed_lines, parsed_fonts, article_length, f, eof, first_run, file
    start = begin
    read_lines = lines
    breaking_mode = render
    parsed_lines = []
    parsed_fonts = []
    article_length = 0
    eof = False
    first_run = True
    file = path

    easydraw.messageCentered(
        "Loading " + path + "\nFrom " + str(start) + " to " +
        str(start + lines), True, "/media/busy.png")
    try:
        f = open(path, mode='r', encoding='utf-8')
        easydraw.messageCentered("Rendering", True, "/media/ok.png")
        read_data()
        view = create_view(0, "next")
    except BaseException as e:
        import sys, system
        sys.print_exception(e)
        system.home()
current = machine.nvs_getstr('splash', 'ledApp')

while True:
    options = []
    for service in services:
        title = service
        if service == current:
            title += " [Enabled]"
        options.append(title)
    options.append(" None (disable LED services)")
    options.append("< Exit")

    selected = term.menu("Services", options, 0, "")
    if selected > len(services):
        system.home(True)
    if selected == len(services):
        current = None
        try:
            machine.nvs_erase('splash', 'ledApp')
        except:
            pass
        term.header(True, "Services")
        print("LED services disabled")
        time.sleep(1)
    else:
        current = services[selected]
        machine.nvs_setstr('splash', 'ledApp', current)
        term.header(True, "Services")
        print("Selected " + current)
        time.sleep(1)
Ejemplo n.º 9
0
def callback(value):
    if value:
        badge.nvs_set_str("owner", "name", value)
    system.home()
            legacy_mpr5 = machine.nvs_get_u16("badge", "mpr121.base.5")
            legacy_mpr6 = machine.nvs_get_u16("badge", "mpr121.base.6")
            legacy_mpr7 = machine.nvs_get_u16("badge", "mpr121.base.7")
            machine.nvs_set_u16("system", "mpr121.base.0", legacy_mpr0)
            machine.nvs_set_u16("system", "mpr121.base.1", legacy_mpr1)
            machine.nvs_set_u16("system", "mpr121.base.2", legacy_mpr2)
            machine.nvs_set_u16("system", "mpr121.base.3", legacy_mpr3)
            machine.nvs_set_u16("system", "mpr121.base.4", legacy_mpr4)
            machine.nvs_set_u16("system", "mpr121.base.5", legacy_mpr5)
            machine.nvs_set_u16("system", "mpr121.base.6", legacy_mpr6)
            machine.nvs_set_u16("system", "mpr121.base.7", legacy_mpr7)
        except:
            print("Unable to move MPR121 calibration!")
            import _mpr121calib
    else:
        print("Badge has been freshly installed!")
        import _mpr121calib
    try:
        # Remove old settings from NVS
        machine.nvs_erase_all("badge")
    except:
        pass

if currentState < 3:
    import dashboard.resources.png_icons as icons
    icons.install()

# We have completed the factory script
machine.nvs_setint('system', 'factory_checked', 3)
system.home()
Ejemplo n.º 11
0
def pm_cb(dummy):
    system.home()
Ejemplo n.º 12
0
def goToSleep(unused_variable=None):
    system.home()
def home(pressed):
    if pressed:
        system.home()
Ejemplo n.º 14
0
def input_start(pressed):
    pm.feed()
    if pressed:
        system.home()
def cancel(pressed):
	if pressed:
		system.home()
Ejemplo n.º 16
0
def home():
    system.home(True)
Ejemplo n.º 17
0
def quit(pressed):
    if pressed:
        system.home()
Ejemplo n.º 18
0
def action_exit(pushed):
    if (pushed):
        system.home()
Ejemplo n.º 19
0
def callback(value):
    if value:
        machine.nvs_setstr("owner", "name", value)
    system.home()
def onB(pressed):
    if pressed:
        device.showLoadingScreen("Homescreen")
        system.home()
Ejemplo n.º 21
0
def home():
    import system
    system.home(True)
Ejemplo n.º 22
0
def onB(pressed):
    if pressed:
        display.drawFill(0x000000)
        drawMessageBox("Loading homescreen...")
        display.flush()
        system.home()
def buttonHandler(pressed):
    global button_pressed
    if pressed:
        system.home()