Beispiel #1
0
def prompt_boolean(text,
                   title=version.dialog_title,
                   true_text="Yes",
                   false_text="No",
                   width=ugfx.width(),
                   height=ugfx.height(),
                   font="Roboto_Regular12",
                   cb=None):
    global wait_for_interrupt, button_pushed

    easydraw.msg(text, title, True)
    easydraw.msg_nosplit("[" + false_text + "/" + true_text + "]")

    def done(result):
        ugfx.input_attach(ugfx.JOY_LEFT, dummy_button_cb)
        ugfx.input_attach(ugfx.JOY_RIGHT, dummy_button_cb)
        ugfx.input_attach(ugfx.JOY_UP, dummy_button_cb)
        ugfx.input_attach(ugfx.JOY_DOWN, dummy_button_cb)
        ugfx.input_attach(ugfx.BTN_B, dummy_button_cb)
        ugfx.input_attach(ugfx.BTN_START, dummy_button_cb)
        if cb:
            cb(result)
        return result

    def syncSuccess(evt):
        if evt:
            # We'd like promises here, but for now this should do
            global wait_for_interrupt, button_pushed
            button_pushed = "A"
            wait_for_interrupt = False

    def syncCancel(evt):
        if evt:
            # We'd like promises here, but for now this should do
            global wait_for_interrupt, button_pushed
            button_pushed = "B"
            wait_for_interrupt = False

    def asyncSuccess(evt):
        if evt:
            done(True)

    def asyncCancel(evt):
        if evt:
            done(False)

    ugfx.input_init()

    ugfx.set_lut(ugfx.LUT_NORMAL)
    ugfx.flush()

    ugfx.input_attach(ugfx.JOY_LEFT, dummy_button_cb)
    ugfx.input_attach(ugfx.JOY_RIGHT, dummy_button_cb)
    ugfx.input_attach(ugfx.JOY_UP, dummy_button_cb)
    ugfx.input_attach(ugfx.JOY_DOWN, dummy_button_cb)
    ugfx.input_attach(ugfx.BTN_B, dummy_button_cb)
    ugfx.input_attach(ugfx.BTN_START, dummy_button_cb)

    if false_text != None:
        ugfx.input_attach(version.btn_cancel,
                          asyncCancel if cb else syncCancel)
    ugfx.input_attach(version.btn_ok, asyncSuccess if cb else syncSuccess)

    if cb:
        return
    else:
        wait_for_interrupt = True
        while wait_for_interrupt:
            time.sleep(0.2)

        if button_pushed == "B": return done(False)
        return done(True)
Beispiel #2
0
easydraw.msg("Welcome!", "Firmware update", True)

title = "Update check"
message = "Unknown state!"
		
if wifi.status():
	info = otacheck.download_info()
	if info:
			print("Server has: ",info['name']," (Build "+str(info['build'])+")")
			if info["build"] > version.build:
				print("Update available!")
				easydraw.msg(" ")
				easydraw.msg("An update is available!")
				easydraw.msg(" ")
				easydraw.msg_nosplit("Currently installed: "+version.name+" (Build "+str(version.build)+")")
				easydraw.msg_nosplit("Available          : "+info["name"]+" (Build "+str(info["build"])+")")
				easydraw.msg(" ")
				easydraw.msg("Press A to start the update")
				easydraw.msg("Press B to cancel")
				title = "Firmware update available"
				message  = "A new firmware version is available. Update?\n"
				message += "Currently installed: "+version.name+" (Build "+str(version.build)+")\n"
				message += "Available          : "+info["name"]+" (Build "+str(info["build"])+")"
			elif info["build"] < version.build:
				print("Server has an older version.")
				easydraw.msg(" ")
				easydraw.msg("A downgrade is available!")
				easydraw.msg(" ")
				easydraw.msg_nosplit("Currently installed: "+version.name+" (Build "+str(version.build)+")")
				easydraw.msg_nosplit("Available          : "+info["name"]+" (Build "+str(info["build"])+")")
Beispiel #3
0
import tasks.otacheck as otacheck, easydraw, term, appglue, time, version, easywifi, badge, ugfx, orientation

orientation.default()

term.header(True, "Update check")
print("Checking for updates...")
print("")
print("Currently installed:", version.name,
      "(Build " + str(version.build) + ")")

easydraw.msg("Current version:", "Update check", True)
easydraw.msg_nosplit(str(version.build) + ") " + version.name)
time.sleep(3)
available = 0

badge.nvs_set_u8('badge', 'OTA.ready', 0)


def start(pressed):
    if pressed:
        appglue.start_ota()


if not easywifi.status():
    if not easywifi.enable():
        easydraw.msg("Error: could not connect to WiFi!")

title = "Update check"
message = "?? Unknown state ??"

if easywifi.status():
import tasks.otacheck as otacheck, easydraw, term, system, time, version, easywifi, badge, ugfx, orientation

orientation.default()

term.header(True, "Update check")
print("Checking for updates...")
print("")
print("Currently installed:",version.name,"(Build "+str(version.build)+")")

easydraw.msg("Current version:", "Update check", True)
easydraw.msg_nosplit(str(version.build)+") "+version.name)
time.sleep(3)
available = 0

badge.nvs_set_u8('badge','OTA.ready',0)

def cancel(pressed):
	if pressed:
		system.home()

def start(pressed):
	if pressed:
		system.ota()

if not easywifi.status():
	if not easywifi.enable():
		easydraw.msg("Error: could not connect to WiFi!")

title = "Update check"
message = "?? Unknown state ??"