Skip to content

Commit

Permalink
Merge pull request #2 from pimoroni/dev
Browse files Browse the repository at this point in the history
Ongoing dev for v0.0.2
  • Loading branch information
Gadgetoid authored Mar 30, 2023
2 parents 7032a6f + 62deec7 commit 52baf7f
Show file tree
Hide file tree
Showing 32 changed files with 985 additions and 401 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/micropython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
types: [created]

env:
MICROPYTHON_VERSION: f80d040c038c343b0709eba537014fb52bc8115e
MICROPYTHON_VERSION: 38e7b842c6bc8122753cbf0845eb141f28fbcb72
PIMORONI_PICO_VERSION: v1.19.18

jobs:
deps:
Expand Down Expand Up @@ -74,6 +75,7 @@ jobs:
env:
RELEASE_FILE: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython.uf2
RELEASE_FILE_WITH_OS: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython-with-badger-os.uf2
FIRMWARE_DIR: "$GITHUB_WORKSPACE/badger2040/firmware"
BOARD_DIR: "$GITHUB_WORKSPACE/badger2040/firmware/${{matrix.board}}"
BADGER_OS_DIR: "$GITHUB_WORKSPACE/badger2040/badger_os"

Expand Down Expand Up @@ -104,6 +106,7 @@ jobs:
- uses: actions/checkout@v3
with:
repository: pimoroni/pimoroni-pico
ref: ${{env.PIMORONI_PICO_VERSION}}
submodules: true
path: pimoroni-pico

Expand All @@ -114,12 +117,12 @@ jobs:
ref: v0.0.1
path: dir2uf2

# HACK: Patch Wakeup GPIO features into Pico SDK
- name: "HACK: Wakeup GPIO Patch"
# HACK: Patch startup overclock into Pico SDK
- name: "HACK: Startup Overclock Patch"
shell: bash
working-directory: micropython/lib/pico-sdk
run: |
git apply "${{env.BOARD_DIR}}/wakeup_gpio.patch"
git apply "${{env.FIRMWARE_DIR}}/startup_overclock.patch"
# Install apt packages
- name: Install CCache & Compiler
Expand Down
46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,44 @@
# Badger 2040 & Badger 2040 W
## Firmware, Examples & Documentation
# Badger 2040 & Badger 2040 W <!-- omit in toc -->
## Firmware, Examples & Documentation <!-- omit in toc -->

Badger 2040 and Badger 2040 W are maker-friendly all-in-one badge wearables, featuring a 2.9", 296x128 pixel, monochrome e-paper display.

