Skip to content

Adding an S meter font to the SSD1306Ascii library

VK3HN edited this page Dec 22, 2022 · 7 revisions

The problem

The conventional OLED libraries (eg the Adafruit library at https://github.com/adafruit/Adafruit_SSD1306 ) do great looking fonts and graphics but are way too big (in memory terms) to be used by a Nano. The only option is to use a light-weight ASCII-only OLED library. I used the SSD1306Ascii library by Bill Greiman (https://github.com/greiman/SSD1306Ascii). But if you do this, you have no way of drawing an S-meter.

The solution

I created a 10x15 font for the SSD1306Ascii library (https://github.com/prt459/Arduino_si5351_VFO_Controller_Keyer/blob/master/s_meter_font.h). My s-meter font contains just the basic S-meter characters only, allowing you to draw an S-meter on a 128x64 OLED display when using the SSD1306Ascii library.

Installing the s-meter font

Download the s-meter font header file (.h) and move it to the libraries\SSD1306Ascii\src\fonts folder.

Edit the file SSD1306Ascii_fonts.h and add in #include "s-meter10x15.h"

The font can now be selected using the library's setFont() function. The characters have ordinal values 1 to 8. To an s-meter character to the OLED use oled.print((char)n); where n is 1 to 8 inclusive.

Alternative and simpler solution

Piotr SP9LVZ simply copied and pasted the S_meter font header code into the main VFO_Controller script. As the file contains only structs (which provide information for the compiler) it should not add to the binary code size, so this seems like a simpler solution. I'm yet to try it, if you do, let me know.