Libraries and examples to support Pimoroni Pico add-ons in C++ and MicroPython.
MIT License
Hot on the tail of MicroPython v1.22.1 there was a patch release which included some changes to DMA interrupt handler behavior which we had to be a little cautious about embracing. It turns out that these did, in fact, expose some problems in the Hub75/Interstate75 driver which I have - hopefully - fixed. This release is mostly to track MicroPython v1.22.2, but includes a few downstream changes too.
⚠️ WARNING: Like v1.21.1, this build changes the LittleFS filesystem version and will update your board filesystem automatically. Please back up your Python files before updating! You will not be able to revert to a build older than v1.21.1 without trashing your filesystem. ⚠️
For a complete list of MicroPython changes since v1.21.1, see https://github.com/micropython/micropython/compare/v1.22.1...v1.22.2
This release also includes some fixes to PNGDEC (The PNG image decoder) to make it compatible with Badger 2040 / Inky Pack. This is useful, since PNG is a much, much better format for precisely plotting pixels on a 1-bit display.
Finally JPEGDEC gets a working width
and height
method which are usable after you open a file or stream, so you can determine the size of a JPEG before drawing it.
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.22.1...v1.22.2
Published by Gadgetoid 8 months ago
This release is - mostly - to track the latest v1.22.0 release of MicroPython and the v1.22.1 patch release, so you can start enjoying the fixes/changes.
For a complete list of MicroPython changes since v1.21.0, see https://github.com/micropython/micropython/compare/v1.21.0...v1.22.1
⚠️ WARNING: This build changes the LittleFS filesystem version and will update your board filesystem automatically. Please back up your Python files before updating! You will not be able to revert to an older build without trashing your filesystem. ⚠️
Possible known issues:
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.21.0...v1.22.1
Published by Gadgetoid about 1 year ago
This release is - mostly - to track the latest v1.21.0 release of MicroPython, so you can start enjoying the fixes/changes
For a complete list of MicroPython changes since v1.20.6, see https://github.com/micropython/micropython/compare/856e08b1931b88271816a2f60648f6ff332235b2...v1.21.0
⚠️ MicroPython v1.21.0 removes the "u" prefix from a number of modules, and we'll be updating our examples to match in good time. This may break backwards compatibility with older builds, so we'll give v1.21.x versions a little time to bed in first.
We have a couple of downstream fixes, too:
jpeg.open_RAM
it will now work as you might expectsdcard.mpy
in favour of including the micropython-lib sdcard.py
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.20.6...v1.21.0
Published by Gadgetoid about 1 year ago
This release is mostly bugfixes for v1.20.5s vector graphics release.
There's also a bitmap font fix, making a space - in fixed_width mode - count as a fixed-width character, rather than the font's preconfigured space width.
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.20.5...v1.20.6
Published by Gadgetoid about 1 year ago
This release introduces a beta of PicoVector, a library that sits atop PicoGraphics and supplies anti-aliased vector drawing tools using Pretty Poly.
PicoVector is currently available in the following builds:
It includes support for Alright Fonts, allowing you to convert almost any ttf or otf font into a simplified vector format - a sequence of overlapping polygonal contours - which you can use in your PicoGraphics projects.
And, we really mean almost any font -
Currently PicoVector is not fast. Turning off anti-aliasing gets you a little more performance, but it's generally only useful in very limited quantities.
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.20.4...v1.20.5
Published by Gadgetoid about 1 year ago
In our continued quest to make doin'-text-stuff better, this version fixes a couple of text rendering bugs. The code wasn't taking into account letter spacing when calculating the width of words, resulting in auto word-wrap failing to wrap words that didn't fit. Additionally it was ignoring line breaks (\n
) so that manually wrapped text was rendered as one line. Both of these bugs should now bug fixed, and -
You can now rotate Bitmap text in 90 degree intervals. Just provide an angle
argument when drawing text
. Text is always drawn with the origin at the top-left, so a 180 degree rotation for text shown at 0, 0
will disappear the text off the left-edge of the screen. You'll need to offset your text accordingly to avoid this.
Hands up, JPEG was an odd choice of format to start with for embedded graphics. It was grabbing JPEG files over the network and display them on e-ink displays that drove us towards it. Using it for icons in Badger/Badger 2040 was not a great fit- we had to be very careful to avoid JPEG artefacts resulting in spurious pixels. If only there was a better way-
There is! Microcontroller optimisation wizard @bitbank2 - the very same wizard who created the JPEG decoded we use - has a PNG decoder. This release adds that PNG decoder to our codebase and glues it into MicroPython for all your crisp, icon-drawing needs.
Like JPEG decoding, PNG decoding supports loading files from microSD, flash and RAM, but unlike JPEG decoding there are some new options for cropping, scaling and rotating you PNG images. (Note: the order is always crop, scale and rotate.)
A basic example looks something like this:
from pngdec import PNG
png = PNG(display)
png.open_file("fire.png")
png.decode(0, 0)
But say you have a spritesheet with 8x8 sprites and you want to display a 3x2 character from it at 4x scale, you might do something like this:
from pngdec import PNG
png = PNG(display)
png.open_file("/s4m_ur4i-pirate-characters.png")
png.decode(0, 0, source=(32, 48, 24, 16), scale=(4, 4), rotate=0)
The source
argument is the region, in pixels, you want to show from the PNG- offset left and top, plus width and height. The whole PNG is loaded and decoded no matter what you put here, but this makes it easier to manage multiple images for things like icons.
The scale
argument lets you scale images up by a fixed multiplier along the X and Y axis. If you want to make an image 4x wider and 2x taller you'd use scale=(4, 2)
.
Finally, rotate lets you rotate your PNG graphic in 90 degree intervals.
Both full-colour RGB PNGs and indexed ones are supported. For indexed PNGs - ie: one that has a palette - you can supply a mode
argument with one of PNG_COPY
, PNG_DITHER
and PNG_POSTERISE
.
PNG_COPY
will copy the palette indexes into a P4
or P8
graphics buffer rather than dithering or posterising (snapping to the nearest available colour).
PNG_DITHER
will use a simple ordered dither matrix to dither the image colours to the available display colours.
PNG_POSTERISE
will snap the colours in the PNG to their nearest display counterpart.
Posterise is the default in all cases.
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.20.3...v1.20.4
Published by Gadgetoid over 1 year ago
This release bumps the MicroPython version we're building against from 1.20
to 856e08b1931b88271816a2f60648f6ff332235b2
and includes various Bluetooth-related libraries into our build. Bluetooth support should be at feature parity with the official MicroPython release. Read more about it at https://www.raspberrypi.com/news/new-functionality-bluetooth-for-pico-w/
Many of you expressed a desire to work with bitmap fonts outside of the rather uninspiring set we ship with PicoGraphics.
This has led to a couple of tweaks to PicoGraphics bitmap fonts. First up-
All of out fonts conform to a fixed grid up to 16 pixels tall and - in theory - unlimited pixels wide. Within this grid, individual characters can have different widths which are computed when the font is generated and saved into the font data. This lets us calculate text widths really quickly and lets us squeeze characters up against each other to fit more on screen.
This is not, as it happens, ideal for displaying numbers. With "1" being narrower than "0", a real-time display of some variable could cause decimal places or larger numbers to jump erratically and be difficult to read. We've added a new fixed_width=
argument to text()
. Specify this when you draw text in MicroPython and all the characters will behave themselves and stay a fixed distance from each other.
How does it look? Well here's bitmap8
at 2x scale in both fixed and variable modes:
Honestly, I don't know why I waited so long to make this happen. Our fonts are just data read from memory, and the code doesn't care if that memory is flash storage (built in fonts) or allocated by MicroPython (a bytearray in a .py file or a raw font loaded from user flash).
It's always been possible to use custom fonts in C, if you were determined enough to pick apart the font structure and painstakingly key in your own pixels.
And therein lies the problem. The biggest hurdle for users wanting custom fonts is preparing the font data. Our custom format is a little weird, mostly focusing on ASCII, plus some useful characters for - loosely - supporting languages other than British English and some even weirder diacritic mark support I glued on to sort-of support some unicode.
In typical fashion I decided to solve this "problem" by getting lost in a side project for viewing, editing and converting Pico Graphics fonts - pgfutil. It's extremely alpha, but you can find it here: https://github.com/gadgetoid/pgfutil
To load a custom bitmap font in PicoGraphics you just pass it into set_font()
. Eg:
display.set_font(open("font14.bitmapfont", "rb").read())
display.text("The quick brown fox jumps over the lazy dog", 10, 10, 240, 2)
An 8x8 font will cost you about 1k of RAM, and a 16x16 font around 3.6k. This is small compared to - for example - the 150k a 320x240 screen needs for 16-bit RGB but still big enough that you'll need to be careful how many fonts you use.
Font data is mutable, too. Do with that what you will 😆
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.20.2...v1.20.3
MicroPython changes: https://github.com/micropython/micropython/compare/v1.20.0...856e08b1931b88271816a2f60648f6ff332235b2
Published by Gadgetoid over 1 year ago
Tufty 2040: Firmware should now work and includes a fix to Tufty's native (RGB565) update code to reduce a typical screen update from ~30ms to ~10ms.
Cosmic Unicorn: Ghosting should be fixed in (just like Galactic).
Pico Display Pack 1.14": A fix to LCD init.
Ulab has been bumped to 6.0.12 where it's available (Tufty, Cosmic, Galactic).
Support added for the shiny new RGB Encoder Wheel breakout 👀
We're still building against MicroPython stable v1.20.0 and will continue to do so until there are some irresistible updates upstream. Quite a few changes have been made to streamline our build process and this may have introduced some regressions. Let us know if something is missing or broken.
🎉 Thank you to contributors new & old! 🎉
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.20.1...v1.20.2
Published by Gadgetoid over 1 year ago
In my haste to release 1.20.0 I fell into a trap- a MicroPython C memory handling trap. One iiickkle tinnny change that I hadn't testing against turned out to be the one that broke all of our builds. This release fixes that, before someone makes me walk the plank.
As before, nothing much has really changed except for a version bump and some (apparently not as) minor (as I thought) changes.
ℹ️ since we'll tracking unstable MicroPython from this point onwards, the v1.20.x
moniker doesn't mean all that much. We'll bump x
every time we release a new version with new Pimoroni Pico libraries. Our point releases are unrelated to MicroPython's own point releases so it's just as well that those are extraordinarily uncommon.
Note from the future - the v1.20.1 image for Tufty 2040 is bugged. If you have a Tufty, best to use v1.19.18 for now.
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.20.0...v1.20.1
Published by Gadgetoid over 1 year ago
Woah, woah. A version 1.20.0 of MicroPython! Surely that means lots of new great things in Pimoroni Pico MicroPython right, right?
Well... uh... it's not a particularly well-kept secret that we've (and, indeed, the official builds) been tracking the latest MicroPython changes since the Pico W. As such this release is mostly a formality and really nothing of consequence has changed since Pimoroni Pico v1.19.18.
Still, we're going to celebrate anyway: 🎉 🎉 🎉 🎉 🎉 🎉 🎉
dither=False
by @helgibbons in https://github.com/pimoroni/pimoroni-pico/pull/739
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.19.18...v1.20.0
MicroPython Changes: https://github.com/micropython/micropython/compare/38e7b842c6bc8122753cbf0845eb141f28fbcb72...v1.20.0
Published by Gadgetoid over 1 year ago
Okay so 1.19.17 was a bit of a memory corruption disaster. It turned out that - despite our best efforts - our C++ code was still assuming it had heap RAM it could use at its leisure. This was... sort-of... the case, except MicroPython's heap overlapped this same memory with disastrous and unpredictable results.
This is a re-issue of sorts, fixing the critical flaws in 1.19.17 but not introducing much else.
This change fixes some init heap usage in LTR559, LTP-305 (Dot Matrix display breakout) - removing almost 10k of memory usage - and PicoGraphics and introduces a new module cppmem
which quietly redirects C++ heap allocations over to the MicroPython heap.
🦡 Badger 2040 and Badger 2040 W builds now live here: https://github.com/pimoroni/badger2040/releases/latest
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.19.17...v1.19.18
MicroPython Changes: https://github.com/micropython/micropython/compare/05bb26010e4a466a82cfed179f8d8d0b406a78ca...38e7b842c6bc8122753cbf0845eb141f28fbcb72
Published by Gadgetoid over 1 year ago
⚠️ This build is incredibly broken, you should use v1.19.16 instead - https://github.com/pimoroni/pimoroni-pico/releases/tag/v1.19.16 ⚠️
A recent change in MicroPython took away the last remaining drips of heap memory that some of our modules (erroneously) relied upon, this release is mostly a great sweeping set of changes to fix these instances and ensure we can continue to follow the latest and greatest MicroPython changes and integrate Bluetooth when it comes.
This is a pretty significant set of changes which may not be complete, if you encounter issues let us know and try version 1.19.16 instead.
Most of these changes have no user-visible effect and everything should work as before, with the notable exception of:
As part of these changes both Unicorn Pack and Scroll Pack received a refactor into MicroPython class style modules, so:
import picounicorn
picounicorn.init()
Becomes:
from picounicorn import PicoUnicorn
picounicorn = PicoUnicorn()
As an added bonus we've thrown in PicoGraphics support for both of these boards. Neither benefit particularly from all that fancy graphics stuff, but it's nice to have party. PicoGraphics for Scroll Pack and Unicorn Pack works like it does for Cosmic/Galactic Unicorn, here's a minimal example for Scroll Pack:
from picographics import PicoGraphics, DISPLAY_SCROLL_PACK, PEN_P8
from picoscroll import PicoScroll
graphics = PicoGraphics(DISPLAY_SCROLL_PACK, pen_type=PEN_P8)
scroll = PicoScroll()
while True:
graphics.set_pen(0)
graphics.clear()
graphics.set_pen(255)
graphics.text("Boo", 0, 0, scale=1)
scroll.update(graphics)
ℹ️ Note that Scroll Pack's update()
method now accepts a PicoGraphics instance, if you want to use it without PicoGraphics you can call show()
instead.
The builds for Badger 2040 and Badger 2040 W have been removed. You should head over to https://github.com/pimoroni/badger2040/releases where you'll find ongoing releases for Badger boards.
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.19.16...v1.19.17
MicroPython Changes: https://github.com/micropython/micropython/compare/294098d28e2bad0ac0aad0d72595d11a82798096...05bb26010e4a466a82cfed179f8d8d0b406a78ca
Published by Gadgetoid over 1 year ago
This release includes a number of improvements to all Inky Frame boards, spurred by Inky Frame 7.3".
The inky_frame
module now includes colour constants and handy functions to manage Inky Frame when it's running on battery.
The pimoroni
module now includes a PWMLED
class which handles a single LED with brightness and on/off control.
All inky_frame
LEDs are now driven by PWMLED
and have variable brightness control.
set_thickness()
now works for Inky Frame (and all PicoGraphics pen types, in fact), allowing you to control the thickness of the lines used to render Hershey fonts. Text can be oooh so much prettier.
line()
now supports a fifth argument, "thickness", letting you draw thick lines at any angle. This is great fun for really slow analogue clocks and other UI elements that involve thick lines that rectangles can't accomplish.
A PicoGraphics instance for Inky Frame will now raise a ValueError
if you try to access the raw framebuffer with memoryview(graphics)
. It's backed by PSRAM so there's no memory to access... yet!
A bug has been fixed in PCF85063A driver, allowing you to set the time more than once.
See the Inky Frame module documentation for details about new (and old) features, caveats and so on.
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.19.15...v1.19.16
Published by Gadgetoid over 1 year ago
Version 1.19.15 mostly adds support for a couple of new and shiny things but we've also taken the opportunity to make improvements to some existing products-
Galactic Unicorn firmware now includes numpy, and we've included a directory full of examples to show you how you can use it for all manner of dynamic effects and crude simulations.
To make these effects a little easier to produce we've also added support for palette-mode pens to Galactic, most of the examples use PEN_P8
which means every pixel on Galactic Unicorn is represented by one 8-bit number that provides an index into a palette of your choice.
You can now use create_pen(r, g, b)
with Inky Frame and PicoGraphics will try its best to dither your drawing to the 7 colours that Inky is capable of producing. This works best on large blocks of colour such as backgrounds or chunky text.
You can also use dither=False
in JPEG decoding, causing JPEG files to be quantized to Inky's 7 colours rather than dithered. This is useful if you're using an image as a background for your project, or just want the cool posterisation-style effect.
PicoGraphics has a new create_pen_hsv(h, s, v)
method, which replaces all of the copy-pasted hsv_to_rgb
functions in our various examples with a faster, tidier implementation. Creating hsv pens works in all pen modes, and will either return a palette index or an appropriately converted RGB colour for you to use with set_pen
as normal.
While this is the first release built against Pico SDK 1.5.0, the new Bluetooth functionality is not yet available in MicroPython.
For a demonstration of Bluetooth doing something on Galactic/Cosmic see: https://github.com/Gadgetoid/galactic-bluetooth-audio/
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.19.14...v1.19.15
List of changes to MicroPython since Pimoroni Pico release v1.19.14: https://github.com/micropython/micropython/compare/35524a6fda1e44692ad599a39c802c168c897de9...294098d28e2bad0ac0aad0d72595d11a82798096
Published by Gadgetoid over 1 year ago
This release adds support for Badger 2040 W which is, as the name suggests, a wireless version of Badger 2040. We've switched to PicoGraphics for this version (we'll migrate Badger 2040 once the bugs are ironed out). It includes breaking changes from older Badger code, so you should consult the Badger 2040 W Python README to see what's changed.
PicoGraphics has also gained an HSV Pen thanks to @ageeandakeyboard, allowing a pen to be created from (hue, saturation, value) values, avoiding the need to calculate the RGB result in Python. Try set_pen_hsv(h, s, v)
.
Thanks to @LionsPhil for tweaking the Tufty 2040 Launcher/Menu to be a lot more RAM friendly, to @MichaelBell for fixing the ghosting issue in Galactic Unicorn and @ahnlak for adding RGB332 Pen support into Galactic Unicorn.
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.19.12...v1.19.14
Published by Gadgetoid almost 2 years ago
This release bumps the MicroPython version we're building against, including significant changes and bugfixes.
Additionally, non-wireless boards are no longer built against the stable v1.19 MicroPython version and are instead synced with the latest, unreleased fixes.
This also means we should better align with the official releases of MicroPython, and we now include "mip" and "ntptime" in W builds as we should!
For an exhaustive list of changes see:
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.19.11...v1.19.12
Note from the future: If you're using Plasma 2040 or Plasma Stick then you should skip this release - the builds below contain a bug that affects the Plasma library. Use v1.19.11 instead!
Published by Gadgetoid almost 2 years ago
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.19.10...v1.19.11
Published by Gadgetoid almost 2 years ago
This release adds support for Pico GFX Pack's RGB-backlit 128x64 monochrome LCD.
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.19.9...v1.19.10
Published by Gadgetoid about 2 years ago
This release adds support for Plasma Stick and Galactic Unicorn.
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/v1.19.8...v1.19.9
Published by Gadgetoid about 2 years ago
⚠️ Pico W builds are still based upon a pre-release, unstable version of MicroPython. We've bumped up the version we're using to the very latest commit as of today. You can find the full and very exhaustive lists of changes to MicroPython here - https://github.com/micropython/micropython/compare/9dfabcd6d3d080aced888e8474e921f11dc979bb...46d02c2469ec7947fe3aae2d68e07236baf5c72e
ℹ️ Contrary to the above, this release includes no MicroPython changes over v1.19.7!
This release tentatively brings v1.19.7 features to a "stable" version and - thanks to @MichaelBell - tweaks how graphics data is copied to displays, hopefully fixing some glitches seen on Tufty 2040.
We've also added a way to disable JPEG dithering in RGB332 mode, giving you a posterised effect instead. See: https://github.com/pimoroni/pimoroni-pico/pull/492
Thank you to our five new contributors!
picoexplorer
references by @helgibbons in https://github.com/pimoroni/pimoroni-pico/pull/498
Full Changelog: https://github.com/pimoroni/pimoroni-pico/compare/1.19.7...v1.19.8