SSD1306 OLED display driver 1.8.2 This library is developed to control SSD1306/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays

Classes | Macros | Functions | Variables
I2C/SPI: physical interface functions

i2c/spi initialization functions for different platforms More...

## Classes
struct | ssd1306_interface_t

## Macros
#define | SSD1306_SA 0x3C
#define | ssd1306_dcQuickSwitch ssd1306_intf.spi
#define | ssd1306_startTransmission ssd1306_intf.start
#define | ssd1306_endTransmission ssd1306_intf.stop
#define | ssd1306_sendByte ssd1306_intf.send
#define | ssd1306_sendBytes ssd1306_intf.send_buffer
#define | ssd1306_closeInterface ssd1306_intf.close

## Functions
void | ssd1306_i2cInit (void)
void | ssd1306_i2cInitEx (int8_t scl, int8_t sda, int8_t sa)
void | ssd1306_i2cInit_Embedded (int8_t scl, int8_t sda, uint8_t sa)
void | ssd1306_i2cConfigure_Twi (uint8_t arg)
void | ssd1306_i2cInit_Twi (uint8_t sa)
void | ssd1306_spiInit (int8_t cesPin, int8_t dcPin)
void | ssd1306_spiDataMode (uint8_t mode)
void | ssd1306_spiInit_avr (int8_t cesPin, int8_t dcPin)
void | ssd1306_spiInit_Usi (int8_t cesPin, int8_t dcPin)
void | ssd1306_sendCommand (uint8_t command)
void | ssd1306_commandStart (void)
void | ssd1306_dataStart (void)
void | ssd1306_uartInit_Builtin (uint32_t baud)

## Variables
int8_t | s_ssd1306_cs
int8_t | s_ssd1306_dc
uint32_t | s_ssd1306_spi_clock
ssd1306_interface_t | ssd1306_intf

## Detailed Description

i2c/spi initialization functions for different platforms

This group of API functions serves to prepare the library to work via specific hardware interface. There are a bunch of functions for different platforms. In general display initialization goes in two steps: hardware interface initialization, and then display driver initialization. But there are functions, which combine 2 steps in single call: ssd1306_128x64_i2c_initEx(), ssd1351_128x128_spi_init(), etc.

## Macro Definition Documentation

## ◆ ssd1306_closeInterface

#define ssd1306_closeInterface ssd1306_intf.close

Deprecated

Definition at line 124 of file ssd1306_interface.h.

## ◆ ssd1306_dcQuickSwitch

#define ssd1306_dcQuickSwitch ssd1306_intf.spi

Deprecated

Definition at line 99 of file ssd1306_interface.h.

## ◆ ssd1306_endTransmission

#define ssd1306_endTransmission ssd1306_intf.stop

Deprecated

Definition at line 109 of file ssd1306_interface.h.

## ◆ SSD1306_SA

#define SSD1306_SA 0x3C

SSD1306_SA defines default i2c address of LCD display. Please, check your device. If you LCD device has different address, you can set different one via ssd1306_i2cInit_Wire() or ssd1306_i2cInit_Embedded() functions. Write command will be SSD1306_SA<<1 and read will be SSD1306_SA<<1 | 1

Definition at line 47 of file ssd1306_i2c_conf.h.

## ◆ ssd1306_sendByte

#define ssd1306_sendByte ssd1306_intf.send

Deprecated

Definition at line 114 of file ssd1306_interface.h.

## ◆ ssd1306_sendBytes

#define ssd1306_sendBytes ssd1306_intf.send_buffer

Deprecated

Definition at line 119 of file ssd1306_interface.h.

## ◆ ssd1306_startTransmission

#define ssd1306_startTransmission ssd1306_intf.start

Deprecated

Definition at line 104 of file ssd1306_interface.h.

## Function Documentation

## ◆ ssd1306_commandStart()

void ssd1306_commandStart | ( | void |  | ) |

Starts transaction for sending commands.

Definition at line 36 of file ssd1306_interface.c.

## ◆ ssd1306_dataStart()

void ssd1306_dataStart | ( | void |  | ) |

Starts transaction for sending bitmap data.

Definition at line 45 of file ssd1306_interface.c.

## ◆ ssd1306_i2cConfigure_Twi()

void ssd1306_i2cConfigure_Twi | ( | uint8_t | arg | ) |

Configures standard TWI AVR module (at 400kHz). This function is called by ssd1306_i2cInit().

Parameters

  arg | - has no meaning for now. Should be zero

Note
  scl and sda pins depend on used hardware.

Definition at line 111 of file ssd1306_i2c_twi.c.

## ◆ ssd1306_i2cInit()

void ssd1306_i2cInit | ( | void |  | ) |

Inits display interface to use i2c bus. The function automatically selects available type of i2c implementation

1. Wire library
2. sw i2c implementation In case of using Wire library this function calls Wire.begin() and sets speed to fast i2c (400kHz). If you prefer to use your own Wire settings or avoid reinitializing of Wire library, please use ssd1306_i2cInit_Wire(). If you want to use embedded i2c (if it is supported), use ssd1306_i2cInit_Embedded().

Note
  : after call to this function you need to initialize lcd display.

Definition at line 45 of file ssd1306_i2c.c.

## ◆ ssd1306_i2cInit_Embedded()

void ssd1306_i2cInit_Embedded | ( | int8_t | scl,
|  | int8_t | sda,
|  | uint8_t | sa
| ) |  |

Initializes software implementation of i2c. If you do not know i2c parameters, try ssd1306_i2cInit_Embedded(0,0,0).

