|
LCDGFX LCD display driver
1.2.0
Lightweight graphics library for SSD1306, SSD1325, SSD1327, SSD1331, SSD1351, SH1106, SH1107, IL9163, ST7735, ST7789, ILI9341, PCD8544 displays over I2C/SPI
|
LCDGFX is organized in layers, each building on the one below:
┌──────────────────────────────────────────┐ │ Application Code │ ├──────────────────────────────────────────┤ │ NanoEngine (game/animation engine) │ ← Double-buffered sprite engine ├──────────────────────────────────────────┤ │ NanoCanvas / Display Drawing API │ ← drawLine, fillRect, print, etc. ├──────────────────────────────────────────┤ │ Display Interface (per-controller) │ ← startBlock/endBlock, setRotation ├──────────────────────────────────────────┤ │ Hardware Abstraction Layer (HAL) │ ← I2C/SPI platform drivers ├──────────────────────────────────────────┤ │ Hardware (I2C/SPI bus, GPIO pins) │ └──────────────────────────────────────────┘
Every display object (e.g., DisplaySSD1306_128x64_I2C) inherits from NanoDisplayOps, which provides the full set of drawing operations:
Each display controller has an interface class (e.g., InterfaceSSD1306) that handles low-level communication:
startBlock(x, y, w) — Set the RAM write windowendBlock() — Close the RAM write sessionsetRotation(r) — Set screen orientation (0–3)setContrast(c) — Adjust brightnessdisplayOn() / displayOff() — Power controlNanoCanvas provides an off-screen drawing buffer. Draw operations go to the canvas first, then the canvas is flushed to the display. This is useful for flicker-free rendering:
Canvas types match display bit depth:
NanoCanvas1 — 1-bit (monochrome)NanoCanvas8 — 8-bit (256 colors)NanoCanvas16 — 16-bit (64K colors)NanoEngine is a lightweight game/animation engine with:
For full NanoEngine documentation, see NANO_ENGINE: Nano Engine description.
The HAL layer abstracts platform differences. The library auto-detects the platform at compile time:
| HAL | Platform | Header |
|---|---|---|
| Arduino HAL | Arduino AVR, ESP32, STM32 | lcd_hal/arduino/ |
| Linux HAL | Raspberry Pi, generic Linux | lcd_hal/linux/ |
| Pico HAL | Raspberry Pi Pico | lcd_hal/pico/ |
| SDL HAL | Desktop emulation | lcd_hal/sdl/ |
For porting to new platforms, see HAL: ssd1306 library hardware abstraction layer.
Color representation depends on the display bit depth:
| Bit Depth | Type | Range | Macro |
|---|---|---|---|
| 1-bit | uint8_t | 0 or 0xFF | — |
| 4-bit | uint8_t | 0–15 | — |
| 8-bit | uint8_t | RGB332 | RGB_COLOR8(r, g, b) |
| 16-bit | uint16_t | RGB565 | RGB_COLOR16(r, g, b) |
LCDGFX is designed for minimal memory footprint:
For ATtiny85 (8 KB flash, 512 B RAM), use direct draw mode without NanoEngine.