Skip to content

Library architecture

Aleksei edited this page May 20, 2018 · 3 revisions

Library architecture

The ssd1306 library sources structure:

  • examples/ Sketches, some of which can be compiled for any platform
  • src/ Main library sources
    • ssd1306_hal/ HAL layer.
    • intf/ Interface functions
      • i2c/
      • spi/
      • vga/
    • lcd/ Display initialization
    • ssd1306.c Common graphics API
    • ssd1331_api.c SSD1331 specific API

HAL layer

HAL layer contains platform specific low level functions for Arduino project, for plain AVR projects and for Linux. The functions include GPIO control, time functions, Analog functions. AVR and Linux hal is partially implemented.

Interface functions

intf contains pointers to interface functions, to communicate with display: data or command mode functions. The API in this section works on top of any physical interface: i2c, spi. Interface functions consist of 2 groups:

  • Physical interface functions
    • ssd1306_startTransmission()
    • ssd1306_endTransmission()
    • ssd1306_sendByte()
    • ssd1306_closeInterface()
    • ssd1306_commandStart()
    • ssd1306_dataStart()
    • ssd1306_sendCommand()
    • ssd1306_sendData()
  • Lcd interface functions
    • ssd1306_sendPixels()
    • ssd1306_setRamBlock()
    • ssd1306_nextRamPage()

Marked functions are already implemented and common and already implemented for all interfaces and LCD displays.

i2c

i2c group provides i2c implementation for specific platforms. All functions are under specific compiler directives, which are defined by hal platform implementation.

spi

spi group provides spi implementation for specific platforms. All functions are under specific compiler directives, which are defined by hal platform implementation.

Display initialization

Display initialization group contains initialization functions for different controllers: SSD1306, SSD1331, PCD8544 and so on. When you call display initialization function, it connects to display using selected physical interface, and configures display according to datasheet notes. Additionally display initialization function setups 3 specific functions: ssd1306_setRamBlock, ssd1306_nextRamPage, ssd1306_sendPixels. Behavior of these functions depend on the controller, OLED display is based on.

Common graphics API

This section contains common graphics functions, working with all OLED displays.

SSD1331 specific API

This section contains API graphics functions to be used with SSD1331 controllers only.