Skip to content

Functions Manual

Microesque edited this page Dec 20, 2024 · 5 revisions

Overview


Initialization Functions

ssd1306_init()

Prototype:

void ssd1306_init(struct ssd1306_display *display,
                  uint8_t i2c_address,
                  enum ssd1306_display_type display_type,
                  uint8_t *array,
                  void (*i2c_write)(uint8_t *data, uint16_t length));

Description:

  • Initializes the ssd1306_display structure as well as the display.

Parameters:

  • display: Pointer to the ssd1306_display structure.
  • i2c_address: 7-bit address of the display.
  • display_type: Display type (128x32 or 128x64). Use the ssd1306_display_type enum provided in the header file.
  • array: Pointer to the array that will serve as the buffer for the display. Use the macros provided in the header file to declare an array of the appropriate size based on the display type.
  • i2c_write: Pointer to the callback function that writes a stream of data to the I2C bus. For proper setup, refer to Setup Guide.

Returns:

  • -

Notes:

  • If this function has already been called at least once and you need to re-initialize the display, use ssd1306_reinit() instead.
  • The display will reset to default configurations. These configurations are defined as macros in the ssd1306.h file under the Library Setup section.
  • Any ongoing scrolls will be disabled (limitation of the driver chip).
  • The display will be updated (limitation of the driver chip).

Example:


ssd1306_reinit()

Prototype:

void ssd1306_reinit(struct ssd1306_display *display);

Description:

  • Re-initializes the display.

Parameters:

  • display: Pointer to the ssd1306_display structure.

Returns:

  • -

Notes:

  • Equivalent to calling ssd1306_init(), but does not re-initialize the structure. Do NOT use this function unless ssd1306_init() has already been called at least once with the given ssd1306_display structure.
  • The display will reset to default configurations. These configurations are defined as macros in the ssd1306.h file under the Library Setup section.
  • Any ongoing scrolls will be disabled (limitation of the driver chip).
  • The display will be updated (limitation of the driver chip).

Example:


Display Functions

ssd1306_display_update()

/**
 * @param display Pointer to the ssd1306_display structure.
 */
void ssd1306_display_update(struct ssd1306_display *display);

Draw Functions

ssd1306_draw_bitmap()

Description:

  • Draws a bitmap image starting from the specified coordinates and extending down-right.

Prototype:

void ssd1306_draw_bitmap(struct ssd1306_display *display,
                         int16_t x0,
                         int16_t y0,
                         const uint8_t *bitmap,
                         uint16_t width,
                         uint16_t height,
                         bool has_bg);

Parameters:

  • display: Pointer to the ssd1306_display structure.
  • x0: x-coordinate of the top left pixel of the image.
  • y0: y-coordinate of the top left pixel of the image.
  • bitmap: Pointer to the bitmap array.
  • width: Width of the image in pixels. The value MUST match the bitmap width, or the drawing may get corrupted and random parts of the memory may be accessed. For example, for an image with a resolution of 60x40, the width value should be '60'.
  • height: Height of the image in pixels. The value MUST match the bitmap height, or the drawing may get corrupted and random parts of the memory may be accessed. For example, for an image with a resolution of 60x40, the height value should be '40'.
  • has_bg: 'true' to overwrite the contents in the background; 'false' to draw transparent.

Returns:

  • -

Notes:

Example:


Getter/Setter Functions