A little while ago, on Twitter, I bemoaned that CircuitPython didn’t “just work” with the Pimoroni Pico Explorer. On this board, there is a little LCD screen, an ST7789. Theoretically, a CircuitPython library exists for it, but it didn’t quite work when I tried it with the Pico Explorer. On Twitter, @wildestpixel picked up on this and we found that we were trying to do the same thing. On Saturday, they announced that they’d managed it. So, I thought I’d write up how to do it in detail, based on their code which is based itself on this blog post that explains how to use CircuitPython to drive a generic ST7789.
Huge thanks to @wildestpixel for doing the legwork on this! Follow them on Twitter!
Tutorial
As before, I’m using Windows, so if you’re using a Mac or Linux, you will have a slightly different experience getting the firmware on the Pico.
Download and install CircuitPython
The first thing to do is to download the very latest CircuitPython from Adafruit.
This will give you a .uf2 file, which is the CircuitPython firmware for the Pico. We then need to flash the firmware to the Pico.
With your Pico unplugged, hold down BOOTSEL and then plug it in. This will give you a folder RPI-RP2. Drag-and-drop the uf2 file onto the Pico. This will cause it to reboot – voila, the firmware is installed. You will get a new drive called CIRCUITPY on your machine. This is the Pico as a “removable drive”.
Get an editor
Next, download the Mu editor. You could also use Thonny, BUT Mu is what Adafruit recommends, so that’s what we’ll go for. Once downloaded, install it and run it.
Download the Adafruit libraries and install the right one on the Pico
Head over to circuitpython.org and download the latest Bundle. This gets you all the Adafruit libraries.
Unzip it. We need two things from the ‘lib’ folder that you’ve just unzipped.
- The file from the lib folder called adafruit_st7789.mpy. Copy this file and paste it directly into the lib folder on the CIRCUITPY device.
- The entire folder called adafruit_display_text. Copy this folder and paste it into the lib folder on CIRCUITPY so that it is a sub-folder.
That’s all you need to do to use the library in question.
Put the code on the Pico
Go to Wildest Pixel’s Gist on GitHub and copy-and-paste the code into Mu. Save it as ‘code.py’ on the CIRCUITPY drive.
This should make the Pico reboot and you should see something on the screen (as pictured above).
What next?
Well, the next thing to do will be to change the code so that it displays what I want it to. Then, I can integrate the buttons, maybe to rotate the screen to start with, as the code is in the script to do that. After that, I guess I will be taking a look at the CircuitPython documentation over on readthedocs.
Let me know in the comments if you have any trouble!