- [Install](#install)
- [Badger 2040](#badger-2040)
- [Badger 2040 W](#badger-2040-w)

## Install

Grab the latest release from [https://github.com/pimoroni/badger2040/releases/latest](https://github.com/pimoroni/badger2040/releases/latest)

There are four .uf2 files to pick from.

:warning: Those marked `with-badger-os` contain a full filesystem image that will overwrite both the firmware *and* filesystem of your Badger:

* pimoroni-badger2040-vX.X.X-micropython-with-badger-os.uf2
* pimoroni-badger2040w-vX.X.X-micropython-with-badger-os.uf2

The regular builds just include the firmware, and leave your files alone:

* pimoroni-badger2040-vX.X.X-micropython.uf2
* pimoroni-badger2040w-vX.X.X-micropython.uf2

### Badger 2040

1. Connect your Badger 2040 W to your computer using a USB A to C cable.

2. Reset your device into bootloader mode by holding BOOT/USR and pressing the RST button next to it.

3. Drag and drop one of the `badger2040` .uf2 files to the "RPI-RP2" drive that appears.

4. Your device should reset and, if you used a `with-badger-os` variant, show the Badger OS Launcher.

### Badger 2040 W

1. Connect your Badger 2040 to your computer using a USB A to microB cable.

2. Reset your device into bootloader mode by holding BOOTSEL (onboard the Pico W) and pressing RESET (next to the qw/st connector).

3. Drag and drop one of the `badger2040w` .uf2 files to the "RPI-RP2" drive that appears.

4. Your device should reset and, if you used a `with-badger-os` variant, show the Badger OS Launcher.
73 changes: 45 additions & 28 deletions badger_os/readme.md → badger_os/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Badger 2040 W MicroPython Examples <!-- omit in toc -->

- [About Badger 2040 W](#about-badger-2040-w)
- [Badger 2040 W and PicoGraphics](#badger-2040-w-and-picographics)
# Badger 2040 MicroPython Examples <!-- omit in toc -->

These MicroPython examples demonstrate a variety of applications and are distributed as a sort of "OS" for Badger 2040.

They should help you get started quickly and give you something to modify for your own requirements.

- [Examples](#examples)
- [Badge](#badge)
- [Clock](#clock)
Expand All @@ -17,25 +19,6 @@
- [Weather](#weather)
- [Other Resources](#other-resources)


## About Badger 2040 W

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.

- :link: [Badger 2040 W store page](https://shop.pimoroni.com/products/badger-2040-w)

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.

- [MicroPython releases](https://github.com/pimoroni/pimoroni-pico/releases)
- [Installing MicroPython](../../../setting-up-micropython.md)

## Badger 2040 W and PicoGraphics

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).

- [Badger 2040 W function reference](../../modules/badger2040w/README.md)
- [PicoGraphics function reference](../../modules/picographics/README.md)

## Examples

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

Customisable name badge example.

Loads badge details from the `/badges` directory on the device, using a file called `badge.txt` which should contain:

* Company
* Name
* Detail 1 title
* Detail 1 text
* Detail 2 title
* Detail 2 text
* Badge image path

For example:

```txt
mustelid inc
H. Badger
RP2040
2MB Flash
E ink
296x128px
/badges/badge.jpg
```

The image should be a 104x128 pixel JPEG. Any colours other than black/white will be dithered.

### Clock
[clock.py](examples/clock.py)

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

Press button B to switch the clock into time set mode.

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.

On Badger 2040 W it will set the external RTC and the time will persist even after sleep/wake.

### Ebook
[ebook.py](examples/ebook.py)

View text files on Badger.

Currently reads an abridged copy of "The Wind in the Willows" out of the `/books` directory.

### Fonts
[fonts.py](examples/fonts.py)

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

### Help
[help.py](examples/help.py)

How to navigate the launcher.
Gives instructions on to navigate the launcher.

### Image
[image.py](examples/image.py)

Display .jpegs on Badger.
Display JPEG images. Images are read out of the `/images` directory on device.

Press button B to show/hide the image filename.

### Info
[info.py](examples/info.py)

Info about Badger 2040 W.
Info about Badger 2040.

### List
[list.py](examples/list.py)

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

### Net Info
[net_info.py](examples/net_info.py)
Expand Down
15 changes: 6 additions & 9 deletions badger_os/examples/badge.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import time
import badger2040
import badger_os
import jpegdec


# Global Constants
WIDTH = badger2040.WIDTH
HEIGHT = badger2040.HEIGHT
Expand Down Expand Up @@ -110,6 +109,8 @@ def draw_badge():
display.text(detail2_title, LEFT_PADDING, HEIGHT - (DETAILS_HEIGHT // 2), WIDTH, DETAILS_TEXT_SIZE)
display.text(detail2_text, LEFT_PADDING + name_length + DETAIL_SPACING, HEIGHT - (DETAILS_HEIGHT // 2), WIDTH, DETAILS_TEXT_SIZE)

display.update()


# ------------------------------
# Program setup
Expand Down Expand Up @@ -160,13 +161,9 @@ def draw_badge():
draw_badge()

while True:
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):
badger_os.warning(display, "To change the text, connect Badger2040 to a PC, load up Thonny, and modify badge.txt")
time.sleep(4)

draw_badge()

display.update()
# Sometimes a button press or hold will keep the system
# powered *through* HALT, so latch the power back on.
display.keepalive()

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

0 comments on commit 52baf7f

Please sign in to comment.