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
gfx_compat.h File Reference

Adafruit_GFX-compatible facade over lcdgfx displays. More...

#include "lcd_hal/io.h"
#include <stdint.h>
#include <stddef.h>
Include dependency graph for gfx_compat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  GFXglyph
 Adafruit_GFX glyph descriptor. More...
 
struct  GFXfont
 Adafruit_GFX font descriptor. More...
 
class  GfxCompat< D >
 Adafruit_GFX-compatible adapter around any lcdgfx display or canvas type D. More...
 
#define _GFXFONT_H_
 
template<class D >
GfxCompat< D > makeGfxCompat (D &display)
 Convenience factory that deduces the display type, so callers can write auto gfx = makeGfxCompat(display); instead of naming the template argument.
 

Detailed Description

Adafruit_GFX-compatible facade over lcdgfx displays.

Drop-in Adafruit_GFX-style API implemented on top of any lcdgfx display or canvas, requiring NO external Adafruit_GFX library.

Existing sketches written against the ubiquitous Adafruit_GFX API (drawPixel/drawLine/fillRect/print/setCursor/... with int16_t coordinates and a trailing uint16_t color) can run on any display supported by lcdgfx by wrapping the display in a GfxCompat adapter:

DisplaySSD1306_128x64_I2C display(-1);
GfxCompat<decltype(display)> gfx(display); // or: auto gfx = makeGfxCompat(display);
void setup() {
display.begin();
gfx.fillScreen(0);
gfx.drawRect(0, 0, 128, 64, 1);
gfx.setCursor(10, 10);
gfx.print("Hello GFX");
}

The adapter is a zero-overhead, header-only template: it forwards directly to the underlying lcdgfx primitives (no virtual calls, no buffer). color is passed through unchanged, so it carries the same meaning as for the underlying display (0/1 for monochrome, RGB_COLOR8/RGB_COLOR16 for color panels), exactly like Adafruit_GFX.

Note
Intentional differences from Adafruit_GFX: text scaling (setTextSize) is honored only at size 1 (lcdgfx uses fixed-cell fonts); setRotation is stored but rotation is controlled through the underlying display's own configuration. These are stubbed so GFX sketches compile unchanged.

Definition in file gfx_compat.h.