Skip to content

Commit

Permalink
Badger OS: Fix fonts, image and list for #6.
Browse files Browse the repository at this point in the history
Using `not badger2040.woken_by_button()` to determine if the display should be refreshed on first run prevented these examples from showing their initial display on battery.
  • Loading branch information
Gadgetoid committed Mar 21, 2023
1 parent 5d72e59 commit 81a41d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion badger_os/examples/fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def draw_fonts():
display.led(128)
display.set_update_speed(badger2040.UPDATE_FAST)

changed = not badger2040.woken_by_button()
changed = True

# ------------------------------
# Main program loop
Expand All @@ -118,6 +118,7 @@ def draw_fonts():
if state["selected_font"] < 0:
state["selected_font"] = len(FONT_NAMES) - 1
changed = True

if display.pressed(badger2040.BUTTON_DOWN):
state["selected_font"] += 1
if state["selected_font"] >= len(FONT_NAMES):
Expand Down
5 changes: 4 additions & 1 deletion badger_os/examples/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def show_image(n):

badger_os.state_load("image", state)

changed = not badger2040.woken_by_button()
changed = True


while True:
Expand All @@ -98,13 +98,16 @@ def show_image(n):
if state["current_image"] > 0:
state["current_image"] -= 1
changed = True

if display.pressed(badger2040.BUTTON_DOWN):
if state["current_image"] < TOTAL_IMAGES - 1:
state["current_image"] += 1
changed = True

if display.pressed(badger2040.BUTTON_A):
state["show_info"] = not state["show_info"]
changed = True

if display.pressed(badger2040.BUTTON_B) or display.pressed(badger2040.BUTTON_C):
display.set_pen(15)
display.clear()
Expand Down
2 changes: 1 addition & 1 deletion badger_os/examples/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def draw_checkbox(x, y, size, background, foreground, thickness, tick, padding):
# Program setup
# ------------------------------

changed = not badger2040.woken_by_button()
changed = True
state = {
"current_item": 0,
}
Expand Down

0 comments on commit 81a41d6

Please sign in to comment.