SDD1306

Micropython driver for the 128x64 small (0.96) OLED display

0.96 Inch 128*64 OLED Module 4 Pin IC I2C IIC Communication

Features:

  • Any font available using Dot Factory
  • Fonts / images stored on file so very little RAM used
  • Specifically for the ESP8288

Resources

Introduction

The purpose of writing this was because the other current drivers hold the font information in RAM and on the ESP8266 this is a precious resource. The option used here is to store the font on file (in flash) and use file random access to select then display a character when needed. In this way the RAM needed is that of a single character rather then the whole character set.

I know what you are thinking, this will be very slow - NOT so. It is slower of course but perfectly usable for text information.

Create Fonts

Step 1

Dot Factory version 0.4.1 is used to create the font with the bits rotated by 90 degrees:

This is the settings used to create the font. This display is unconventional in that the bytes written are aligned side by side horizontally and hence the need to rotate 90 degrees.

The output for 'A' is sown here, when written to the display this will be 16 bits (2 bytes high) and so for this display that is 8 bytes high, 4 rows of text can be displayed. The only font I can find that is legible (just) 1 byte high is courier 7pt. If the font has 3 bytes in a row that that will be 3 bytes high etc. In this case there are 7, 2byte rows and so it will be 7 pixels wide.

Dot Factory also outputs a character map which is used to locate the character within the file and display the font.

Step 2

Save the output using save As.. This will generate a .c and a .h file, the .h file can be discarded.

Step 3

Generate a binary file. This could of course be done on the ESP8266 however, the whole point of the exercise is to save resources so it is better to do as much processing externally as possible.

There is a stand alone GUI Python3 program that will do the conversion, this is called fontConverter.py, run as follows from a command window:

python3 fontConverter.py

(or python fontConverter.py but it was written for python version 3, see below convert.py is the stand alone command line program that may well run under python 2)

This pops up the dialog, just select the .c file and it will create the .fon binary font file which can be used with the driver

The fontConverter.zip has the following files:

fontConverter.py This is the GUI as in the image above
fontConverter.fbp This is the wxFormbiulder file so you can change the look easily
noname.py This is the file output from wxFormBuilder which is all of the frame, GUI
convert.py This does the work and can be run stand alone if required

demo.py
sdd1306_i2c.py Driver files for thedevice

Step 4

Download the binary files on to the ESP8266 flash and use from there.

Create Images

This is exactly the same procedure as for creating fonts, the convert.py has a --b' switch if used stand alone or the GUI has an image check box.

The settings for Dot Factory are different though

Here there is no rotation and the byte layout is ColumnMajor that gives a height of 8 bytes and a width of 128 bytes, the output is very wide.

This is a partial image of a typical output just so you know you are on the right track.