SSD1306 Driver for TivaC
SSD1306 i2c driver for use with Texas Instrument TivaC
SSD1306 Driver for TivaC Documentation

tiva_SSD1306_Driver

Driver for the SSD1306 OLED controller for the TivaC.

Features

Design

This a pretty simple driver, communication with the ssd1306 is detailed in the datasheet and most functions simply follow that. The font creator script was designed to be easy to use and require almost no work to integrate the result.

Docs

Doxygen Docs for the Driver

Directory Structure

External Dependencies

This project is a ccs project, setting up ccs is outside the scope of this README so consult TI documentation for that

This driver uses the Tivaware support package from TI for the low level works so to run this you need to have this in the compile PATH

Display Icon and Images

Icon and Images are recommended to have black background and be mainly black and white, icons like this have a better chance of working well:

Black Background Icons

Credits: Icons made by Google from https://www.flaticon.com/ (a very good site to get black background icons)

Making the dimension symmetric like 16x16 gives good results, this driver does support drawing partial image but it's recommended to pre-crop before inserting the bit map into the firmware

How to print picture on screen

Resize your picture if you need to, then go to this site, depending on your picture, pick Horizontal or Vertical in the Output section(just do trial and error if you are not sure), copy the images in to a bitmap array and use it like this:

// in your c file
static uint8_t testIcon[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; // arrays obtained from the site above
ssd1306PrintPic(testIcon, 0, 127, 0, 0); // print icons onscreen with given coordinate

Using Custom Fonts

This driver comes with a python script called create_new_font.py that allows converting a c array bitmap to a struct that is used by the firmware

The python script will take a raw c bitmap file and converts to struct used by firmware, the struct you will be interested in will be in the form of font_name_set, where font_name is supplied as the second argument of the python script and is declared in src/oled_font_font_name.h

By default, the raw c font file has incosistent whitespace in them, the script will remove those whitespace as well as put the raw array into source files ready to be integrated into the firmware

This repo comes with an example font called source_pro.

Steps:

  1. Get a ttf file from site like this
  2. Go here and convert the file to a c array file, set bpp to 1, other settings are up to you but monospace font tends to look better
  3. With the downloaded c array file, launch the python script:
python3 create_new_font.py /home/your_name/Downloads/source_code_pro_oled.c font_name # provide raw bit map fiile path and font name
  1. The steps above will create two files, oled_font_font_name.h and oled_font_font_name.c, you need the struct named font_name_set(declared in oled_font_font_name.h) to use the write string function:
// main.c
#include "oled_font_font_name.h"
ssd1306PrintString("ABCDE14321L", 0, 0, font_name_set);

Credits And Reources

Huge thanks to Adafruit SSD1306 library for providing the detailed steps needed for initializing the ssd1306 as well as for the macro definitions

Image to C Array Converter

Google Font

TTF to C Array Converter