C library for SSD1306 OLED Driver
Go to file
2022-12-15 20:39:40 +01:00
img Update images v3.0.0 2022-12-11 14:17:44 +01:00
lib Update freq for m328p 2022-12-11 14:23:32 +01:00
.gitignore Modification 2022-11-22 20:38:14 +01:00
LICENSE Initial commit 2020-10-13 10:44:23 +02:00
main.c Small modification 2022-12-15 20:39:40 +01:00
Makefile Modification 2022-11-22 20:38:14 +01:00
README.md Update v3.0.0 2022-12-11 14:19:26 +01:00

C Library for SSD1306 0.96" OLED display

SSD1306 Description

Detailed information are described in Datasheet SSD1306.

Library

C library is aimed for driving 0.96" OLED display with SSD1306 driver 128x64 or 128x32 version through TWI's (I2C). Settings for particular versions:

  • 128x64 version
    • command argument SSD1306_SET_MUX_RATIO set to 63 (ssd1306.c)
    • command argument SSD1306_COM_PIN_CONF set to 0x12 (ssd1306.c)
    • END_PAGE_ADDR set to 7 (ssd1306.h)
  • 128x32 version
    • command argument SSD1306_SET_MUX_RATIO set to 31 (ssd1306.c)
    • command argument SSD1306_COM_PIN_CONF set to 0x02 (ssd1306.c)
    • END_PAGE_ADDR set to 3 (ssd1306.h)

Versions

  • 1.0 - basic functions. The first publication.
  • 2.0 - more changes:
    • rebuild to cacheMemLcd array. It means that every request is stored in cache array and then is depicted on the display by function SSD1306_UpdateScreen (uint8_t).
    • Added new function -> SSD1306_DrawLine (uint8_t, uint8_t, uint8_t, uint8_t). Possible depicted any line (horizontal, vertical, with slope).
    • Possible to use for more than 1 display (not tested, cause displays that I have avialable had the same addresses).
    • !!! ~1kB RAM memory consumption.
  • 3.0 - simplified alphanumeric version
    • used for displaying alphanumeric characters
    • one display applicable
    • only few RAM bytes consumption
    • !!! no graphic functions

Dependencies

Font.c can be modified according to application requirements with form defined in font.c. Maximal permissible horizontal dimension is 8 bits.

Usage

Prior defined for MCU Atmega328p / Atmega8 / Atmega16. Need to be carefull with TWI ports definition.

PORT Atmega16 Atmega8 / Atmega328
SCL PC0 PC5
SDA PC1 PC4

Tested

Library was tested and proved with 0.96″ 128x64 and 128x32 OLED Display (SSD1306 driver) and Atmega328p.

Init OLED Sequence

Init sequence OLED display was defined according to page 64 (next to last page) of Datasheet SSD1306.

// +---------------------------+
// |      Set MUX Ratio        |
// +---------------------------+
// |        0xA8, 0x3F         |
// +---------------------------+
//              |
// +---------------------------+
// |    Set Display Offset     |
// +---------------------------+
// |        0xD3, 0x00         |
// +---------------------------+
//              |
// +---------------------------+
// |  Set Display Start Line   |
// +---------------------------+
// |          0x40             |
// +---------------------------+
//              |
// +---------------------------+
// |     Set Segment Remap     |
// +---------------------------+
// |       0xA0 / 0xA1         |
// +---------------------------+
//              |
// +---------------------------+
// |   Set COM Output Scan     |
// |        Direction          |
// +---------------------------+
// |       0xC0 / 0xC8         |
// +---------------------------+
//              |
// +---------------------------+
// |   Set COM Pins hardware   |
// |       configuration       |
// +---------------------------+
// |        0xDA, 0x02         |
// +---------------------------+
//              |
// +---------------------------+
// |   Set Contrast Control    |
// +---------------------------+
// |        0x81, 0x7F         |
// +---------------------------+
//              |
// +---------------------------+
// | Disable Entire Display On |
// +---------------------------+
// |          0xA4             |
// +---------------------------+
//              |
// +---------------------------+
// |    Set Normal Display     |
// +---------------------------+
// |          0xA6             |
// +---------------------------+
//              |
// +---------------------------+
// |    Set Osc Frequency      |
// +---------------------------+
// |       0xD5, 0x80          |
// +---------------------------+
//              |
// +---------------------------+
// |    Enable charge pump     |
// |        regulator          |
// +---------------------------+
// |       0x8D, 0x14          |
// +---------------------------+
//              |
// +---------------------------+
// |        Display On         |
// +---------------------------+
// |          0xAF             |
// +---------------------------+

Functions

Demonstration

Acknowledgement