Skip to content

Commit 52baf7f

Browse files
authored
Merge pull request #2 from pimoroni/dev
Ongoing dev for v0.0.2
2 parents 7032a6f + 62deec7 commit 52baf7f

32 files changed

+985
-401
lines changed

.github/workflows/micropython.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
types: [created]
88

99
env:
10-
MICROPYTHON_VERSION: f80d040c038c343b0709eba537014fb52bc8115e
10+
MICROPYTHON_VERSION: 38e7b842c6bc8122753cbf0845eb141f28fbcb72
11+
PIMORONI_PICO_VERSION: v1.19.18
1112

1213
jobs:
1314
deps:
@@ -74,6 +75,7 @@ jobs:
7475
env:
7576
RELEASE_FILE: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython.uf2
7677
RELEASE_FILE_WITH_OS: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython-with-badger-os.uf2
78+
FIRMWARE_DIR: "$GITHUB_WORKSPACE/badger2040/firmware"
7779
BOARD_DIR: "$GITHUB_WORKSPACE/badger2040/firmware/${{matrix.board}}"
7880
BADGER_OS_DIR: "$GITHUB_WORKSPACE/badger2040/badger_os"
7981

@@ -104,6 +106,7 @@ jobs:
104106
- uses: actions/checkout@v3
105107
with:
106108
repository: pimoroni/pimoroni-pico
109+
ref: ${{env.PIMORONI_PICO_VERSION}}
107110
submodules: true
108111
path: pimoroni-pico
109112

@@ -114,12 +117,12 @@ jobs:
114117
ref: v0.0.1
115118
path: dir2uf2
116119

