Showing posts from May, 2019

Trade storage for code - stretching a font in real time

I've published several Arduino libraries for controlling inexpensive OLED and LCD displays, for example, my oled_96 library drives SSD1306/SH1106 OLEDs. It's gone through several iterations with additional functionality added. Recently I was using it on a new ATmega32u4 (Arduino Leonardo) project and ran out of FLASH space. I wanted to keep using the large fixed font for the project, but the font data takes up 6K of the 28K available. My first idea was to just #ifdef the font out of existence on targets with small amounts of FLASH memory. I couldn't move forward with my project until I solved the space problem and then decided that a slightly blocky looking large font would be better than no large font. The code to stretch the pixels isn't very complicated, so I added the logic to draw the large font as a 2x2 stretch of the 8x8 font.  AVR target MCUs tend to have very little FLASH space, so I singled them out as the target which would get this font stretching. Luckil