SSD1306 OLED display driver  1.3.2
This library is developed to control SSD1306 i2c/spi OLED display
Macros | Functions | Variables
LCD communication interface functions

Macros

#define SSD1306_SA   0x3C
 
#define SSD1306_EMBEDDED_I2C
 
#define SSD1306_I2C_SW_SUPPORTED
 
#define SSD1306_SCL   3
 SCL, Pin 3 on SSD1306 Board.
 
#define SSD1306_SDA   4
 SDA, Pin 4 on SSD1306 Board.
 
#define SSD1306_EMBEDDED_SPI
 

Functions

void ssd1306_i2cInit ()
 
void ssd1306_i2cInitEx (int8_t scl, int8_t sda, int8_t sa)
 
void ssd1306_i2cCommandStart ()
 
void ssd1306_i2cDataStart ()
 
void ssd1306_i2cInit_Embedded (int8_t scl, int8_t sda, uint8_t sa)
 
void ssd1306_i2cStart_Embedded (void)
 
void ssd1306_i2cStop_Embedded (void)
 
void ssd1306_i2cSendByte_Embedded (uint8_t data)
 
void ssd1306_i2cConfigure_Wire (int8_t scl, int8_t sda)
 
void ssd1306_i2cInit_Wire (uint8_t sa)
 
void ssd1306_i2cStart_Wire ()
 
void ssd1306_i2cStop_Wire ()
 
void ssd1306_i2cSendByte_Wire (uint8_t data)
 
void ssd1306_sendCommand (uint8_t command)
 
void ssd1306_sendData (uint8_t data)
 
void ssd1306_spiInit (int8_t cesPin, int8_t dcPin)
 
void ssd1306_spiCommandStart ()
 
void ssd1306_spiDataStart ()
 

Variables

void(* ssd1306_startTransmission )()
 
void(* ssd1306_endTransmission )()
 
void(* ssd1306_sendByte )(uint8_t data)
 
void(* ssd1306_commandStart )()
 
void(* ssd1306_dataStart )()
 
void(* ssd1306_setRamBlock )(uint8_t x, uint8_t y, uint8_t w)
 
void(* ssd1306_nextRamPage )()
 
void(* ssd1306_setRamPos )(uint8_t x, uint8_t y)
 
int8_t s_ssd1306_cs
 
int8_t s_ssd1306_dc
 

Detailed Description

Macro Definition Documentation

◆ SSD1306_EMBEDDED_I2C

#define SSD1306_EMBEDDED_I2C

Use embedded i2c on attiny controllers, when Wire library is not applicable. The macro is deprecated. Use SSD1306_I2C_SW_SUPPORTED or SSD1306_WIRE_SUPPORTED instead

Definition at line 52 of file ssd1306_i2c_conf.h.

◆ SSD1306_EMBEDDED_SPI

#define SSD1306_EMBEDDED_SPI

Use embedded spi on attiny controllers. SPI library is not applicable The macro is deprecated. Use SSD1306_SPI_SUPPORTED instead.

Definition at line 41 of file ssd1306_spi_conf.h.

◆ SSD1306_I2C_SW_SUPPORTED

#define SSD1306_I2C_SW_SUPPORTED

The macro is defined when software i2c implementation is available

Definition at line 55 of file ssd1306_i2c_conf.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 43 of file ssd1306_i2c_conf.h.

Function Documentation

◆ ssd1306_i2cCommandStart()

void ssd1306_i2cCommandStart ( )

Switches i2c chip to command transmission mode.

Definition at line 25 of file ssd1306_i2c_common.c.

◆ ssd1306_i2cConfigure_Wire()

void ssd1306_i2cConfigure_Wire ( int8_t  scl,
int8_t  sda 
)

Configures speed for standard Wire library (via Wire.begin()). This function is called by ssd1306_i2cInit().

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
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

Definition at line 43 of file ssd1306_i2c_wire.cpp.

◆ ssd1306_i2cDataStart()

void ssd1306_i2cDataStart ( )

Switches i2c chip to data transmission mode.

Definition at line 31 of file ssd1306_i2c_common.c.

◆ ssd1306_i2cInit()

void ssd1306_i2cInit ( )

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().

Definition at line 47 of file ssd1306_i2c_common.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

Definition at line 160 of file ssd1306_i2c_embedded.c.

◆ ssd1306_i2cInit_Wire()

void ssd1306_i2cInit_Wire ( uint8_t  sa)

Initializes ssd1306 library to use Wire lib for i2c. If you do not know i2c parameters, try ssd1306_i2cInit_Wire(0). SCL and SDA pins depend on platform and Wire library implementation.

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

Definition at line 85 of file ssd1306_i2c_wire.cpp.

◆ 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().
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

Definition at line 37 of file ssd1306_i2c_common.c.

◆ ssd1306_i2cSendByte_Embedded()

void ssd1306_i2cSendByte_Embedded ( uint8_t  data)

Sends single byte to i2c device using software implementation.

Parameters
data- byte to send

Inputs: SCL is LOW, SDA is has no meaning Outputs: SCL is LOW

Definition at line 131 of file ssd1306_i2c_embedded.c.

◆ ssd1306_i2cSendByte_Wire()

void ssd1306_i2cSendByte_Wire ( uint8_t  data)

Sends single byte to i2c device using Wire library.

Parameters
data- byte to send

Inputs: SCL is LOW, SDA is has no meaning Outputs: SCL is LOW

Definition at line 64 of file ssd1306_i2c_wire.cpp.

◆ ssd1306_i2cStart_Embedded()

void ssd1306_i2cStart_Embedded ( void  )

Starts i2c communication with lcd display using software implementation of i2c interface.

SCL remains HIGH on EXIT, Low SDA means start transmission

Definition at line 100 of file ssd1306_i2c_embedded.c.

◆ ssd1306_i2cStart_Wire()

void ssd1306_i2cStart_Wire ( )

Starts i2c communication with lcd display via Wire library.

Definition at line 32 of file ssd1306_i2c_wire.cpp.

◆ ssd1306_i2cStop_Embedded()

void ssd1306_i2cStop_Embedded ( void  )

Stops i2c communication

Note
the function enables interrupts back.

Definition at line 112 of file ssd1306_i2c_embedded.c.

◆ ssd1306_i2cStop_Wire()

void ssd1306_i2cStop_Wire ( )

Stops i2c communication.

Definition at line 38 of file ssd1306_i2c_wire.cpp.

◆ 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 36 of file ssd1306_interface.c.

◆ ssd1306_sendData()

void ssd1306_sendData ( uint8_t  data)

Sends byte data to SSD1306 controller memory. Performs 3 operations at once: ssd1306_dataStart(); ssd1306_sendByte( data ); ssd1306_endTransmission();

Parameters
data- byte to send to the controller memory

Definition at line 43 of file ssd1306_interface.c.

◆ ssd1306_spiCommandStart()

void ssd1306_spiCommandStart ( )

Switches spi chip to command transmission mode.

Definition at line 38 of file ssd1306_spi.cpp.

◆ ssd1306_spiDataStart()

void ssd1306_spiDataStart ( )

Switches spi chip to data transmission mode.

Definition at line 44 of file ssd1306_spi.cpp.

◆ 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

Definition at line 30 of file ssd1306_spi.cpp.

Variable Documentation

◆ s_ssd1306_cs

int8_t s_ssd1306_cs

chip enable pin to controll lcd display over spi

Definition at line 27 of file ssd1306_spi.cpp.

◆ s_ssd1306_dc

int8_t s_ssd1306_dc

data/command control pin for spi interface of lcd display

Definition at line 28 of file ssd1306_spi.cpp.

◆ ssd1306_commandStart

void(* ssd1306_commandStart) ()

Starts transaction for sending commands.

Definition at line 29 of file ssd1306_interface.c.

◆ ssd1306_dataStart

void(* ssd1306_dataStart) ()

Starts transaction for sending bitmap data.

Definition at line 30 of file ssd1306_interface.c.

◆ ssd1306_endTransmission

void(* ssd1306_endTransmission) ()

Ends communication with SSD1306 display.

Definition at line 27 of file ssd1306_interface.c.

◆ ssd1306_nextRamPage

void(* ssd1306_nextRamPage) ()

Switches to the start of next RAM page for the block, specified by ssd1306_setRamBlock(). For ssd1306 it does nothing, while for sh1106 the function moves cursor to next page.

Definition at line 33 of file ssd1306_interface.c.

◆ ssd1306_sendByte

void(* ssd1306_sendByte) (uint8_t data)

Sends byte to SSD1306 device

Parameters
data- byte to send

Definition at line 28 of file ssd1306_interface.c.

◆ ssd1306_setRamBlock

void(* ssd1306_setRamBlock) (uint8_t x, uint8_t y, uint8_t w)

Sets block in RAM of lcd display controller to write data to. For ssd1306 it uses horizontal addressing mode, while for sh1106 the function uses page addressing mode. Width can be specified as 0, thus the library will set the right region of RAM block to the right column of the display.

Parameters
x- column (left region)
y- page (top page of the block)
w- width of the block in pixels to control

Definition at line 32 of file ssd1306_interface.c.

◆ ssd1306_setRamPos

void(* ssd1306_setRamPos) (uint8_t x, uint8_t y)

Sets position in RAM of lcd display controller to write data to. For ssd1306 this function is not defined. So, calling it will cause your controller to reset. For sh1106 the function does the same as ssd1306_setRamBlock().

Parameters
x- column (left region)
y- page (top page of the block)

Definition at line 34 of file ssd1306_interface.c.

◆ ssd1306_startTransmission

void(* ssd1306_startTransmission) ()

Starts communication with SSD1306 display.

Definition at line 26 of file ssd1306_interface.c.