JM9 XRCU Board 0.2.0a
Libraries API Reference
Loading...
Searching...
No Matches
Adafruit_GFX Class Referenceabstract

#include <Adafruit_GFX.h>

Inheritance diagram for Adafruit_GFX:
Print Adafruit_GrayOLED Adafruit_SPITFT GFXcanvas1 GFXcanvas16 GFXcanvas8 Adafruit_ST77xx Adafruit_ST7735 Adafruit_ST7789 Monitor

Public Member Functions

 Adafruit_GFX (int16_t w, int16_t h)
 
virtual void drawPixel (int16_t x, int16_t y, uint16_t color)=0
 Draw to the screen/framebuffer/etc. Must be overridden in subclass.
 
virtual void startWrite (void)
 
virtual void writePixel (int16_t x, int16_t y, uint16_t color)
 
virtual void writeFillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
virtual void writeFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 
virtual void writeFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 
virtual void writeLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 
virtual void endWrite (void)
 
virtual void setRotation (uint8_t r)
 
virtual void invertDisplay (bool i)
 
virtual void drawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 
virtual void drawFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 
virtual void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
virtual void fillScreen (uint16_t color)
 
virtual void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 
virtual void drawRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
void drawCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 
void drawCircleHelper (int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)
 
void fillCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 
void fillCircleHelper (int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)
 
void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 
void fillTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 
void drawRoundRect (int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
 
void fillRoundRect (int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
 
void drawBitmap (int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color)
 
void drawBitmap (int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color, uint16_t bg)
 
void drawBitmap (int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)
 
void drawBitmap (int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg)
 
void drawXBitmap (int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color)
 
void drawGrayscaleBitmap (int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h)
 
void drawGrayscaleBitmap (int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h)
 
void drawGrayscaleBitmap (int16_t x, int16_t y, const uint8_t bitmap[], const uint8_t mask[], int16_t w, int16_t h)
 
void drawGrayscaleBitmap (int16_t x, int16_t y, uint8_t *bitmap, uint8_t *mask, int16_t w, int16_t h)
 
void drawRGBBitmap (int16_t x, int16_t y, const uint16_t bitmap[], int16_t w, int16_t h)
 
void drawRGBBitmap (int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h)
 
void drawRGBBitmap (int16_t x, int16_t y, const uint16_t bitmap[], const uint8_t mask[], int16_t w, int16_t h)
 
void drawRGBBitmap (int16_t x, int16_t y, uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h)
 
void drawChar (int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
 
void drawChar (int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size_x, uint8_t size_y)
 
void getTextBounds (const char *string, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)
 
void getTextBounds (const __FlashStringHelper *s, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)
 
void getTextBounds (const String &str, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)
 
void setTextSize (uint8_t s)
 
void setTextSize (uint8_t sx, uint8_t sy)
 
void setFont (const GFXfont *f=NULL)
 
void setCursor (int16_t x, int16_t y)
 Set text cursor location.
 
void setTextColor (uint16_t c)
 Set text font color with transparant background.
 
void setTextColor (uint16_t c, uint16_t bg)
 Set text font color with custom background color.
 
void setTextWrap (bool w)
 Set whether text that is too long for the screen width should automatically wrap around to the next line (else clip right).
 
void cp437 (bool x=true)
 Enable (or disable) Code Page 437-compatible charset. There was an error in glcdfont.c for the longest time – one character (#176, the 'light shade' block) was missing – this threw off the index of every character that followed it. But a TON of code has been written with the erroneous character indices. By default, the library uses the original 'wrong' behavior and old sketches will still work. Pass 'true' to this function to use correct CP437 character values in your code.
 
virtual void write (uint8_t)
 
int16_t width (void) const
 Get width of the display, accounting for current rotation.
 
int16_t height (void) const
 Get height of the display, accounting for current rotation.
 
uint8_t getRotation (void) const
 Get rotation setting for display.
 
int16_t getCursorX (void) const
 Get text cursor X location.
 
int16_t getCursorY (void) const
 Get text cursor Y location.
 
size_t write (const char *str)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 
size_t write (const char *buffer, size_t size)
 
- Public Member Functions inherited from Print
int getWriteError ()
 
void clearWriteError ()
 
size_t write (const char *str)
 
size_t write (const char *buffer, size_t size)
 
virtual int availableForWrite ()
 
size_t print (const __FlashStringHelper *)
 
size_t print (const String &)
 
size_t print (const char[])
 
size_t print (char)
 
size_t print (unsigned char, int=DEC)
 
size_t print (int, int=DEC)
 
size_t print (unsigned int, int=DEC)
 
size_t print (long, int=DEC)
 
size_t print (unsigned long, int=DEC)
 
size_t print (long long, int=DEC)
 
size_t print (unsigned long long, int=DEC)
 
size_t print (float, int=2)
 
size_t print (double, int=2)
 
size_t print (const Printable &)
 
size_t println (const __FlashStringHelper *)
 
size_t println (const String &s)
 
size_t println (const char[])
 
size_t println (char)
 
size_t println (unsigned char, int=DEC)
 
size_t println (int, int=DEC)
 
size_t println (unsigned int, int=DEC)
 
size_t println (long, int=DEC)
 
size_t println (unsigned long, int=DEC)
 
size_t println (long long, int=DEC)
 
size_t println (unsigned long long, int=DEC)
 
size_t println (float, int=2)
 
size_t println (double, int=2)
 
size_t println (const Printable &)
 
size_t println (void)
 
int printf (const char *format,...)
 
int printf (const __FlashStringHelper *format,...)
 
int vprintf (const __FlashStringHelper *format, va_list ap)
 
int vprintf (const char *format, va_list ap)
 
virtual void flush ()
 

Protected Member Functions

void charBounds (unsigned char c, int16_t *x, int16_t *y, int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy)
 
- Protected Member Functions inherited from Print
void setWriteError (int err=1)
 

Protected Attributes

int16_t WIDTH
 This is the 'raw' display width - never changes.
 
int16_t HEIGHT
 This is the 'raw' display height - never changes.
 
int16_t _width
 Display width as modified by current rotation.
 
int16_t _height
 Display height as modified by current rotation.
 
int16_t cursor_x
 x location to start print()ing text
 
int16_t cursor_y
 y location to start print()ing text
 
uint16_t textcolor
 16-bit background color for print()
 
uint16_t textbgcolor
 16-bit text color for print()
 
uint8_t textsize_x
 Desired magnification in X-axis of text to print()
 
uint8_t textsize_y
 Desired magnification in Y-axis of text to print()
 
uint8_t rotation
 Display rotation (0 thru 3)
 
bool wrap
 If set, 'wrap' text at right edge of display.
 
bool _cp437
 If set, use correct CP437 charset (default is off)
 
GFXfontgfxFont
 Pointer to special font.
 

Detailed Description

A generic graphics superclass that can handle all sorts of drawing. At a minimum you can subclass and provide drawPixel(). At a maximum you can do a ton of overriding to optimize. Used for any/all Adafruit displays!

Member Function Documentation

◆ cp437()

void Adafruit_GFX::cp437 ( bool x = true)
inline

Enable (or disable) Code Page 437-compatible charset. There was an error in glcdfont.c for the longest time – one character (#176, the 'light shade' block) was missing – this threw off the index of every character that followed it. But a TON of code has been written with the erroneous character indices. By default, the library uses the original 'wrong' behavior and old sketches will still work. Pass 'true' to this function to use correct CP437 character values in your code.

Parameters
xtrue = enable (new behavior), false = disable (old behavior)

◆ drawPixel()

virtual void Adafruit_GFX::drawPixel ( int16_t x,
int16_t y,
uint16_t color )
pure virtual

Draw to the screen/framebuffer/etc. Must be overridden in subclass.

Parameters
xX coordinate in pixels
yY coordinate in pixels
color16-bit pixel color.

Implemented in Adafruit_GrayOLED, Adafruit_SPITFT, GFXcanvas16, GFXcanvas1, and GFXcanvas8.

◆ getCursorX()

int16_t Adafruit_GFX::getCursorX ( void ) const
inline

Get text cursor X location.

Returns
X coordinate in pixels

◆ getCursorY()

int16_t Adafruit_GFX::getCursorY ( void ) const
inline

Get text cursor Y location.

Returns
Y coordinate in pixels

◆ getRotation()

uint8_t Adafruit_GFX::getRotation ( void ) const
inline

Get rotation setting for display.

Returns
0 thru 3 corresponding to 4 cardinal rotations

◆ height()

int16_t Adafruit_GFX::height ( void ) const
inline

Get height of the display, accounting for current rotation.

Returns
Height in pixels

◆ setCursor()

void Adafruit_GFX::setCursor ( int16_t x,
int16_t y )
inline

Set text cursor location.

Parameters
xX coordinate in pixels
yY coordinate in pixels

◆ setTextColor() [1/2]

void Adafruit_GFX::setTextColor ( uint16_t c)
inline

Set text font color with transparant background.

Parameters
c16-bit 5-6-5 Color to draw text with
Note
For 'transparent' background, background and foreground are set to same color rather than using a separate flag.

◆ setTextColor() [2/2]

void Adafruit_GFX::setTextColor ( uint16_t c,
uint16_t bg )
inline

Set text font color with custom background color.

Parameters
c16-bit 5-6-5 Color to draw text with
bg16-bit 5-6-5 Color to draw background/fill with

◆ setTextWrap()

void Adafruit_GFX::setTextWrap ( bool w)
inline

Set whether text that is too long for the screen width should automatically wrap around to the next line (else clip right).

Parameters
wtrue for wrapping, false for clipping

◆ width()

int16_t Adafruit_GFX::width ( void ) const
inline

Get width of the display, accounting for current rotation.

Returns
Width in pixels

◆ write() [1/2]

virtual size_t Print::write ( const uint8_t * buffer,
size_t size )
virtual

Reimplemented from Print.

◆ write() [2/2]

virtual void Adafruit_GFX::write ( uint8_t )
virtual

Implements Print.


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