Badger 2040 Tutorial

There appears to be a problem here with 1.18.3
main.py (import launcher)
and witw.txt
are present on the Badger
but you get the following error if you execute main.py from Thonny

Just plugging in the Badger to power no longer runs the demo - it just crashes.

MicroPython v1.18-dirty on 2022-03-04; Pimoroni Badger2040 2MB with RP2040

Type "help()" for more information.
>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'launcher'

Upgrading from 1.18v1 to v1.18.2 works - and can be restored but upgrading to 1.18.3 does not work

Does the contents of main.py need to be changed?

I’m going back to 1.18.2 until this is fixed.

Resetting should still go back to the launcher - sounds like older files hanging around in the flash might be causing problems? (I think main.py used to be import launcher, and now is import _launcher ?)

If you’re having issues upgrading to 1.18.3 I’d probably try -

  • Backing up any scripts you want to save to your computer with Thonny
  • Downloading and copying flash nuke uf2 to your Badger to clear the flash and start from fresh
  • Installing MicroPython again

Thanks, that did it.

main.py does now need the underline.

Thanks for that - it answered a few questions. I’ve followed:
Getting Started with Badger 2040
to change the image for the Badge option in the basic OS, and while I can change the text adding my own image fails. If I remove my image and reboot all is OK. With my image the Badge example fails to run, and then no further examples run either. As far as I can tell the image files is in the correct format and location - 1664 bytes, named badge-image.bin, in the same directory as badge.txt. I’ve placed the file here: https://www.satsignal.eu/badge-image.bin in case it helps. I’ve also written a small program to display the binary image - it appears correct. I’m using 1.18.2. Thanks for any help.

First of all, great tutorial @hel. I had tried figuring things out before that was published and it seems I got there through some trial and error (and eventually, but very importantly, updating the firmware), but reading the tutorial made everything so much clearer for me. That, and I am definitely printing a backplate so I can safely make use of a LiPo to power my Badger 2040.

From the tutorial and the image documentation in the repo, I am still left with one gap. I would like to customise the launcher icons, but feel I am missing something that someone can nudge me in thr right direction for.

In the 1.18.3 repo update, I see launcher.py has import launchericons. This is presumably for the icons that are associated with the example scripts that come pre-bundled. I found the launcher icons.png, that I assume a .bin file gets built (e.g. using the convert.py script) from for the icons to be taken from, but I haven’t been able to find any launchericons.py file.

Should there be such a file in the examples in the repo, or am I missing something about how to specify an icons file for the launcher?

You have to convert the file to a .py module, so it can be imported. This is done with convert.py like this:

python3 convert.py --py your_icons_file.png

It will create a your_icons_file.py, which you can then use like this:

import your_icons_file
some_icons = bytearray(your_icons_file.data())

At that point, some_icons can be passed to display.icon() where necessary.

Going back to customizing the launcher, I guess that it should be enough to generate your own iconset as described above, just calling the generated file launchericons.py and uploading it at the root level (/). At worst, you can rename the launcher.py file as main.py and edit that to reference your own icons.

Note that icons must be square and their sizes must be multiple of 8 pixels.

2 Likes

Thanks @toyg. I will give that a try.

When I edit checklist.txt, contrary to what the tutorial says, the first line is just the first item on the list, not the title. How do I change the title?

You’re right, sorry that I hadn’t spotted that had changed!

If you want to change the title of the list you’ll need to upload your own modified copy of the list.py example to your Badger, you can find the code here:

Here is a working boilerplate code for writing C++ programs for Badger 2040 with much-needed instructions. GitHub - avinal/badger2040-boilerplate: This is a bolierplate project for developing Badger 2040 C++ programs.