Detailed information are described in Datasheet SSD1306.
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:
Font.c can be modified according to application requirements with form defined in font.c. Maximal permissible horizontal dimension is 8 bits.
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 |
Library was tested and proved with 0.96″ 128x64 and 0.91" 128x32 OLED Display (SSD1306 driver) and Arduino UNO R3. The Arduino was without a bootloader installed, it was only raw Atmega328P microcontroller. Communication was done through I2C (TWI) interface of Arduino UNO R3. This hardware configuration was chosen for simplicity.
Init sequence OLED display was defined mainly according to page 64 (next to last page) of Datasheet SSD1306.
// +---------------------------+
// | Software Reset | // not tested yet, @source https://github.com/SmingHub/Sming/issues/501
// +---------------------------+
// | 0xE4 |
// +---------------------------+
// ||
// +---------------------------+
// | DISPLAY OFF |
// +---------------------------+
// | 0xAE |
// +---------------------------+
// ||
// +---------------------------+
// | Set MUX Ratio |
// +---------------------------+
// | 0xA8 |
// | 0x3F |
// +---------------------------+
// ||
// +---------------------------+
// | Set Memory Addr Mode |
// +---------------------------+
// | 0x20 |
// | 0x00 |
// +---------------------------+
// ||
// +---------------------------+
// | Set Start Line |
// +---------------------------+
// | 0x40 |
// +---------------------------+
// ||
// +---------------------------+
// | Set Display Offset |
// +---------------------------+
// | 0xD3 |
// | 0x00 |
// +---------------------------+
// ||
// +---------------------------+
// | Set Segment Remap |
// +---------------------------+
// | 0xA0 or 0xA1 |
// +---------------------------+
// ||
// +---------------------------+
// | Set COM Output Scan |
// | Direction |
// +---------------------------+
// | 0xC0 or 0xC8 |
// +---------------------------+
// ||
// +---------------------------+
// | Set COM Pins hardware |
// | configuration |
// +---------------------------+
// | 0xDA |
// | 0x12 for 128x64 |
// | 0x02 for 128x32 |
// +---------------------------+
// ||
// +---------------------------+
// | Set Contrast Control |
// +---------------------------+
// | 0x81 |
// | 0x7F |
// +---------------------------+
// ||
// +---------------------------+
// | Disable Entire Display On |
// +---------------------------+
// | 0xA4 |
// +---------------------------+
// ||
// +---------------------------+
// | Set Normal Display |
// +---------------------------+
// | 0xA6 |
// +---------------------------+
// ||
// +---------------------------+
// | Set OSC Frequency Fosc |
// +---------------------------+
// | 0xD5 |
// | 0x80 |
// +---------------------------+
// ||
// +---------------------------+
// | Enable charge pump |
// | regulator |
// +---------------------------+
// | 0x8D |
// | 0x14 |
// +---------------------------+
// ||
// +---------------------------+
// | Deactivate Scroll |
// +---------------------------+
// | 0x2E |
// +---------------------------+
// ||
// +---------------------------+
// | Display On |
// +---------------------------+
// | 0xAF |
// +---------------------------+