Badger2040: Improve launcher.
This commit is contained in:
parent
75d0112421
commit
5c2cc7ebf8
|
@ -54,7 +54,9 @@ def state_running():
|
||||||
|
|
||||||
|
|
||||||
def state_clear_running():
|
def state_clear_running():
|
||||||
|
running = state_running()
|
||||||
state_modify("launcher", {"running": "launcher"})
|
state_modify("launcher", {"running": "launcher"})
|
||||||
|
return running != "launcher"
|
||||||
|
|
||||||
|
|
||||||
def state_set_running(app):
|
def state_set_running(app):
|
||||||
|
|
|
@ -94,7 +94,7 @@ if TOTAL_IMAGES == 0:
|
||||||
|
|
||||||
badger_os.state_load("image", state)
|
badger_os.state_load("image", state)
|
||||||
|
|
||||||
changed = not display.woken()
|
changed = not badger2040.woken_by_button()
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -10,9 +10,13 @@ import badger_os
|
||||||
# Reduce clock speed to 48MHz, that's fast enough!
|
# Reduce clock speed to 48MHz, that's fast enough!
|
||||||
machine.freq(48000000)
|
machine.freq(48000000)
|
||||||
|
|
||||||
|
changed = False
|
||||||
|
exited_to_launcher = False
|
||||||
|
woken_by_button = badger2040.woken_by_button() # Must be done before we clear_pressed_to_wake
|
||||||
|
|
||||||
if badger2040.pressed_to_wake(badger2040.BUTTON_A) and badger2040.pressed_to_wake(badger2040.BUTTON_C):
|
if badger2040.pressed_to_wake(badger2040.BUTTON_A) and badger2040.pressed_to_wake(badger2040.BUTTON_C):
|
||||||
# Pressing A and C together at start quits app
|
# Pressing A and C together at start quits app
|
||||||
badger_os.state_clear_running()
|
exited_to_launcher = badger_os.state_clear_running()
|
||||||
badger2040.clear_pressed_to_wake()
|
badger2040.clear_pressed_to_wake()
|
||||||
else:
|
else:
|
||||||
# Otherwise restore previously running app
|
# Otherwise restore previously running app
|
||||||
|
@ -33,7 +37,8 @@ state = {
|
||||||
}
|
}
|
||||||
|
|
||||||
badger_os.state_load("launcher", state)
|
badger_os.state_load("launcher", state)
|
||||||
changed = state["running"] != "launcher"
|
|
||||||
|
display.invert(state["inverted"])
|
||||||
|
|
||||||
icons = bytearray(launchericons.data())
|
icons = bytearray(launchericons.data())
|
||||||
icons_width = 576
|
icons_width = 576
|
||||||
|
@ -206,16 +211,11 @@ def button(pin):
|
||||||
render()
|
render()
|
||||||
|
|
||||||
|
|
||||||
if changed:
|
if exited_to_launcher or not woken_by_button:
|
||||||
# Wait for any wakeup button to be released
|
|
||||||
while display.pressed(badger2040.BUTTON_A) or display.pressed(badger2040.BUTTON_B) or display.pressed(badger2040.BUTTON_C) or display.pressed(badger2040.BUTTON_UP) or display.pressed(badger2040.BUTTON_DOWN):
|
|
||||||
time.sleep(0.01)
|
|
||||||
display.update_speed(badger2040.UPDATE_MEDIUM)
|
display.update_speed(badger2040.UPDATE_MEDIUM)
|
||||||
render()
|
render()
|
||||||
|
|
||||||
display.update_speed(badger2040.UPDATE_FAST)
|
display.update_speed(badger2040.UPDATE_FAST)
|
||||||
if not changed and not display.woken():
|
|
||||||
render()
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if display.pressed(badger2040.BUTTON_A):
|
if display.pressed(badger2040.BUTTON_A):
|
||||||
|
|
Loading…
Reference in New Issue