1 # ssd1306 library introduction # {#index}
5 [tocstart]: # (toc start)
7 * [Introduction](#introduction)
8 * [Key Features](#key-features)
9 * [Supported displays](#supported-displays)
10 * [Supported platforms](#supported-platforms)
11 * [Setting up](#setting-up)
17 <a name="introduction"></a>
20 SSD1306 driver is Arduino style C/C++ library with unicode support. The library can be compiled for plain Linux
21 (for example, raspberry spi), or you can use it with plain avr-gcc compiler without Arduino IDE, or with
22 ESP32 IDF. It supports monochrome and RGB oleds and has debug mode, allowing to execute code on PC, using SDL2.0.
23 Initially the library is intended for very small microcontrollers (with a little of RAM). It was developed to use as
24 few resources as possible, but still has powerful capabilities, allowing to develop nice animation.
25 It works on any powerful devices like raspberry pi, esp32; and can be easily ported to new platform.
27 Since ssd1306 library supports different display types: monochrome, 8-bit color, 16-bit color displays, -
28 there are several group of API functions:
30 * Generic API functions (font specific, cursor positioning, menu implementation)
31 * 1-bit API functions for monochrome displays (these ones can be used both for color and mono lcd)
32 * 8-bit API functions for color displays (these ones work only for color displays)
33 * 16-bit API functions for color displays (only color displays)
35 Also, for graphics animation there special C++ API, called [Nano Engine](nano_engine/README.md).
37 <a name="key-features"></a>
40 * Supports color, monochrome OLED displays, and VGA monitor
41 * The library has modular structure, and some modules can be excluded from compilation at all to reduce flash usage.
42 * Needs very little RAM (Attiny85 with Damellis package needs minimum 25 bytes of RAM to communicate with OLED)
43 * Fast implementation to provide reasonable speed on slow microcontrollers
44 * Supports i2c and spi interfaces:
45 * i2c (software implementation, Wire library, AVR Twi, Linux i2c-dev)
46 * spi (4-wire spi via Arduino SPI library, AVR Spi, AVR USI module)
47 * Primitive graphics functions (lines, rectangles, pixels, bitmaps)
48 * Printing text to display (using fonts of different size, you can use GLCD Font Creator to create new fonts)
49 * Includes [graphics engine](https://github.com/lexus2k/ssd1306/wiki/Using-NanoEngine-for-systems-with-low-resources) to support
50 double buffering on tiny microcontrollers.
51 * Can be used for game development (bonus examples):
52 * Arkanoid game ([arkanoid](examples/games/arkanoid) in old style API and [arkanoid8](examples/games/arkanoid8) in new style API)
53 * Simple [Lode runner](examples/games/lode_runner) game.
54 * [Snowflakes](examples/nano_engine/snowflakes)
56 The i2c pins can be changed via API functions. Please, refer to documentation. Keep in mind,
57 that the pins, which are allowed for i2c or spi interface, depend on the hardware.
58 The default spi SCLK and MOSI pins are defined by SPI library, and DC, RST, CES pins are configurable
61 <a name="supported-displays"></a>
62 ## Supported displays:
64 | **Display** | **I2C** | **SPI** | **Orientation** | **Comments** |
65 | :-------- |:---:|:---:|:---:|:---------|
66 | sh1106 128x64 | X | | | |
67 | ssd1306 128x64 | X | X | | |
68 | ssd1306 128x32 | X | X | | |
69 | ssd1325 128x64 | | X | | |
70 | ssd1327 128x128 | | X | | |
71 | ssd1351 128x128 | | X | | |
72 | il9163 128x128 | | X | X | |
73 | st7735 128x160 | | X | X | |
74 | ili9341 240x320 | | X | X | |
75 | pcd8544 84x48 | | X | | Nokia 5110 |
76 | vga 96x40 color | | | | direct D-sub output, atmega328p only |
77 | vga 128x64 bw | | | | direct D-sub output, atmega328p only |
79 <a name="supported-platforms"></a>
80 ## Supported platforms
82 | **Platforms** | **I2C** | **SPI** | **Comments** |
83 | :-------- |:---:|:---:|:---------|
85 | Attiny85, Attiny45 | X | X | Refer to [Damellis attiny package](https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json) |
86 | Attiny84, Attiny44 | X | X | Refer to [Damellis attiny package](https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json) |
87 | Atmega328p, Atmega168 | X | X | |
88 | Atmega32u4 | X | X | |
89 | Atmega2560 | X | X | |
90 | Digispark, including PRO version | X | X | check [examples compatibility list](examples/Digispark_compatibility.txt) |
91 | ESP8266 | X | X | check [examples compatibility list](examples/ESP8266_compatibility.txt) |
92 | ESP32 | X | X | check [examples compatibility list](examples/ESP8266_compatibility.txt) |
93 | STM32 | X | X | [stm32duino](https://github.com/stm32duino/wiki/wiki) |
94 | Arduino Zero | X | X | |
95 | Nordic nRF5 (nRF51, nRF52) | X | X | nRF users, enable c++11 in platform.txt `-std=gnu++11` |
96 | Nordic nRF5 (nRF51, nRF52) | X | X | via [Sandeep Mistry arduino-nRF5](https://github.com/sandeepmistry/arduino-nRF5) package |
97 | **Plain AVR** | | | |
98 | Attiny85, Attiny45 | X | X | |
99 | Atmega328p, Atmega168 | X | X | |
100 | Atmega32u4 | X | X | |
101 | **Plain ESP32** | | | |
102 | ESP32 | X | X | library can be used as IDF component |
104 | Raspberry Pi | X | X | i2c-dev, spidev, sys/class/gpio |
105 | [SDL Emulation](https://github.com/lexus2k/ssd1306/wiki/How-to-run-emulator-mode) | X | X | demo code can be run without real OLED HW via SDL library |
106 | **Windows** | | | |
107 | [SDL Emulation](https://github.com/lexus2k/ssd1306/wiki/How-to-run-emulator-mode) | X | X | demo code can be run without real OLED HW via MinGW32 + SDL library |
109 Digispark users, please check compilation options in your Arduino prior to using this library.
110 Ssd1306 library requires at least c++11 and c99 (by default Digispark package misses the options
111 -std=gnu11, -std=gnu++11).
113 <a name="setting-up"></a>
116 *i2c Hardware setup is described [here](https://github.com/lexus2k/ssd1306/wiki/Hardware-setup)*
118 *Setting up for Arduino from github sources)*
119 * Download source from https://github.com/lexus2k/ssd1306
120 * Put the sources to Arduino/libraries/ssd1306/ folder
122 *Setting up for Arduino from Arduino IDE library manager*
123 * Install ssd1306 library (named ssd1306 by Alexey Dynda) via Arduino IDE library manager
125 *Using with plain avr-gcc:*
126 * Download source from https://github.com/lexus2k/ssd1306
127 * Build the library (variant 1)
128 * cd ssd1306/src && make -f Makefile.avr MCU=<your_mcu>
129 * Link library to your project (refer to [Makefile.avr](examples/Makefile.avr) in examples folder).
130 * Build demo code (variant 2)
131 * cd ssd1306/tools && ./build_and_run.sh -p avr -m <your_mcu> ssd1306_demo
134 * Download source from https://github.com/lexus2k/ssd1306
135 * Put downloaded sources to components/ssd1306/ folder.
136 * Compile your project as described in ESP-IDF build system documentation
138 For more information about this library, please, visit https://github.com/lexus2k/ssd1306.
139 Doxygen documentation can be found at [github.io site](http://lexus2k.github.io/ssd1306).
140 If you found any problem or have any idea, please, report to Issues section.
142 <a name="license"></a>
145 The library is free. If this project helps you, you can give me a cup of coffee. [Donate via Paypal](https://www.paypal.me/lexus2k)
149 Copyright (c) 2016-2019, Alexey Dynda
151 Permission is hereby granted, free of charge, to any person obtaining a copy
152 of this software and associated documentation files (the "Software"), to deal
153 in the Software without restriction, including without limitation the rights
154 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
155 copies of the Software, and to permit persons to whom the Software is
156 furnished to do so, subject to the following conditions:
158 The above copyright notice and this permission notice shall be included in all
159 copies or substantial portions of the Software.
161 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
162 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
163 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
164 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
165 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
166 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE