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
GfxCompat< D > Class Template Reference

Adafruit_GFX-compatible adapter around any lcdgfx display or canvas type D. More...

#include <gfx_compat.h>

Public Member Functions

 GfxCompat (D &display)
 Creates an Adafruit_GFX-compatible facade bound to an existing display. More...
 
int16_t width ()
 Returns display width in pixels (Adafruit_GFX::width()). More...
 
int16_t height ()
 Returns display height in pixels (Adafruit_GFX::height()). More...
 
void drawPixel (int16_t x, int16_t y, uint16_t color)
 Draws a single pixel of the given color (Adafruit_GFX::drawPixel()). More...
 
void drawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 Draws a vertical run of h pixels (Adafruit_GFX::drawFastVLine()). More...
 
void drawFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 Draws a horizontal run of w pixels (Adafruit_GFX::drawFastHLine()). More...
 
void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 Draws an arbitrary line (Adafruit_GFX::drawLine()). More...
 
void drawRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 Draws a rectangle outline of size w*h (Adafruit_GFX::drawRect()). More...
 
void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 Fills a rectangle of size w*h (Adafruit_GFX::fillRect()). More...
 
void fillScreen (uint16_t color)
 Fills the whole screen with a single color (Adafruit_GFX::fillScreen()). More...
 
void drawCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 Draws a circle outline (Adafruit_GFX::drawCircle()). More...
 
void fillCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 Draws a filled circle (Adafruit_GFX::fillCircle()). More...
 
void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 Draws a triangle outline (Adafruit_GFX::drawTriangle()). More...
 
void fillTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 Draws a filled triangle (Adafruit_GFX::fillTriangle()). More...
 
void drawRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
 Draws a rounded-rectangle outline (Adafruit_GFX::drawRoundRect()). More...
 
void fillRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
 Draws a filled rounded rectangle (Adafruit_GFX::fillRoundRect()). More...
 
void drawBitmap (int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)
 Draws a 1-bit bitmap using the foreground color (Adafruit_GFX::drawBitmap()). More...
 
void setCursor (int16_t x, int16_t y)
 Positions the text cursor (Adafruit_GFX::setCursor()). More...
 
void setTextColor (uint16_t color)
 Sets text foreground color (Adafruit_GFX::setTextColor()). More...
 
void setTextColor (uint16_t color, uint16_t background)
 Sets text foreground and background color (Adafruit_GFX::setTextColor()). More...
 
void setFont (const GFXfont *font)
 Selects an Adafruit_GFX custom font (GFXfont) for text output. More...
 
void setTextSize (uint8_t size)
 Accepts an Adafruit_GFX text size. More...
 
void setRotation (uint8_t rotation)
 Accepts an Adafruit_GFX rotation value for source compatibility. More...
 
uint8_t getRotation ()
 Returns the stored rotation value (Adafruit_GFX::getRotation()). More...
 
size_t write (uint8_t ch)
 Writes a single character at the text cursor (Adafruit_GFX::write()). More...
 
void print (const char *str)
 Prints a null-terminated string (Adafruit_GFX/Print::print()). More...
 
void print (char c)
 Prints a single character (Adafruit_GFX/Print::print()). More...
 
void print (int number)
 Prints a signed integer in base 10 (Adafruit_GFX/Print::print()). More...
 
void print (long number)
 Prints a signed long in base 10 (Adafruit_GFX/Print::print()). More...
 
void println (const char *str)
 Prints a string followed by a newline (Adafruit_GFX/Print::println()). More...
 
void println (int number)
 Prints an integer followed by a newline (Adafruit_GFX/Print::println()). More...
 
void println ()
 Emits a newline (Adafruit_GFX/Print::println()). More...
 
void startWrite ()
 Adafruit_GFX transaction start hook. More...
 
void writePixel (int16_t x, int16_t y, uint16_t color)
 Adafruit_GFX transaction pixel write; identical to drawPixel(). More...
 
void endWrite ()
 Adafruit_GFX transaction end hook. More...
 
D & display ()
 Returns the wrapped lcdgfx display/canvas for native calls. More...
 

Detailed Description

template<class D>
class GfxCompat< D >

Adafruit_GFX-compatible adapter around any lcdgfx display or canvas type D.

D must expose the standard lcdgfx primitives: setColor(), setBackground(), putPixel(), drawHLine(), drawVLine(), drawLine(), drawRect(), fillRect(), drawCircle(), drawBitmap1(), width(), height(), setTextCursor(), write(). All lcdgfx Display* classes and NanoCanvasOps-based canvases qualify.

Definition at line 107 of file gfx_compat.h.

Constructor & Destructor Documentation

◆ GfxCompat()

template<class D>
GfxCompat< D >::GfxCompat ( D &  display)
inlineexplicit

Creates an Adafruit_GFX-compatible facade bound to an existing display.

Parameters
displayreference to an already-constructed lcdgfx display/canvas. The reference must outlive the adapter.

Definition at line 115 of file gfx_compat.h.

Member Function Documentation

◆ display()

template<class D>
D& GfxCompat< D >::display ( )
inline

Returns the wrapped lcdgfx display/canvas for native calls.

Definition at line 443 of file gfx_compat.h.

◆ drawBitmap()

template<class D>
void GfxCompat< D >::drawBitmap ( int16_t  x,
int16_t  y,
const uint8_t *  bitmap,
int16_t  w,
int16_t  h,
uint16_t  color 
)
inline

Draws a 1-bit bitmap using the foreground color (Adafruit_GFX::drawBitmap()).

Bitmap layout matches lcdgfx drawBitmap1.

Definition at line 288 of file gfx_compat.h.

◆ drawCircle()

template<class D>
void GfxCompat< D >::drawCircle ( int16_t  x0,
int16_t  y0,
int16_t  r,
uint16_t  color 
)
inline

Draws a circle outline (Adafruit_GFX::drawCircle()).

Definition at line 197 of file gfx_compat.h.

◆ drawFastHLine()

template<class D>
void GfxCompat< D >::drawFastHLine ( int16_t  x,
int16_t  y,
int16_t  w,
uint16_t  color 
)
inline

Draws a horizontal run of w pixels (Adafruit_GFX::drawFastHLine()).

Definition at line 156 of file gfx_compat.h.

◆ drawFastVLine()

template<class D>
void GfxCompat< D >::drawFastVLine ( int16_t  x,
int16_t  y,
int16_t  h,
uint16_t  color 
)
inline

Draws a vertical run of h pixels (Adafruit_GFX::drawFastVLine()).

Definition at line 147 of file gfx_compat.h.

◆ drawLine()

template<class D>
void GfxCompat< D >::drawLine ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
uint16_t  color 
)
inline

Draws an arbitrary line (Adafruit_GFX::drawLine()).

Definition at line 165 of file gfx_compat.h.

◆ drawPixel()

template<class D>
void GfxCompat< D >::drawPixel ( int16_t  x,
int16_t  y,
uint16_t  color 
)
inline

Draws a single pixel of the given color (Adafruit_GFX::drawPixel()).

Definition at line 133 of file gfx_compat.h.

◆ drawRect()

template<class D>
void GfxCompat< D >::drawRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
uint16_t  color 
)
inline

Draws a rectangle outline of size w*h (Adafruit_GFX::drawRect()).

Definition at line 172 of file gfx_compat.h.

◆ drawRoundRect()

template<class D>
void GfxCompat< D >::drawRoundRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
int16_t  r,
uint16_t  color 
)
inline

Draws a rounded-rectangle outline (Adafruit_GFX::drawRoundRect()).

Definition at line 254 of file gfx_compat.h.

◆ drawTriangle()

template<class D>
void GfxCompat< D >::drawTriangle ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2,
uint16_t  color 
)
inline

Draws a triangle outline (Adafruit_GFX::drawTriangle()).

Definition at line 215 of file gfx_compat.h.

◆ endWrite()

template<class D>
void GfxCompat< D >::endWrite ( )
inline

Adafruit_GFX transaction end hook.

No-op for lcdgfx.

Definition at line 438 of file gfx_compat.h.

◆ fillCircle()

template<class D>
void GfxCompat< D >::fillCircle ( int16_t  x0,
int16_t  y0,
int16_t  r,
uint16_t  color 
)
inline

Draws a filled circle (Adafruit_GFX::fillCircle()).

Definition at line 206 of file gfx_compat.h.

◆ fillRect()

template<class D>
void GfxCompat< D >::fillRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
uint16_t  color 
)
inline

Fills a rectangle of size w*h (Adafruit_GFX::fillRect()).

Definition at line 181 of file gfx_compat.h.

◆ fillRoundRect()

template<class D>
void GfxCompat< D >::fillRoundRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
int16_t  r,
uint16_t  color 
)
inline

Draws a filled rounded rectangle (Adafruit_GFX::fillRoundRect()).

Definition at line 272 of file gfx_compat.h.

◆ fillScreen()

template<class D>
void GfxCompat< D >::fillScreen ( uint16_t  color)
inline

Fills the whole screen with a single color (Adafruit_GFX::fillScreen()).

Definition at line 190 of file gfx_compat.h.

◆ fillTriangle()

template<class D>
void GfxCompat< D >::fillTriangle ( int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2,
uint16_t  color 
)
inline

Draws a filled triangle (Adafruit_GFX::fillTriangle()).

Note
Filled by vertical spans (one write per column) instead of the Adafruit horizontal-scanline method. On bufferless paged monochrome displays a horizontal fill would clobber earlier rows in the same 8-pixel page byte; column fills avoid that and behave identically on color panels.

Definition at line 230 of file gfx_compat.h.

◆ getRotation()

template<class D>
uint8_t GfxCompat< D >::getRotation ( )
inline

Returns the stored rotation value (Adafruit_GFX::getRotation()).

Definition at line 348 of file gfx_compat.h.

◆ height()

template<class D>
int16_t GfxCompat< D >::height ( )
inline

Returns display height in pixels (Adafruit_GFX::height()).

Definition at line 127 of file gfx_compat.h.

◆ print() [1/4]

template<class D>
void GfxCompat< D >::print ( const char *  str)
inline

Prints a null-terminated string (Adafruit_GFX/Print::print()).

Definition at line 369 of file gfx_compat.h.

◆ print() [2/4]

template<class D>
void GfxCompat< D >::print ( char  c)
inline

Prints a single character (Adafruit_GFX/Print::print()).

Definition at line 385 of file gfx_compat.h.

◆ print() [3/4]

template<class D>
void GfxCompat< D >::print ( int  number)
inline

Prints a signed integer in base 10 (Adafruit_GFX/Print::print()).

Definition at line 391 of file gfx_compat.h.

◆ print() [4/4]

template<class D>
void GfxCompat< D >::print ( long  number)
inline

Prints a signed long in base 10 (Adafruit_GFX/Print::print()).

Definition at line 397 of file gfx_compat.h.

◆ println() [1/3]

template<class D>
void GfxCompat< D >::println ( const char *  str)
inline

Prints a string followed by a newline (Adafruit_GFX/Print::println()).

Definition at line 405 of file gfx_compat.h.

◆ println() [2/3]

template<class D>
void GfxCompat< D >::println ( int  number)
inline

Prints an integer followed by a newline (Adafruit_GFX/Print::println()).

Definition at line 412 of file gfx_compat.h.

◆ println() [3/3]

template<class D>
void GfxCompat< D >::println ( )
inline

Emits a newline (Adafruit_GFX/Print::println()).

Definition at line 419 of file gfx_compat.h.

◆ setCursor()

template<class D>
void GfxCompat< D >::setCursor ( int16_t  x,
int16_t  y 
)
inline

Positions the text cursor (Adafruit_GFX::setCursor()).

Definition at line 297 of file gfx_compat.h.

◆ setFont()

template<class D>
void GfxCompat< D >::setFont ( const GFXfont font)
inline

Selects an Adafruit_GFX custom font (GFXfont) for text output.

Pass a font produced by Adafruit's fontconvert tool. Call setFont(nullptr) to revert to the underlying display's built-in fixed font.

Definition at line 324 of file gfx_compat.h.

◆ setRotation()

template<class D>
void GfxCompat< D >::setRotation ( uint8_t  rotation)
inline

Accepts an Adafruit_GFX rotation value for source compatibility.

Rotation is configured through the underlying display; the value is stored only.

Definition at line 342 of file gfx_compat.h.

◆ setTextColor() [1/2]

template<class D>
void GfxCompat< D >::setTextColor ( uint16_t  color)
inline

Sets text foreground color (Adafruit_GFX::setTextColor()).

Definition at line 305 of file gfx_compat.h.

◆ setTextColor() [2/2]

template<class D>
void GfxCompat< D >::setTextColor ( uint16_t  color,
uint16_t  background 
)
inline

Sets text foreground and background color (Adafruit_GFX::setTextColor()).

Definition at line 312 of file gfx_compat.h.

◆ setTextSize()

template<class D>
void GfxCompat< D >::setTextSize ( uint8_t  size)
inline

Accepts an Adafruit_GFX text size.

lcdgfx uses fixed-cell fonts, so only size 1 renders scaled output; other values are stored but not applied.

Definition at line 333 of file gfx_compat.h.

◆ startWrite()

template<class D>
void GfxCompat< D >::startWrite ( )
inline

Adafruit_GFX transaction start hook.

No-op for lcdgfx.

Definition at line 427 of file gfx_compat.h.

◆ width()

template<class D>
int16_t GfxCompat< D >::width ( )
inline

Returns display width in pixels (Adafruit_GFX::width()).

Definition at line 121 of file gfx_compat.h.

◆ write()

template<class D>
size_t GfxCompat< D >::write ( uint8_t  ch)
inline

Writes a single character at the text cursor (Adafruit_GFX::write()).

Definition at line 354 of file gfx_compat.h.

◆ writePixel()

template<class D>
void GfxCompat< D >::writePixel ( int16_t  x,
int16_t  y,
uint16_t  color 
)
inline

Adafruit_GFX transaction pixel write; identical to drawPixel().

Definition at line 432 of file gfx_compat.h.


The documentation for this class was generated from the following file: