Skip to content

Initialization

Tara K edited this page Apr 9, 2018 · 3 revisions

SSD1306_Init_I2C

bool SSD1306_Init_I2C( struct SSD1306_Device* DeviceHandle, int Width, int Height, int I2CAddress, int ResetPin, WriteCommandProc WriteCommand, WriteDataProc WriteData, ResetProc Reset );

Sets up the device structure using user supplied callbacks for writing commands, data, and resetting the display in hardware.
Note: See ifaces/default_if_i2c.c for an example on how these are implemented

Parameters:

  1. Pointer to object which will be the display device handle
  2. Width of display
  3. Height of display
  4. I2C Address
  5. GPIO Number of reset pin (Optional: Pass -1 if not using a reset pin)
  6. Callback to a function which will write a command over the i2c bus
  7. Callback to a function which will write data over the i2c bus
  8. Callback to a function that will reset the device via hardware means

Returns:

  • True if the device structure was successfully initialized

Note: Because this display is write only we cannot guarantee that the display was ACTUALLY initialized.
A return value of true just means there were no errors during setup of local structures.

SSD1306_Init_SPI:

bool SSD1306_Init_SPI( struct SSD1306_Device* DeviceHandle, int Width, int Height, int ResetPin, int CSPin, spi_device_handle_t SPIHandle, WriteCommandProc WriteCommand, WriteDataProc WriteData, ResetProc Reset )

Sets up the device structure for use with the SPI bus using user provided callbacks for writing commands, data, and hardware reset.
Note: See ifaces/default_if_spi.c for an example on how this is implemented

Parameters:

  1. Pointer to object which will be the display device handle
  2. Width of display
  3. Height of display
  4. GPIO Number of reset pin (Optional: Pass -1 if not using a reset pin)
  5. GPIO Number of chip select pin
  6. SPI Handle provided by spi_bus_add_device
  7. Callback to write a command byte over the SPI bus
  8. Callback to write data bytes over the SPI bus
  9. Callback to handle hardware reset

Returns:

True: Device structures were properly allocated and initialized

Note: Because this display is write only we cannot guarantee that the display was ACTUALLY initialized.
A return value of true just means there were no errors during setup of local structures.

SSD1306_HWReset:

SSD1306_HWReset( struct SSD1306_Device* DeviceHandle )

Calls the hardware reset handler provided by the user or the default interface.

Returns:

If there was no reset pin set, it will return true since it's not required and thus not an error.
Otherwise, it will return whatever value the hardware reset callback returns.