From a5efdf8bae61f21c171ec3fd47c21d301388f655 Mon Sep 17 00:00:00 2001 From: Mike Bell Date: Sat, 26 Mar 2022 17:32:27 +0000 Subject: [PATCH] Badger2040: Improve help, info, qrgen --- micropython/examples/badger2040/help.py | 28 +++++++++++++----------- micropython/examples/badger2040/info.py | 7 +++++- micropython/examples/badger2040/qrgen.py | 6 ++++- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/micropython/examples/badger2040/help.py b/micropython/examples/badger2040/help.py index 4f000f71..7d08e4bf 100644 --- a/micropython/examples/badger2040/help.py +++ b/micropython/examples/badger2040/help.py @@ -2,7 +2,7 @@ import badger2040 from badger2040 import WIDTH TEXT_SIZE = 0.45 -LINE_HEIGHT = 16 +LINE_HEIGHT = 20 display = badger2040.Badger2040() display.led(128) @@ -12,29 +12,31 @@ display.rectangle(0, 0, WIDTH, 16) display.thickness(1) display.pen(15) display.text("badgerOS", 3, 8, 0.4) +display.text("help", WIDTH - display.measure_text("help", 0.4) - 4, 8, 0.4) display.pen(0) -y = 16 + int(LINE_HEIGHT / 2) +TEXT_SIZE = 0.62 +y = 20 + int(LINE_HEIGHT / 2) display.thickness(2) -display.text("Normal:", 0, y, TEXT_SIZE) -display.thickness(1) -y += LINE_HEIGHT -display.text("Up / Down - Change launcher page", 0, y, TEXT_SIZE) +display.font("sans") +display.text("Up/Down - Change page", 0, y, TEXT_SIZE) y += LINE_HEIGHT display.text("a, b or c - Launch app", 0, y, TEXT_SIZE) y += LINE_HEIGHT +display.text("a & c - Exit app", 0, y, TEXT_SIZE) y += LINE_HEIGHT -display.thickness(2) -display.text("Hold USER after:", 0, y, TEXT_SIZE) -display.thickness(1) +y += 8 +display.text("Up/Down & User - Font size", 0, y, TEXT_SIZE) y += LINE_HEIGHT -display.text("Up / Down - Change font size", 0, y, TEXT_SIZE) -y += LINE_HEIGHT -display.text("a - Toggle invert", 0, y, TEXT_SIZE) +display.text("a & User - Toggle invert", 0, y, TEXT_SIZE) y += LINE_HEIGHT display.update() -display.halt() + +# Call halt in a loop, on battery this switches off power. +# On USB, the app will exit when A+C is pressed because the launcher picks that up. +while True: + display.halt() diff --git a/micropython/examples/badger2040/info.py b/micropython/examples/badger2040/info.py index f3b05683..3fedefe6 100644 --- a/micropython/examples/badger2040/info.py +++ b/micropython/examples/badger2040/info.py @@ -12,6 +12,7 @@ display.rectangle(0, 0, WIDTH, 16) display.thickness(1) display.pen(15) display.text("badgerOS", 3, 8, 0.4) +display.text("info", WIDTH - display.measure_text("help", 0.4) - 4, 8, 0.4) display.pen(0) @@ -34,4 +35,8 @@ y += LINE_HEIGHT display.text("https://pimoroni.com/badger2040", 0, y, TEXT_SIZE) display.update() -display.halt() + +# Call halt in a loop, on battery this switches off power. +# On USB, the app will exit when A+C is pressed because the launcher picks that up. +while True: + display.halt() diff --git a/micropython/examples/badger2040/qrgen.py b/micropython/examples/badger2040/qrgen.py index f4ea40c8..baf35a85 100644 --- a/micropython/examples/badger2040/qrgen.py +++ b/micropython/examples/badger2040/qrgen.py @@ -65,4 +65,8 @@ for line in detail_text: top += 10 display.update() -display.halt() + +# Call halt in a loop, on battery this switches off power. +# On USB, the app will exit when A+C is pressed because the launcher picks that up. +while True: + display.halt()