def main():
    term.empty_lines()
    term.header(True, "Nickname setup")
    print("Enter your new nickname.")
    nickname = term.prompt("Nickname", 1, 5)
    if (len(nickname) >= 1):
        confirm(nickname)
Example #2
0
def sleep(duration=0, status=False):
    import time, os, badge
    #---BADGE specific---
    try:
        os.umountsd()
    except:
        pass
    badge.setPower(False)
    machine.RTC().wake_on_ext0(pin=machine.Pin(39),
                               level=0)  #Navigation buttons
    machine.RTC().wake_on_ext1(
        [machine.Pin(34, machine.Pin.IN),
         machine.Pin(35, machine.Pin.IN)], 0)  #Keyboard
    badge.eink_busy_wait()
    #---
    if (duration >= 86400000):  #One day
        duration = 0
    if status:
        import term
        if duration < 1:
            term.header(True, "Sleeping until button is pressed...")
        else:
            term.header(True, "Sleeping for " + str(duration) + "ms...")
    time.sleep(0.05)
    machine.deepsleep(duration)
Example #3
0
def ota(status=False):
    if status:
        term.header(True, "Starting update...")
    rtc = machine.RTC()
    rtc.write(0, 1)
    rtc.write(1, 254)
    machine.deepsleep(2)
Example #4
0
def ota(status=False):
	import esp
	if status:
		import term
		term.header(True, "Starting update...")
	esp.rtcmem_write(0,1)
	esp.rtcmem_write(1,254)
	reboot()
Example #5
0
def ota(status=False):
    if status:
        term.header(True, "Starting update...")
        device.showLoadingScreen("OTA update")
    rtc = machine.RTC()
    rtc.write(0, 1)  # Boot mode selection magic
    rtc.write(1, 254)
    reboot()
Example #6
0
def start(app, status=True):
    if status:
        if app == "" or app == "launcher":
            term.header(True, "Loading menu...")
        else:
            term.header(True, "Loading application " + app + "...")
    machine.RTC().write_string(app)
    machine.deepsleep(1)
def ota(status=False):
    if status:
        import term
        term.header(True, "Starting update...")
    rtc = machine.RTC()
    rtc.write(0, 1)
    rtc.write(1, 254)
    reboot()
Example #8
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 _showProgress(msg, error=False, icon_wifi=False):
    term.header(True, "Installer")
    print(msg)
    icon = "/media/busy.png"
    if error:
        icon = "/media/alert.png"
    elif icon_wifi:
        icon = "/media/wifi.png"
    easydraw.messageCentered(msg, False, icon)
Example #10
0
def start(app, status=False):
    if status:
        if app == "" or app == "launcher":
            term.header(True, "Loading menu...")
        else:
            term.header(True, "Loading application " + app + "...")
        device.showLoadingScreen(app)
    machine.RTC().write_string(app)
    reboot()
def ota(status=False):
    if status:
        term.header(True, "Starting update...")
        easydraw.messageCentered("PLEASE WAIT\nStarting update...", True,
                                 "/media/busy.png")
    rtc = machine.RTC()
    rtc.write(0, 1)
    rtc.write(1, 254)
    reboot()
def show_app(app,category):
	term.empty_lines()
	term.header(True, "Installer - %s"%app['name'])
	items=["Install app %s"%app['name'], "Go back"]
	option=term.menu("Installer %s %s"%(app['name'],app['description']), items)
	if option==0:
		install_app(app)
	else:
		return
	gc.collect()
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)
Example #14
0
def vcc_low(sleepTime=0):
    import term, rgb, machine
    term.header(True, "Going to sleep...")
    rgb.enablecomp()
    rgb.background((0, 0, 0))
    rgb.clear()
    uinterface.skippabletext('BATT LOW!')

    time.sleep(0.1)
    machine.deepsleep(sleepTime)
Example #15
0
def ota(status=False):
    import esp, deepsleep
    if status:
        import term, easydraw
        term.header(True, "Starting update...")
        easydraw.messageCentered("PLEASE WAIT\nStarting update...", True,
                                 "/media/busy.png")
    esp.rtcmem_write(0, 1)
    esp.rtcmem_write(1, 254)
    reboot()
def vcc_low(sleepTime=0):
    term.header(True, "Going to sleep...")
    rgb.enablecomp()
    rgb.background((0, 0, 0))
    rgb.clear()
    rgb.scrolltext('BATT LOW!')
    time.sleep(4)

    time.sleep(0.1)
    machine.deepsleep(sleepTime)
Example #17
0
def sleep(duration=0, status=False):
    if (duration >= 86400000):  #One day
        duration = 0
    if status:
        if duration < 1:
            term.header(True, "Sleeping until touchbutton is pressed...")
        else:
            term.header(True, "Sleeping for " + str(duration) + "ms...")
    time.sleep(0.1)
    machine.deepsleep(0)
Example #18
0
def start(app, status=False):
	import esp
	if status:
		import term
		if app == "" or app == "launcher":
			term.header(True, "Loading menu...")
		else:
			term.header(True, "Loading application "+app+"...")
	esp.rtcmem_write_string(app)
	reboot()
Example #19
0
def start_sleeping(sleepTime=0):
	badge.off()
	term.header(True, "Going to sleep...")
	if (sleepTime >= 86400000): #One day
		sleepTime = 0
	if (sleepTime < 1):
		print("Sleeping until touchbutton is pressed...")
	else:
		print("Sleeping for "+str(sleepTime)+"ms...")
	time.sleep(0.1)
	machine.deepsleep(sleepTime)
Example #20
0
def showMessage(msg, error=False, icon_wifi=False, icon_ok=False):
	term.header(True, "Installer")
	print(msg)
	if error:
		easydraw.messageCentered("ERROR\n\n"+msg, True, "/media/alert.png")
	elif icon_wifi:
		easydraw.messageCentered("PLEASE WAIT\n\n"+msg, True, "/media/wifi.png")
	elif icon_ok:
		easydraw.messageCentered(msg, True, "/media/ok.png")
	else:
		easydraw.messageCentered("PLEASE WAIT\n\n"+msg, True, "/media/busy.png")
Example #21
0
def show_names():
    global names
    c = False
    y = 10

    term.header(True, "About")
    print("Developers:")
    for n in range(0, len(names)):
        if (names[n]==" "):
            break
        print(" - "+names[n])
Example #22
0
def start(app, status=False):
    if status:
        import term  #, easydraw
        if app == "" or app == "launcher":
            term.header(True, "Loading menu...")
            #easydraw.messageCentered("PLEASE WAIT\nStarting the menu...", True, "/media/busy.png")
        else:
            term.header(True, "Loading application " + app + "...")
            #easydraw.messageCentered("PLEASE WAIT\nStarting '"+app+"'...", True, "/media/busy.png")
    machine.RTC().write_string(app)
    reboot()
Example #23
0
def onSleep(idleTime=None):
    if idleTime == None:
        idleTime = virtualtimers.idle_time()
    gui_redraw = True
    drawTask(True)
    if (idleTime >= 86400000):  #One day
        idleTime = 0
    if idleTime < 1:
        term.header(True, "Sleeping until touchbutton is pressed...")
    else:
        term.header(True, "Sleeping for " + str(idleTime) + "ms...")
    system.sleep(idleTime)
def sleep(duration=0, status=False):
    import time, os

    if (duration >= 86400000):  #One day
        duration = 0
    if status:
        import term
        if duration < 1:
            term.header(True, "Sleeping forever...")
        else:
            term.header(True, "Sleeping for " + str(duration) + "ms...")
    time.sleep(0.05)
    machine.deepsleep(duration)
Example #25
0
def scan():
	term.header(True, "WiFi setup")
	print("Scanning...")
	sta_if = network.WLAN(network.STA_IF)
	sta_if.active(True)
	ssid_result = sta_if.scan()
	ssid_list = []
	for ssid in ssid_result:
		ssid_list.append(ssid[0].decode('utf-8', 'ignore'))
	ssid_list.append("< Back")
	option = term.menu("WiFi setup - Select a network", ssid_list)
	if option != len(ssid_list)-1:
		password(ssid_result[option][0].decode('utf-8', 'ignore'), ssid_result[option][4])
Example #26
0
def start_sleeping(sleepTime=0):
    machine.RTC().wake_on_ext0(pin=machine.Pin(25), level=0)

    term.header(True, "Going to sleep...")
    if (sleepTime >= 86400000):  #One day
        sleepTime = 0
    if (sleepTime < 1):
        print("Sleeping until touchbutton is pressed...")
    else:
        print("Sleeping for " + str(sleepTime) + "ms...")
    time.sleep(0.05)
    badge.eink_busy_wait()
    machine.deepsleep(sleepTime)
Example #27
0
def sleep(duration=0, status=False):
    for i in range(6):
        samd.led(i, 0, 0, 0)
    machine.RTC().wake_on_ext0(pin=machine.Pin(25), level=0)
    if (duration >= 86400000):  #One day
        duration = 0
    if status:
        if duration < 1:
            term.header(True, "Sleeping until touch button is pressed!")
        else:
            term.header(True, "Sleeping for " + str(duration) + "ms...")
    time.sleep(0.05)
    machine.deepsleep(duration)
Example #28
0
def sleep(duration=0, status=False):
    machine.RTC().wake_on_ext0(pin=machine.Pin(25), level=0)
    machine.RTC().wake_on_ext1(
        [machine.Pin(12, machine.Pin.IN, machine.Pin.PULL_UP)], 0)
    if (duration >= 86400000):  #One day
        duration = 0
    if status:
        if duration < 1:
            term.header(True, "Sleeping until touchbutton is pressed...")
        else:
            term.header(True, "Sleeping for " + str(duration) + "ms...")
    time.sleep(0.1)
    machine.deepsleep(duration)
Example #29
0
def sleep(duration=0, status=False):
    if not device.configureWakeupSource():
        print("No wakeup source available, rebooting...")
        reboot()
        return
    if (duration >= 86400000):  #One day
        duration = 0
    if status:
        if duration < 1:
            term.header(True, "Sleeping until a touch button is pressed!")
        else:
            term.header(True, "Sleeping for " + str(duration) + "ms...")
    device.prepareForSleep()
    machine.deepsleep(duration)
Example #30
0
def sleep(duration=0, status=False):
    # Not working for Disobey 2020 as the pins are not in the RTC domain
    machine.RTC().wake_on_ext0(pin=machine.Pin(25), level=0)
    #machine.RTC().wake_on_ext1([machine.Pin(5, machine.Pin.IN, machine.Pin.PULL_UP)], 0)
    #---
    if (duration >= 86400000):  #One day
        duration = 0
    if status:
        if duration < 1:
            term.header(True, "Sleeping until touch button is pressed!")
        else:
            term.header(True, "Sleeping for " + str(duration) + "ms...")
    time.sleep(0.05)
    machine.deepsleep(duration)