SSD1306/README.md

122 lines
4.4 KiB
Markdown
Raw Normal View History

2020-10-27 09:03:43 -04:00
# C Library for SSD1306 0.96" OLED display
2020-10-13 05:01:17 -04:00
## SSD1306 Description
Detailed information are described in [Datasheet SSD1306](https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf).
## Library
2020-10-13 06:56:27 -04:00
C library is aimed for driving [SSD1306 0.96" OLED display](#demonstration) 128x64 through TWI's Atmega16.
2020-10-13 05:01:17 -04:00
2020-10-13 07:04:33 -04:00
## Dependencies
- [font.c](https://github.com/Matiasus/SSD1306/blob/readme-edits/lib/font.c)
- [font.h](https://github.com/Matiasus/SSD1306/blob/readme-edits/lib/font.h)
- [twi.c](https://github.com/Matiasus/SSD1306/blob/readme-edits/lib/twi.c)
- [twi.h](https://github.com/Matiasus/SSD1306/blob/readme-edits/lib/twi.h)
2020-10-27 08:46:37 -04:00
Font.c can be modified according to application requirements with form defined in font.c. Maximal permissible horizontal dimension is 8 bits.
2020-10-27 08:20:54 -04:00
2020-10-13 05:01:17 -04:00
### Usage
2020-10-13 07:04:33 -04:00
Prior defined for MCU Atmega16 / Atmega8. Need to be carefull with TWI ports definition.
2020-10-13 05:01:17 -04:00
| PORT | [Atmega16](http://ww1.microchip.com/downloads/en/devicedoc/doc2466.pdf) | [Atmega8](https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2486-8-bit-AVR-microcontroller-ATmega8_L_datasheet.pdf) |
| :---: | :---: | :---: |
| SCL | PC0 | PC5 |
| SDA | PC1 | PC4 |
### Tested
Library was tested and proved on a **_SSD1306 0.96″ OLED Dispay_** with **_Atmega16_**.
2020-10-13 07:00:31 -04:00
## Init OLED Sequence
Init sequence OLED display was defined according to page 64 (next to last page) of [Datasheet SSD1306](https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf).
```
// +---------------------------+
// | 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 |
// +---------------------------+
```
2020-10-27 08:10:12 -04:00
## Functions
2020-10-27 08:17:28 -04:00
- [SSD1306_Init (void)](#ssd1306_init) - Init display
- [SSD1306_ClearScreen (char)](#ssd1306_clearscreen) - Clear screen
- [SSD1306_InverseScreen (void)](#ssd1306_inversescreen) - Inverse screen
- [SSD1306_SetPosition (char, char)](#ssd1306_setposition) - Set position
- [SSD1306_DrawChar (char)](#ssd1306_drawchar) - Draw specific character
- [SSD1306_DrawString (char*)](#ssd1306_drawstring) - Draw specific string
- [SSD1306_UpdateScreen (void)](#ssd1306_updatescreen) - Display on
- [SSD1306_DrawLineHorizontal (char, char, char)](#ssd1306_drawlinehorizontal) - Draw horizontal line
2020-10-27 08:57:25 -04:00
## Demonstration
2020-10-27 09:00:36 -04:00
<img src="img/demonstration_ssd1306.jpg" />
2020-10-27 08:57:25 -04:00
2020-10-13 05:01:17 -04:00
## Links
- [Datasheet SSD1306](https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf)