Badger2040: Improve launcher.
This commit is contained in:
parent
75d0112421
commit
5c2cc7ebf8
|
@ -54,7 +54,9 @@ def state_running():
|
|||
|
||||
|
||||
def state_clear_running():
|
||||
running = state_running()
|
||||
state_modify("launcher", {"running": "launcher"})
|
||||
return running != "launcher"
|
||||
|
||||
|
||||
def state_set_running(app):
|
||||
|
|
|
@ -94,7 +94,7 @@ if TOTAL_IMAGES == 0:
|
|||
|
||||
badger_os.state_load("image", state)
|
||||
|
||||
changed = not display.woken()
|
||||
changed = not badger2040.woken_by_button()
|
||||
|
||||
|
||||
while True:
|
||||
|
|
|
@ -10,9 +10,13 @@ import badger_os
|
|||
# Reduce clock speed to 48MHz, that's fast enough!
|
||||
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):
|
||||
# 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()
|
||||
else:
|
||||
# Otherwise restore previously running app
|
||||
|
@ -33,7 +37,8 @@ state = {
|
|||
}
|
||||
|
||||
badger_os.state_load("launcher", state)
|
||||
changed = state["running"] != "launcher"
|
||||
|
||||
display.invert(state["inverted"])
|
||||
|
||||
icons = bytearray(launchericons.data())
|
||||
icons_width = 576
|
||||
|
@ -206,16 +211,11 @@ def button(pin):
|
|||
render()
|
||||
|
||||
|
||||
if changed:
|
||||
# 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)
|
||||
if exited_to_launcher or not woken_by_button:
|
||||
display.update_speed(badger2040.UPDATE_MEDIUM)
|
||||
render()
|
||||
|
||||
display.update_speed(badger2040.UPDATE_FAST)
|
||||
if not changed and not display.woken():
|
||||
render()
|
||||
|
||||
while True:
|
||||
if display.pressed(badger2040.BUTTON_A):
|
||||
|
|
Loading…
Reference in New Issue