Background

One day I thought it would be cool to have a pin or a patch on my backpack. I didn’t have one, so the next logical step was to build one with an E Ink display.

Hardware

For hardware I used whatever I had lying around: an ESP32-S3 (far more than the job needs, later swapped for an ESP32-C3) and a three-color E Ink display.

The firmware

Source: github.com/mikolajlubiak/pixelpin

I chose Bluetooth Low Energy for the link because it uses very little power. Once a simple channel similar to serial-over-Bluetooth worked, I could BEGIN a transfer, say whether I was sending a PNG or a JPEG, stream the image data, END the transfer and ask the device to DRAW it.

The display driver expects an unusual image format: two separate buffers, one for black and one for the display’s accent color, each with 1 bit per pixel. Every source pixel is classified as white, colored or black and packed into the right buffer:

whitish = (red * 0.299f + green * 0.587f + blue * 0.114f) > 0x80;
colored = ((red > 0x80) && (((red > green + 0x40) && (red > blue + 0x40))
            || (red + 0x10 > green + blue))) || (green > 0xC8 && red > 0xC8 && blue < 0x40);
if (whitish) { }
else if (colored) { out_color_byte &= ~(0x80 >> col % 8); }
else { out_byte &= ~(0x80 >> col % 8); }

The prototype on a white background

The app

Source: github.com/mikolajlubiak/pixelpin-app

At first I sent everything from a generic Bluetooth terminal app. A custom app was the obvious next step: it could also take image decoding off the small microcontroller and do it on the phone, which is far more capable. I wrote it in Flutter. I had tried to build a Bluetooth app once before and failed, so it was satisfying to see the app and the microcontroller talking to each other this time.

Engineering notes

The prototype

Up to this point the board had always been tethered to my computer, so I asked a friend to help turn it into an actual wearable: a case and a battery. We had some issues, and even more hot glue. The case was measured for a different battery than the one that ended up inside, so the battery was a little too thick for it; fortunately, nothing beats a hot glue gun. Of course it didn’t work on the first try. After some debugging we found that the display’s FPC connector had come loose, and once we reseated it, we had a working prototype.

The prototype in my hand

A shorter version of this build was published in Paged Out! #6 (PDF), page 31.

← All writing