1 # LCDGFX library for display controllers
3 [](https://travis-ci.org/lexus2k/lcdgfx)
4 [](https://coveralls.io/github/lexus2k/lcdgfx?branch=master)
7 [tocstart]: # (toc start)
9 * [Introduction](#introduction)
10 * [Documentation](#documentation)
11 * [Key Features](#key-features)
12 * [Easy to use](#easy-to-use)
13 * [Supported displays](#supported-displays)
14 * [Supported platforms](#supported-platforms)
15 * [The goals of lcdgfx library](#the-goals-of-ldcgfx-library)
16 * [Setting up](#setting-up)
24 lcdgfx driver is Arduino style C++ library with unicode support. The library can be compiled for plain Linux
25 (for example, raspberry spi), or you can use it with plain avr-gcc compiler without Arduino IDE. It supports
26 monochrome and RGB oleds and has debug mode, allowing to execute code on Linux, Windows and macOS, using SDL2.0.
27 Initially the library was intended to run on very small microcontrollers (with a little of RAM). It was developed to use as
28 few resources as possible, but still has powerful capabilities (NanoEngine), allowing to develop nice animation.
29 It works on any powerful devices like raspberry pi, esp32; and can be easily ported to new platform.
30 This library integrates another library [canvas](https://github.com/lexus2k/canvas)
34 For more information about this library, please, visit https://github.com/lexus2k/lcdgfx.
35 Documentation generated by doxygen tool can be found at [lcdgfx github.io site](http://lexus2k.github.io/lcdgfx).
36 The library provides numerous usage [examples](https://github.com/lexus2k/lcdgfx/tree/master/examples).
40 * Supports color, monochrome OLED displays
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, drawing canvas)
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/lcdgfx/wiki/Using-NanoEngine-for-systems-with-low-resources2) 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 
57 
59 
60 
62 The i2c pins can be changed via API functions. Please, refer to documentation. Keep in mind,
63 that the pins, which are allowed for i2c or spi interface, depend on the hardware.
64 The default spi SCLK and MOSI pins are defined by SPI library, and DC, RST, CES pins are configurable
72 DisplayST7735_128x160x16_SPI display(3,{-1, 4, 5, 0,-1,-1});
82 display.setColor(RGB_COLOR16(255,255,0));
83 display.drawLine(10,30,56,96);
87 ## Supported displays:
89 | **Display** | **I2C** | **SPI** | **Orientation** | **Comments** |
90 | :-------- |:---:|:---:|:---:|:---------|
91 | sh1106 128x64 | X | X | | |
92 | ssd1306 128x64 | X | X | | |
93 | ssd1306 128x32 | X | X | | |
94 | ssd1325 128x64 | X | X | | |
95 | ssd1327 128x128 | X | X | | |
96 | ssd1331 96x64 | | X | X | |
97 | ssd1351 128x128 | | X | | |
98 | il9163 128x128 | | X | X | |
99 | st7735 128x160 | | X | X | |
100 | ili9341 240x320 | | X | X | |
101 | pcd8544 84x48 | | X | | Nokia 5110 |
103 ## Supported platforms
105 Compilers: gcc, clang
107 | **Platforms** | **I2C** | **SPI** | **Comments** |
108 | :-------- |:---:|:---:|:---------|
109 | **Arduino** | | | |
110 | 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) |
111 | 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) |
112 | Atmega328p, Atmega168 | X | X | |
113 | Atmega32u4 | X | X | |
114 | Atmega2560 | X | X | |
115 | Digispark, including PRO version | X | X | check [examples compatibility list](../examples/Digispark_compatibility.txt) |
116 | ESP8266 | X | X | check [examples compatibility list](../examples/ESP8266_compatibility.txt) |
117 | ESP32 | X | X | check [examples compatibility list](../examples/ESP8266_compatibility.txt) |
118 | STM32 | X | X | [stm32duino](https://github.com/stm32duino/wiki/wiki) |
119 | Arduino Zero | X | X | |
120 | Nordic nRF5 (nRF51, nRF52) | X | X | via Standard Arduino nRF52 boards. nRF users, enable c++11 in platform.txt `-std=gnu++11` |
121 | Nordic nRF5 (nRF51, nRF52) | X | X | via [Sandeep Mistry arduino-nRF5](https://github.com/sandeepmistry/arduino-nRF5) package |
122 | **Plain AVR** | | | |
123 | Attiny85, Attiny45 | X | X | |
124 | Atmega328p, Atmega168 | X | X | |
125 | Atmega32u4 | X | X | |
126 | **Plain ESP32** | | | |
127 | ESP32 | X | X | library can be used as IDF component |
129 | Raspberry Pi | X | X | i2c-dev, spidev, sys/class/gpio |
130 | [SDL Emulation](https://github.com/lexus2k/lcdgfx/wiki/How-to-run-emulator-mode) | X | X | demo code can be run without real OLED HW via SDL library |
132 | [SDL Emulation](https://github.com/lexus2k/lcdgfx/wiki/How-to-run-emulator-mode) | X | X | demo code can be run without real OLED HW via SDL library |
133 | **Windows** | | | |
134 | [SDL Emulation](https://github.com/lexus2k/lcdgfx/wiki/How-to-run-emulator-mode) | X | X | demo code can be run without real OLED HW via MinGW32 + SDL library |
136 Digispark users, please check compilation options in your Arduino prior to using this library.
137 lcdgfx library requires at least c++11 and c99 (by default Digispark package misses the options
138 -std=gnu11, -std=gnu++11).
140 ## The goals of lcdgfx library
142 * To use as few RAM as possible
143 * To use as few Flash as possible
144 * To be as fast as possible
145 * To fit [Arkanoid game example](../examples/games/arkanoid) to Attiny85 microcontroller
149 *i2c Hardware setup is described [here](https://github.com/lexus2k/lcdgfx/wiki/Hardware-setup)*
151 *Setting up for Arduino from github sources)*
152 * Download source from https://github.com/lexus2k/lcdgfx
153 * Put the sources to Arduino/libraries/lcdgfx folder
155 *Setting up for Arduino from Arduino IDE library manager*
156 * Install lcdgfx library (named lcdgfx by Alexey Dynda) via Arduino IDE library manager
158 *Using with plain avr-gcc:*
159 * Download source from https://github.com/lexus2k/lcdgfx
160 * Build the library (variant 1)
161 * cd lcdgfx/src && make -f Makefile.avr MCU=<your_mcu>
162 * Link library to your project (refer to [Makefile.avr](../examples/Makefile.avr) in examples folder).
163 * Build demo code (variant 2)
164 * cd lcdgfx/tools && ./build_and_run.sh -p avr -m <your_mcu> ssd1306_demo
167 * Download source from https://github.com/lexus2k/lcdgfx
168 * Put downloaded sources to components/lcdgfx/ folder.
169 * Compile your project as described in ESP-IDF build system documentation
171 For more information about this library, please, visit https://github.com/lexus2k/lcdgfx.
172 Doxygen documentation can be found at [github.io site](http://lexus2k.github.io/lcdgfx).
173 If you found any problem or have any idea, please, report to Issues section.
177 The library is free. If this project helps you, you can give me a cup of coffee.
181 Copyright (c) 2016-2020, Alexey Dynda
183 Permission is hereby granted, free of charge, to any person obtaining a copy
184 of this software and associated documentation files (the "Software"), to deal
185 in the Software without restriction, including without limitation the rights
186 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
187 copies of the Software, and to permit persons to whom the Software is
188 furnished to do so, subject to the following conditions:
190 The above copyright notice and this permission notice shall be included in all
191 copies or substantial portions of the Software.
193 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
194 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
195 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
196 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
197 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
198 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE