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 * [Key Features](#key-features)
11 * [Easy to use](#easy-to-use)
12 * [Supported displays](#supported-displays)
13 * [Supported platforms](#supported-platforms)
14 * [Setting up](#setting-up)
22 lcdgfx driver is Arduino style C++ library with unicode support. The library can be compiled for plain Linux
23 (for example, raspberry spi), or you can use it with plain avr-gcc compiler without Arduino IDE. It supports
24 monochrome and RGB oleds and has debug mode, allowing to execute code on PC, using SDL2.0.
25 Initially the library was intended to run on very small microcontrollers (with a little of RAM). It was developed to use as
26 few resources as possible, but still has powerful capabilities (NanoEngine), allowing to develop nice animation.
27 It works on any powerful devices like raspberry pi, esp32; and can be easily ported to new platform.
28 This library integrates another library [canvas](https://github.com/lexus2k/canvas)
32 * Supports color, monochrome OLED displays
33 * The library has modular structure, and some modules can be excluded from compilation at all to reduce flash usage.
34 * Needs very little RAM (Attiny85 with Damellis package needs minimum 25 bytes of RAM to communicate with OLED)
35 * Fast implementation to provide reasonable speed on slow microcontrollers
36 * Supports i2c and spi interfaces:
37 * i2c (software implementation, Wire library, AVR Twi, Linux i2c-dev)
38 * spi (4-wire spi via Arduino SPI library, AVR Spi, AVR USI module)
39 * Primitive graphics functions (lines, rectangles, pixels, bitmaps, drawing canvas)
40 * Printing text to display (using fonts of different size, you can use GLCD Font Creator to create new fonts)
41 * Includes [graphics engine](https://github.com/lexus2k/lcdgfx/wiki/Using-NanoEngine-for-systems-with-low-resources2) to support
42 double buffering on tiny microcontrollers.
43 * Can be used for game development (bonus examples):
44 * Arkanoid game ([arkanoid](examples/games/arkanoid) in old style API and [arkanoid8](examples/games/arkanoid8) in new style API)
45 * Simple [Lode runner](examples/games/lode_runner) game.
46 * [Snowflakes](examples/nano_engine/snowflakes)
48 
49 
51 
52 
54 The i2c pins can be changed via API functions. Please, refer to documentation. Keep in mind,
55 that the pins, which are allowed for i2c or spi interface, depend on the hardware.
56 The default spi SCLK and MOSI pins are defined by SPI library, and DC, RST, CES pins are configurable
64 DisplayST7735_128x160x16_SPI display(3,{-1, 4, 5, 0,-1,-1});
74 display.setColor(RGB_COLOR16(255,255,0));
75 display.drawLine(10,30,56,96);
79 ## Supported displays:
81 | **Display** | **I2C** | **SPI** | **Orientation** | **Comments** |
82 | :-------- |:---:|:---:|:---:|:---------|
83 | sh1106 128x64 | X | X | | |
84 | ssd1306 128x64 | X | X | | |
85 | ssd1306 128x32 | X | X | | |
86 | ssd1325 128x64 | X | X | | |
87 | ssd1327 128x128 | X | X | | |
88 | ssd1331 96x64 | | X | X | |
89 | ssd1351 128x128 | | X | | |
90 | il9163 128x128 | | X | X | |
91 | st7735 128x160 | | X | X | |
92 | ili9341 240x320 | | X | X | |
93 | pcd8544 84x48 | | X | | Nokia 5110 |
95 ## Supported platforms
97 | **Platforms** | **I2C** | **SPI** | **Comments** |
98 | :-------- |:---:|:---:|:---------|
100 | 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) |
101 | 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) |
102 | Atmega328p, Atmega168 | X | X | |
103 | Atmega32u4 | X | X | |
104 | Atmega2560 | X | X | |
105 | Digispark, including PRO version | X | X | check [examples compatibility list](examples/Digispark_compatibility.txt) |
106 | ESP8266 | X | X | check [examples compatibility list](examples/ESP8266_compatibility.txt) |
107 | ESP32 | X | X | check [examples compatibility list](examples/ESP8266_compatibility.txt) |
108 | STM32 | X | X | [stm32duino](https://github.com/stm32duino/wiki/wiki) |
109 | Arduino Zero | X | X | |
110 | Nordic nRF5 (nRF51, nRF52) | X | X | via Standard Arduino nRF52 boards. nRF users, enable c++11 in platform.txt `-std=gnu++11` |
111 | Nordic nRF5 (nRF51, nRF52) | X | X | via [Sandeep Mistry arduino-nRF5](https://github.com/sandeepmistry/arduino-nRF5) package |
112 | **Plain AVR** | | | |
113 | Attiny85, Attiny45 | X | X | |
114 | Atmega328p, Atmega168 | X | X | |
115 | Atmega32u4 | X | X | |
116 | **Plain ESP32** | | | |
117 | ESP32 | X | X | library can be used as IDF component |
119 | Raspberry Pi | X | X | i2c-dev, spidev, sys/class/gpio |
120 | [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 |
121 | **Windows** | | | |
122 | [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 |
124 Digispark users, please check compilation options in your Arduino prior to using this library.
125 lcdgfx library requires at least c++11 and c99 (by default Digispark package misses the options
126 -std=gnu11, -std=gnu++11).
128 ## The goals of lcdgfx library
130 * To use as few RAM as possible
131 * To use as few Flash as possible
132 * To be as fast as possible
133 * To fit [Arkanoid game example](examples/games/arkanoid) to Attiny85 microcontroller
137 *i2c Hardware setup is described [here](https://github.com/lexus2k/lcdgfx/wiki/Hardware-setup)*
139 *Setting up for Arduino from github sources)*
140 * Download source from https://github.com/lexus2k/lcdgfx
141 * Put the sources to Arduino/libraries/lcdgfx folder
143 *Setting up for Arduino from Arduino IDE library manager*
144 * Install lcdgfx library (named lcdgfx by Alexey Dynda) via Arduino IDE library manager
146 *Using with plain avr-gcc:*
147 * Download source from https://github.com/lexus2k/lcdgfx
148 * Build the library (variant 1)
149 * cd lcdgfx/src && make -f Makefile.avr MCU=<your_mcu>
150 * Link library to your project (refer to [Makefile.avr](examples/Makefile.avr) in examples folder).
151 * Build demo code (variant 2)
152 * cd lcdgfx/tools && ./build_and_run.sh -p avr -m <your_mcu> ssd1306_demo
155 * Download source from https://github.com/lexus2k/lcdgfx
156 * Put downloaded sources to components/lcdgfx/ folder.
157 * Compile your project as described in ESP-IDF build system documentation
159 For more information about this library, please, visit https://github.com/lexus2k/lcdgfx.
160 Doxygen documentation can be found at [github.io site](http://lexus2k.github.io/lcdgfx).
161 If you found any problem or have any idea, please, report to Issues section.
165 The library is free. If this project helps you, you can give me a cup of coffee.
169 Copyright (c) 2016-2019, Alexey Dynda
171 Permission is hereby granted, free of charge, to any person obtaining a copy
172 of this software and associated documentation files (the "Software"), to deal
173 in the Software without restriction, including without limitation the rights
174 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
175 copies of the Software, and to permit persons to whom the Software is
176 furnished to do so, subject to the following conditions:
178 The above copyright notice and this permission notice shall be included in all
179 copies or substantial portions of the Software.
181 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
182 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
183 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
184 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
185 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
186 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE