Migrating a badger2040 app to badger2350 - Moodbadger?

I’m looking for pointers on how to port a badger2040 MicroPython app to the Badger2350

We have a program called MoodBadger that aids the neurodivergent in expressing an emotional state via icons. It currently runs as the only app on the 2040 Badger. I’d like to migrate the app to the new Badger2350 (e-ink) either as a standalone or as an app in the app set.

The application is a single Python file plus an icon directory and two JSON files. One for configuration and one for updatable state that is saved before a badger2040.turnOff() call. The app uses these Python libraries

import badger2040
import jpegdec
import uio
import ujson

Maybe

  • badger2040 is replaced by badger looks like it does not have to be imported
  • jpegdec is replaced by image looks like it does not have to be imported
  • uio is used to read and write JSON files. It is retained as a Micropython library. Does it need to be imported?
  • ujsion is used to dump and load JSON. It is retained as a Micropython library. Does it need to be imprted?

Sleep / power down
We had badger2040.turn_off() for the original badger is replaced by what?

I had a similar situation with my Tufty code. Basically, I just ran it and fixed the errors that croped up one by one.
Tufty 2040 > code > Tufty 2350

The Badger2040 had some circuitry that did cut power to the device, so the Badger2040 was really off. The Badger2350 is a step backward in this respect: it only switches to deep-sleep. You will notice this if you have very long off-times: power draw of the Badger2350 is probably 5-10 times higher in deep-sleep compared to the off-state of the Badger2040.

If you port your application to an app in the app set as you call it, you probably get the switch to deep-sleep automatically. For a standalone application, you need to call the appropriate method yourself.

In the new API for Badgeware, JSON is built in and just needs importing - details are here: https://badgewa.re/docs/guides/filesystem.md

There’s really quite a lot that’s changed and the new API is a lot more powerful than the old, so it may be worth thinking about rewriting from the ground up to take advantage of that while keeping things user friendly.

As far as sleeping goes, it’s as bablokb says - the badge goes into a deep sleep mode after a few seconds of inactivity. That’s accomplished simply using badge.sleep(), which will wake it up on a button press.

This is a fantastic use of these badges, and my initial beginner’s tutorial (offline at time of writing as I’m updating it to the new firmware version) was written with a view to being easily modifiable for this kind of application. Let me know if there’s anything else you need!