MicroPython demos of custom bitmap fonts, a train-themed "Ok to Wake" clock, and more for the Pimoroni Cosmic Unicorn LED Matrix with built-in Raspberry Pi Pico W 2040.
Table of Contents:
- Custom Tiny Bitmap Fonts
- Ok to Wake Train Clock
- Traffic Signals
The default bitmap fonts that come PicoGraphics library are awesome, but sometimes you need a smaller font to display lots of numbers and text on LED matrices such as the Cosmic Unicorn. Further, some PicoGraphics fonts are variable width which cause display issues for timers and clocks.
LEFT: default Cosmic Unicorn bitmap fonts, RIGHT: new fonts available via this bitfonts library

- Upload
bitfonts.pyfile to the Pico W - Import in your MicroPython .py project as follows (only import fonts you need for your project)
from bitfonts import BitFont, font2x5, font3x5, font4x5, font5x9
- Then, initialise the
bitfontClass immediately after you initializePicoGraphics:
# INITIALISE GALACTIC UNICORN
cu = CosmicUnicorn()
graphics = PicoGraphics(DISPLAY)
bitfont = BitFont(graphics)
- Finally, use the draw_text method to draw the font
bitfont.draw_text("my text string",0,16,font3x5)
See this demo project custom_font.py for an example of a working demo of the custom fonts used on the Cosmic Unicorn.
Function draw_text accepts a str of the text to be displayed, an int of the x position (where 0 = leftmost), an int of the y position (where 0 = topmost), and a dict font array as defined in bitfonts.py file such as this 2x5 font.
ONLY 0 1 2 3 4 5 6 7 8 9 characters are supported across all fonts. Some fonts include all alphanumeric characters. Some fonts include delimiters and limited emojis.
When using in your project, first refer to the source code to see which characaters are supported. It is very easy to add your own characters. Then, please contribute them back to this repo! :)
- Thanks to https://github.com/NiVZ78/galactic_unicorn_custom_font for improved bitmap font parser and definition format
- Thanks to https://github.com/leswright1977/picofont for 5x9 custom bitmap font example
- This repo is originally forked from Pimoroni's Cosmic Unicorn MicroPython Examples
To be written. See twitter for now: https://twitter.com/kfarr/status/1663203677828694022 and this file: https://github.com/kfarr/cosmic-unicorn-playground/blob/main/train_clock.py
=== Original readme:
- About Cosmic Unicorn
- Cosmic Unicorn and PicoGraphics
- Examples
- Wireless Examples
- NumPy examples
- Other Examples
- Other Resources
Cosmic Unicorn offers 32x32 bright RGB LEDs driven by Pico W's PIO in addition to a 1W amplifier + speaker, a collection of system and user buttons, and two Qw/ST connectors for adding external sensors and devices. Woha!
Cosmic Unicorn ships with MicroPython firmware pre-loaded, but you can download the most recent version at the link below (you'll want the cosmic-unicorn image).
The easiest way to start displaying cool stuff on Cosmic Unicorn is using our Cosmic Unicorn module (which contains a bunch of helpful functions for interacting with the buttons, adjusting brightness and suchlike) and our PicoGraphics library, which is chock full of useful functions for drawing on the LED matrix.
Clock example with (optional) NTP synchronization. You can adjust the brightness with LUX + and -, and resync the time by pressing A.
Random LEDs blink on and off mimicing the look of a movie super computer doing its work in the eighties. You can adjust the brightness with LUX + and -.
Displays some text, gradients and colours and demonstrates button use. You can adjust the brightness with LUX + and -.
Displays some text, gradients and colours and demonstrates button use. Also demonstrates some of the audio / synth features.
- Button A plays a synth tune
- Button B plays a solo channel of the synth tune
- Button C plays a sinewave (it's frequency can be adjusted with VOL + and -)
- Button D plays a second sinewave (it's frequency can be adjusted with LUX + and -)
- Sleep button stops the sounds
A pretty, procedural fire effect. Switch between landscape fire and vertical fire using the A and B buttons! You can adjust the brightness with LUX + and -.
A 70s-tastic, procedural rainbow lava lamp. You can adjust the brightness with LUX + and -.
A collection of copies of classic terminal styles including C64, MS-DOS, Spectrum, and more. Images and text are drawn pixel by pixel from a pattern of Os and Xs. You can adjust the brightness with LUX + and -.
Some good old fashioned rainbows! You can adjust the cycling speed with A and B, stripe width with C and D, hue with VOL + and -, and the brightness with LUX + and -. The sleep button stops the animation (can be started again with A or B).
Display scrolling wisdom, quotes or greetz. You can adjust the brightness with LUX + and -.
Calendar example with (optional) NTP synchronization. You can adjust the brightness with LUX + and -, and resync the date by pressing C.
These examples need WIFI_CONFIG.py and network_manager.py (from the common directory) to be saved to your Pico W. Open up WIFI_CONFIG.py in Thonny to add your wifi details (and save it when you're done).
Updates one pixel every two minutes to display the most recent #Cheerlights colour. Discover the most popular colours over time, or use it as an avant garde (but colourful) 32 hour clock! Find out more about the Cheerlights API at https://cheerlights.com/
You can adjust the brightness with LUX + and -.
Draw on your Cosmic Unicorn from another device in real time, over wifi!
This example needs the micropython-phew and microdot libraries (you can install these using Thonny's 'Tools > Manage Packages').
This example uses the Coinbase open API to collect the current exchange rates of various cryptocurrencies.
Press A to change to a different base exchange currency.
Display scrolling wisdom, quotes or greetz... from another computer or device!
You can adjust the brightness with LUX + and -.
Requires logging.mpy and tinyweb from micropython/examples/common - copy these into the lib folder on your Pico W. You'll also need index.html to be saved alongside html_text.py.
Display current weather data from the Open-Meteo weather API.
The examples in the folder use numpy-like array functions contained in the ulab library for super fast graphical effects.
If you want to get the demo reel that Cosmic Unicorn ships with back, copy the contents of this launch folder to your Pico W.
Here are some cool Cosmic Unicorn community projects and resources that you might find useful / inspirational! Note that code at the links below has not been tested by us and we're not able to offer support with it.