From 0410b7c775cfc413cbf507755e5e95bae97e05ab Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 7 Feb 2023 15:03:54 +0000 Subject: [PATCH] Badger2040W: Add thickness back. Better error backdrop. --- micropython/examples/badger2040w/examples/badge.py | 1 + micropython/examples/badger2040w/examples/ebook.py | 2 ++ micropython/examples/badger2040w/examples/help.py | 1 + micropython/examples/badger2040w/examples/list.py | 1 + micropython/examples/badger2040w/lib/badger_os.py | 8 +++++++- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/micropython/examples/badger2040w/examples/badge.py b/micropython/examples/badger2040w/examples/badge.py index 86ccc3ac..3377d79c 100644 --- a/micropython/examples/badger2040w/examples/badge.py +++ b/micropython/examples/badger2040w/examples/badge.py @@ -119,6 +119,7 @@ def draw_badge(): display = badger2040w.Badger2040W() display.led(128) display.set_update_speed(badger2040w.UPDATE_NORMAL) +display.set_thickness(2) jpeg = jpegdec.JPEG(display.display) diff --git a/micropython/examples/badger2040w/examples/ebook.py b/micropython/examples/badger2040w/examples/ebook.py index 0091af84..31fa27b0 100644 --- a/micropython/examples/badger2040w/examples/ebook.py +++ b/micropython/examples/badger2040w/examples/ebook.py @@ -20,6 +20,7 @@ TEXT_PADDING = 4 TEXT_WIDTH = WIDTH - TEXT_PADDING - TEXT_PADDING - ARROW_WIDTH FONTS = ["sans", "gothic", "cursive", "serif"] +THICKNESSES = [2, 1, 1, 2] # ------------------------------ # Drawing functions # ------------------------------ @@ -91,6 +92,7 @@ def render_page(): next_pos = pos add_newline = False display.set_font(FONTS[state["font_idx"]]) + display.set_thickness(THICKNESSES[state["font_idx"]]) while True: # Read a full line and split it into words diff --git a/micropython/examples/badger2040w/examples/help.py b/micropython/examples/badger2040w/examples/help.py index 8e08a8c8..f51b0403 100644 --- a/micropython/examples/badger2040w/examples/help.py +++ b/micropython/examples/badger2040w/examples/help.py @@ -6,6 +6,7 @@ LINE_HEIGHT = 20 display = badger2040w.Badger2040W() display.led(128) +display.set_thickness(2) # Clear to white display.set_pen(15) diff --git a/micropython/examples/badger2040w/examples/list.py b/micropython/examples/badger2040w/examples/list.py index f74298ad..01137a7c 100644 --- a/micropython/examples/badger2040w/examples/list.py +++ b/micropython/examples/badger2040w/examples/list.py @@ -181,6 +181,7 @@ items_per_page = 0 display = badger2040w.Badger2040W() display.led(128) display.set_font("sans") +display.set_thickness(2) if changed: display.set_update_speed(badger2040w.UPDATE_FAST) else: diff --git a/micropython/examples/badger2040w/lib/badger_os.py b/micropython/examples/badger2040w/lib/badger_os.py index 98a14fa3..3eaaec63 100644 --- a/micropython/examples/badger2040w/lib/badger_os.py +++ b/micropython/examples/badger2040w/lib/badger_os.py @@ -145,7 +145,7 @@ def launch(file): # Draw an overlay box with a given message within it -def warning(display, message, width=badger2040.WIDTH - 40, height=badger2040.HEIGHT - 40, line_spacing=20, text_size=0.6): +def warning(display, message, width=badger2040.WIDTH - 20, height=badger2040.HEIGHT - 20, line_spacing=20, text_size=0.6): print(message) if display is None: @@ -156,6 +156,12 @@ def warning(display, message, width=badger2040.WIDTH - 40, height=badger2040.HEI display.set_pen(12) display.rectangle((badger2040.WIDTH - width) // 2, (badger2040.HEIGHT - height) // 2, width, height) + width -= 20 + height -= 20 + + display.set_pen(15) + display.rectangle((badger2040.WIDTH - width) // 2, (badger2040.HEIGHT - height) // 2, width, height) + # Take the provided message and split it up into # lines that fit within the specified width words = message.split(" ")