117-
# HACK: Patch Wakeup GPIO features into Pico SDK
118-
- name: "HACK: Wakeup GPIO Patch"
120+
# HACK: Patch startup overclock into Pico SDK
121+
- name: "HACK: Startup Overclock Patch"
119122
shell: bash
120123
working-directory: micropython/lib/pico-sdk
121124
run: |
122-
git apply "${{env.BOARD_DIR}}/wakeup_gpio.patch"
125+
git apply "${{env.FIRMWARE_DIR}}/startup_overclock.patch"
123126
124127
# Install apt packages
125128
- name: Install CCache & Compiler

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
1-
# Badger 2040 & Badger 2040 W
2-
## Firmware, Examples & Documentation
1+
# Badger 2040 & Badger 2040 W <!-- omit in toc -->
2+
## Firmware, Examples & Documentation <!-- omit in toc -->
3+
4+
Badger 2040 and Badger 2040 W are maker-friendly all-in-one badge wearables, featuring a 2.9", 296x128 pixel, monochrome e-paper display.
5+
6+
- [Install](#install)
7+
- [Badger 2040](#badger-2040)
8+
- [Badger 2040 W](#badger-2040-w)
9+
10+
## Install
11+
12+
Grab the latest release from [https://github.com/pimoroni/badger2040/releases/latest](https://github.com/pimoroni/badger2040/releases/latest)
13+
14+
There are four .uf2 files to pick from.
15+
16+
:warning: Those marked `with-badger-os` contain a full filesystem image that will overwrite both the firmware *and* filesystem of your Badger:
17+
18+
* pimoroni-badger2040-vX.X.X-micropython-with-badger-os.uf2
19+
* pimoroni-badger2040w-vX.X.X-micropython-with-badger-os.uf2
20+
21+
The regular builds just include the firmware, and leave your files alone:
22+
23+
* pimoroni-badger2040-vX.X.X-micropython.uf2
24+
* pimoroni-badger2040w-vX.X.X-micropython.uf2
25+
26+
### Badger 2040
27+
28+
1. Connect your Badger 2040 W to your computer using a USB A to C cable.
29+
30+
2. Reset your device into bootloader mode by holding BOOT/USR and pressing the RST button next to it.
31+
32+
3. Drag and drop one of the `badger2040` .uf2 files to the "RPI-RP2" drive that appears.
33+
34+
4. Your device should reset and, if you used a `with-badger-os` variant, show the Badger OS Launcher.
35+
36+
### Badger 2040 W
37+
38+
1. Connect your Badger 2040 to your computer using a USB A to microB cable.
39+
40+
2. Reset your device into bootloader mode by holding BOOTSEL (onboard the Pico W) and pressing RESET (next to the qw/st connector).
41+
42+
3. Drag and drop one of the `badger2040w` .uf2 files to the "RPI-RP2" drive that appears.
43+
44+
4. Your device should reset and, if you used a `with-badger-os` variant, show the Badger OS Launcher.

badger_os/readme.md renamed to badger_os/README.md

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# Badger 2040 W MicroPython Examples <!-- omit in toc -->
2-
3-
- [About Badger 2040 W](#about-badger-2040-w)
4-
- [Badger 2040 W and PicoGraphics](#badger-2040-w-and-picographics)
1+
# Badger 2040 MicroPython Examples <!-- omit in toc -->
2+
3+
These MicroPython examples demonstrate a variety of applications and are distributed as a sort of "OS" for Badger 2040.
4+
5+
They should help you get started quickly and give you something to modify for your own requirements.
6+
57
- [Examples](#examples)
68
- [Badge](#badge)
79
- [Clock](#clock)
@@ -17,25 +19,6 @@
1719
- [Weather](#weather)
1820
- [Other Resources](#other-resources)
1921

20-
21-
## About Badger 2040 W
22-
23-
Badger 2040 W is a programmable E Paper/eInk/EPD badge with 2.4GHz wireless connectivity, powered by Raspberry Pi Pico W. It can go into a deep sleep mode between updates to preserve battery.
24-
25-
- :link: [Badger 2040 W store page](https://shop.pimoroni.com/products/badger-2040-w)
26-
27-
Badger 2040 W ships with MicroPython firmware pre-loaded, but you can download the most recent version at the link below (you'll want the `pimoroni-badger2040w` .uf2). If you download the `-with-examples` file, it will come with examples built in.
28-
29-
- [MicroPython releases](https://github.com/pimoroni/pimoroni-pico/releases)
30-
- [Installing MicroPython](../../../setting-up-micropython.md)
31-
32-
## Badger 2040 W and PicoGraphics
33-
34-
The easiest way to start displaying cool stuff on Badger is by using our `badger2040w` module (which contains helpful functions for interacting with the board hardware) and our PicoGraphics library (which contains a bunch of functions for drawing on the E Ink display).
35-
36-
- [Badger 2040 W function reference](../../modules/badger2040w/README.md)
37-
- [PicoGraphics function reference](../../modules/picographics/README.md)
38-
3922
## Examples
4023

4124
Find out more about how to use these examples in our Learn guide:
@@ -47,40 +30,74 @@ Find out more about how to use these examples in our Learn guide:
4730

4831
Customisable name badge example.
4932

33+
Loads badge details from the `/badges` directory on the device, using a file called `badge.txt` which should contain:
34+
35+
* Company
36+
* Name
37+
* Detail 1 title
38+
* Detail 1 text
39+
* Detail 2 title
40+
* Detail 2 text
41+
* Badge image path
42+
43+
For example:
44+
45+
```txt
46+
mustelid inc
47+
H. Badger
48+
RP2040
49+
2MB Flash
50+
E ink
51+
296x128px
52+
/badges/badge.jpg
53+
```
54+
55+
The image should be a 104x128 pixel JPEG. Any colours other than black/white will be dithered.
56+
5057
### Clock
5158
[clock.py](examples/clock.py)
5259

5360
Clock example with (optional) NTP synchronization and partial screen updates.
5461

62+
Press button B to switch the clock into time set mode.
63+
64+
On Badger 2040 this allows you to set the internal RTC, but it will not survive a sleep/wake cycle even with a connected battery.
65+
66+
On Badger 2040 W it will set the external RTC and the time will persist even after sleep/wake.
67+
5568
### Ebook
5669
[ebook.py](examples/ebook.py)
5770

5871
View text files on Badger.
5972

73+
Currently reads an abridged copy of "The Wind in the Willows" out of the `/books` directory.
74+
6075
### Fonts
6176
[fonts.py](examples/fonts.py)
6277

63-
View all the built in fonts.
78+
A basic example that lets you preview how all of the built-in fonts will appear on the display.
6479

6580
### Help
6681
[help.py](examples/help.py)
6782

68-
How to navigate the launcher.
83+
Gives instructions on to navigate the launcher.
6984

7085
### Image
7186
[image.py](examples/image.py)
7287

73-
Display .jpegs on Badger.
88+
Display JPEG images. Images are read out of the `/images` directory on device.
89+
90+
Press button B to show/hide the image filename.
7491

7592
### Info
7693
[info.py](examples/info.py)
7794

78-
Info about Badger 2040 W.
95+
Info about Badger 2040.
7996

8097
### List
8198
[list.py](examples/list.py)
8299

83-
A checklist to keep track of to-dos or shopping.
100+
A checklist to keep track of to-dos or shopping. Use A/C and Up/Down to navigate and B to check/uncheck items.
84101

85102
### Net Info
86103
[net_info.py](examples/net_info.py)

badger_os/examples/badge.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import time
21
import badger2040
3-
import badger_os
42
import jpegdec
53

4+
65
# Global Constants
76
WIDTH = badger2040.WIDTH
87
HEIGHT = badger2040.HEIGHT
@@ -110,6 +109,8 @@ def draw_badge():
110109
display.text(detail2_title, LEFT_PADDING, HEIGHT - (DETAILS_HEIGHT // 2), WIDTH, DETAILS_TEXT_SIZE)
111110
display.text(detail2_text, LEFT_PADDING + name_length + DETAIL_SPACING, HEIGHT - (DETAILS_HEIGHT // 2), WIDTH, DETAILS_TEXT_SIZE)
112111

112+
display.update()
113+
113114

114115
# ------------------------------
115116
# Program setup
@@ -160,13 +161,9 @@ def draw_badge():
160161
draw_badge()
161162

162163
while True:
163-
if 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):
164-
badger_os.warning(display, "To change the text, connect Badger2040 to a PC, load up Thonny, and modify badge.txt")
165-
time.sleep(4)
166-
167-
draw_badge()
168-
169-
display.update()
164+
# Sometimes a button press or hold will keep the system
165+
# powered *through* HALT, so latch the power back on.
166+
display.keepalive()
170167

171168
# If on battery, halt the Badger to save power, it will wake up if any of the front buttons are pressed
172169
display.halt()

0 commit comments

Comments
 (0)