Warning
  the function disables interrupts.

Parameters

  scl | - i2c clock pin. Use -1 if you don't need to change default pin number
  sda | - i2c data pin. Use -1 if you don't need to change default pin number
  sa | - i2c address of lcd display. Use 0 to leave default

Note
  : after call to this function you need to initialize lcd display.

Definition at line 178 of file ssd1306_i2c_embedded.c.

## ◆ ssd1306_i2cInit_Twi()

void ssd1306_i2cInit_Twi | ( | uint8_t | sa | ) |

Initializes ssd1306 library to use TWI AVR module for i2c. If you do not know i2c parameters, try ssd1306_i2cInit_Twi(0). SCL and SDA pins depend on platform.

Parameters

  sa | - i2c address of lcd display. Use 0 to leave default

Note
  : after call to this function you need to initialize lcd display.

Definition at line 160 of file ssd1306_i2c_twi.c.

## ◆ ssd1306_i2cInitEx()

void ssd1306_i2cInitEx | ( | int8_t | scl,
|  | int8_t | sda,
|  | int8_t | sa
| ) |  |

Inits display interface to use i2c bus. The function automatically selects available type of i2c implementation

1. Wire library
2. sw i2c implementation In case of using Wire library this function calls Wire.begin() and sets speed to fast i2c (400kHz). If you prefer to use your own Wire settings or avoid reinitializing of Wire library, please use ssd1306_i2cInit_Wire(). If you want to use embedded i2c (if it is supported), use ssd1306_i2cInit_Embedded().

Parameters

  scl | - i2c clock pin. Use -1 if you don't need to change default pin number
  sda | - i2c data pin. Use -1 if you don't need to change default pin number
  sa | - i2c address of lcd display. Use 0 to leave default

Note
  scl and sda parameters depend on used hardware. For many hardware boards these parameters do not have any effect. ESP8266 allows to specify these parameters
  scl and sda for Linux systems should be the same, and should contain i2c bus id.
  : after call to this function you need to initialize lcd display.

Definition at line 28 of file ssd1306_i2c.c.

## ◆ ssd1306_sendCommand()

void ssd1306_sendCommand | ( | uint8_t | command | ) |

Sends command to SSD1306 device: includes initiating of transaction, sending data and completing transaction.

Parameters

  command | - command to send

Definition at line 54 of file ssd1306_interface.c.

## ◆ ssd1306_spiDataMode()

void ssd1306_spiDataMode | ( | uint8_t | mode | ) |

Switches spi to data(1) or command(0) mode.

Parameters

  mode | - 1 data mode 0 command mode

Definition at line 50 of file ssd1306_spi.c.

## ◆ ssd1306_spiInit()

void ssd1306_spiInit | ( | int8_t | cesPin,
|  | int8_t | dcPin
| ) |  |

Inits lcd interface to use hardware spi for communication. The function automatically selects available type of spi implementation

1. SPI library (ssd1306_spiInit_hw())
   Parameters

     cesPin | - pin, controlling chip enable of LCD
     dcPin | - pin, controlling data/command mode of LCD

   Note
     : after call to this function you need to initialize lcd display.

Definition at line 37 of file ssd1306_spi.c.

## ◆ ssd1306_spiInit_avr()

void ssd1306_spiInit_avr | ( | int8_t | cesPin,
|  | int8_t | dcPin
| ) |  |

Inits lcd interface to use hardware SPI for communication (SPI.h library). It uses standard MOSI, SCLK pins to send data to LCD.

Parameters

  cesPin | - pin, controlling chip enable of LCD
  dcPin | - pin, controlling data/command mode of LCD

Note
  : after call to this function you need to initialize lcd display.

Definition at line 133 of file ssd1306_spi_avr.c.

## ◆ ssd1306_spiInit_Usi()

void ssd1306_spiInit_Usi | ( | int8_t | cesPin,
|  | int8_t | dcPin
| ) |  |

Inits lcd interface to use USI for SPI communication. It uses standard USI CLK, USI DO, USI DI pins to send data to LCD.

Parameters

  cesPin | - pin, controlling chip enable of LCD
  dcPin | - pin, controlling data/command mode of LCD

Note
  : after call to this function you need to initialize lcd display.

Definition at line 111 of file ssd1306_spi_usi.c.

## ◆ ssd1306_uartInit_Builtin()

void ssd1306_uartInit_Builtin | ( | uint32_t | baud | ) |

Initializes built-in implementation of uart functions, based on USART hw module. If you do not know uart parameters, try ssd1306_uartInit_Builtin(0).

Parameters

  baud | uart baud rate

Note
  : after call to this function you need to initialize lcd display.

Definition at line 63 of file ssd1306_uart_builtin.c.

## Variable Documentation

## ◆ s_ssd1306_cs

int8_t s_ssd1306_cs

chip enable pin to controll lcd display over spi

Definition at line 33 of file ssd1306_spi.c.

## ◆ s_ssd1306_dc

int8_t s_ssd1306_dc

data/command control pin for spi interface of lcd display

Definition at line 34 of file ssd1306_spi.c.

## ◆ s_ssd1306_spi_clock

uint32_t s_ssd1306_spi_clock

maximum SPI clock, supported by OLED display

Definition at line 35 of file ssd1306_spi.c.

## ◆ ssd1306_intf

ssd1306_interface_t ssd1306_intf

Holds pointers to functions of currently initialized interface.

Definition at line 31 of file ssd1306_interface.c.