A quick and dirty graphics converter for DigisparkOLED

Printer-friendly version

A few months ago, I dragged my Linux laptop, some Digispark ATTiny85s, and some other hardware along to while away the time on an out-of-town visit. My objective was to, in my spare time, learn how to use some of the libraries available to the ATTiny85/Arduino environment, and to play a bit with the hardware.

One of my goals was to have the ATTiny85 display some graphics on a 128x64 OLED display. I already had figured out how to display text, but the example code for graphics display didn't make it clear how to organize a graphics bitmap to properly display on the OLED. Eventually, I did figure out the encoding trick, which involved interpreting the graphic as a number of 8-row columns, and storing the resulting bytes away for playback to the OLED. But, encoding a graphic in this manner seemed time-consuming and sensitive to errors.

So, I wrote a small program, for my Linux laptop, that would convert monochrome graphics files into the requisite bitmapped array, and emit that array as C code to be compiled into my ATTiny85 Arduino programs.

The pbm2oled program reads a NetPBM portable bitmap graphics file, and emits the appropriate C code to stdout. When redirected to a file, the programmer can #include this C code into an ATTiny85/Arduino program, and use the appropriate Digispark library to write the graphic to an OLED screen.

Since this is a trivial program, I have no reservations in releasing it to the wild, licenced under the GNU GPL v2.

Enjoy

AttachmentSize
Binary Data pbm2OLED.tar_.gz9.91 KB