From 81a41d6ed733333734c8e9fc8b2961cf338a89c0 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 21 Mar 2023 15:59:42 +0000 Subject: [PATCH] Badger OS: Fix fonts, image and list for #6. 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. --- badger_os/examples/fonts.py | 3 ++- badger_os/examples/image.py | 5 ++++- badger_os/examples/list.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/badger_os/examples/fonts.py b/badger_os/examples/fonts.py index f9d949d..b66dea4 100644 --- a/badger_os/examples/fonts.py +++ b/badger_os/examples/fonts.py @@ -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 @@ -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): diff --git a/badger_os/examples/image.py b/badger_os/examples/image.py index d721746..95e4036 100644 --- a/badger_os/examples/image.py +++ b/badger_os/examples/image.py @@ -86,7 +86,7 @@ def show_image(n): badger_os.state_load("image", state) -changed = not badger2040.woken_by_button() +changed = True while True: @@ -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() diff --git a/badger_os/examples/list.py b/badger_os/examples/list.py index bf9591c..3232124 100644 --- a/badger_os/examples/list.py +++ b/badger_os/examples/list.py @@ -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, }