30#ifndef _ADAFRUIT_GFX_H
31#define _ADAFRUIT_GFX_H
65 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
71 virtual void writePixel(int16_t x, int16_t y, uint16_t color);
72 virtual void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
73 virtual void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
74 virtual void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
75 virtual void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
89 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
90 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
91 virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
94 virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
95 virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
98 void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
99 void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color);
100 void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
102 int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color);
104 int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
106 int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
108 int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
110 int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
112 int16_t x, int16_t y,
const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color);
114 int16_t x, int16_t y,
const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color,
116 void drawBitmap(int16_t x, int16_t y, uint8_t* bitmap, int16_t w, int16_t h, uint16_t color);
118 int16_t x, int16_t y, uint8_t* bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg);
120 int16_t x, int16_t y,
const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color);
121 void drawGrayscaleBitmap(int16_t x, int16_t y,
const uint8_t bitmap[], int16_t w, int16_t h);
124 int16_t x, int16_t y,
const uint8_t bitmap[],
const uint8_t mask[], int16_t w, int16_t h);
126 int16_t x, int16_t y, uint8_t* bitmap, uint8_t* mask, int16_t w, int16_t h);
127 void drawRGBBitmap(int16_t x, int16_t y,
const uint16_t bitmap[], int16_t w, int16_t h);
128 void drawRGBBitmap(int16_t x, int16_t y, uint16_t* bitmap, int16_t w, int16_t h);
130 int16_t x, int16_t y,
const uint16_t bitmap[],
const uint8_t mask[], int16_t w, int16_t h);
131 void drawRGBBitmap(int16_t x, int16_t y, uint16_t* bitmap, uint8_t* mask, int16_t w, int16_t h);
132 void drawChar(int16_t x, int16_t y,
unsigned char c, uint16_t color, uint16_t bg, uint8_t size);
134 int16_t x, int16_t y,
unsigned char c, uint16_t color, uint16_t bg, uint8_t size_x,
137 const char*
string, int16_t x, int16_t y, int16_t* x1, int16_t* y1, uint16_t* w,
140 const __FlashStringHelper* s, int16_t x, int16_t y, int16_t* x1, int16_t* y1, uint16_t* w,
143 const String& str, int16_t x, int16_t y, int16_t* x1, int16_t* y1, uint16_t* w,
212 virtual size_t write(uint8_t);
214 virtual void write(uint8_t);
261 unsigned char c, int16_t* x, int16_t* y, int16_t* minx, int16_t* miny, int16_t* maxx,
287 Adafruit_GFX* gfx, int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t outline,
288 uint16_t fill, uint16_t textcolor,
char* label, uint8_t textsize);
290 Adafruit_GFX* gfx, int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t outline,
291 uint16_t fill, uint16_t textcolor,
char* label, uint8_t textsize_x, uint8_t textsize_y);
294 Adafruit_GFX* gfx, int16_t x1, int16_t y1, uint16_t w, uint16_t h, uint16_t outline,
295 uint16_t fill, uint16_t textcolor,
char* label, uint8_t textsize);
297 Adafruit_GFX* gfx, int16_t x1, int16_t y1, uint16_t w, uint16_t h, uint16_t outline,
298 uint16_t fill, uint16_t textcolor,
char* label, uint8_t textsize_x, uint8_t textsize_y);
300 bool contains(int16_t x, int16_t y);
310 laststate = currstate;
331 uint16_t _outlinecolor, _fillcolor, _textcolor;
334 bool currstate, laststate;
343 void drawPixel(int16_t x, int16_t y, uint16_t color);
345 void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
346 void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
347 bool getPixel(int16_t x, int16_t y)
const;
365 static const uint8_t
PROGMEM GFXsetBit[], GFXclrBit[];
375 void drawPixel(int16_t x, int16_t y, uint16_t color);
377 void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
378 void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
379 uint8_t
getPixel(int16_t x, int16_t y)
const;
401 void drawPixel(int16_t x, int16_t y, uint16_t color);
404 void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
405 void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
406 uint16_t
getPixel(int16_t x, int16_t y)
const;
Adafruit SSD1306 dependency code for I2C.
Adafruit SSD1306 dependency code.
A generic graphics superclass that can handle all sorts of drawing. At a.
int16_t getCursorX(void) const
Get text cursor X location.
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Draw a perfectly vertical line (this is often optimized in a subclass!)
void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)
Quarter-circle drawer with fill, used for circles and roundrects.
uint16_t textbgcolor
16-bit text color for print()
virtual void fillScreen(uint16_t color)
Fill the screen completely with one color. Update in subclasses if desired!
int16_t HEIGHT
This is the 'raw' display height - never changes.
void setTextWrap(bool w)
Set whether text that is too long for the screen width should automatically wrap around to the next l...
int16_t width(void) const
Get width of the display, accounting for current rotation.
uint8_t rotation
Display rotation (0 thru 3)
void setTextSize(uint8_t s)
Set text 'magnification' size. Each increase in s makes 1 pixel that much bigger.
void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)
Quarter-circle drawer, used to do circles and roundrects.
virtual void invertDisplay(bool i)
Invert the display (ideally using built-in hardware command)
void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
Draw a triangle with no fill color.
int16_t height(void) const
Get height of the display, accounting for current rotation.
void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
Draw a triangle with color-fill.
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Draw a perfectly horizontal line (this is often optimized in a subclass!)
void setTextColor(uint16_t c)
Set text font color with transparant background.
virtual void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Write a rectangle completely with one color, overwrite in subclasses if startWrite is defined!
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draw a circle with filled color.
void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draw a circle outline.
void charBounds(unsigned char c, int16_t *x, int16_t *y, int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy)
Helper to determine size of a character with current font/size. Broke this out as it's used by both t...
virtual void setRotation(uint8_t r)
Set rotation setting for display.
Adafruit_GFX(int16_t w, int16_t h)
Instatiate a GFX context for graphics! Can only be done by a superclass.
bool _cp437
If set, use correct CP437 charset (default is off)
void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
Draw a rounded rectangle with fill color.
void drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color)
Draw a PROGMEM-resident 1-bit image at the specified (x,y) position, using the specified foreground c...
int16_t getCursorY(void) const
Get text cursor Y location.
virtual void write(uint8_t)
Print one byte/character of data, used to support print()
bool wrap
If set, 'wrap' text at right edge of display.
uint16_t textcolor
16-bit background color for print()
int16_t cursor_x
x location to start print()ing text
void getTextBounds(const char *string, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)
Helper to determine size of a string with current font/size. Pass string and a cursor position,...
uint8_t textsize_x
Desired magnification in X-axis of text to print()
virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Draw a rectangle with no fill color.
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Draw a line.
virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Fill a rectangle completely with one color. Update in subclasses if desired!
void drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color)
Draw PROGMEM-resident XBitMap Files (*.xbm), exported from GIMP. Usage: Export from GIMP to *....
uint8_t textsize_y
Desired magnification in Y-axis of text to print()
virtual void startWrite(void)
Start a display-writing routine, overwrite in subclasses.
void setCursor(int16_t x, int16_t y)
Set text cursor location.
void setFont(const GFXfont *f=NULL)
Set the font to display when print()ing, either custom or default.
int16_t _width
Display width as modified by current rotation.
void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
Draw a rounded rectangle with no fill color.
virtual void writePixel(int16_t x, int16_t y, uint16_t color)
Write a pixel, overwrite in subclasses if startWrite is defined!
void setTextColor(uint16_t c, uint16_t bg)
Set text font color with custom background color.
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
Draw a single character.
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
Draw to the screen/framebuffer/etc. Must be overridden in subclass.
uint8_t getRotation(void) const
Get rotation setting for display.
int16_t _height
Display height as modified by current rotation.
virtual void endWrite(void)
End a display-writing routine, overwrite in subclasses if startWrite is defined!
void cp437(bool x=true)
Enable (or disable) Code Page 437-compatible charset. There was an error in glcdfont....
virtual void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Write a perfectly horizontal line, overwrite in subclasses if startWrite is defined!
int16_t WIDTH
This is the 'raw' display width - never changes.
virtual void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Write a perfectly vertical line, overwrite in subclasses if startWrite is defined!
virtual void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Write a line. Bresenham's algorithm - thx wikpedia.
int16_t cursor_y
y location to start print()ing text
void drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h)
Draw a PROGMEM-resident 8-bit image (grayscale) at the specified (x,y) pos. Specifically for 8-bit di...
void drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[], int16_t w, int16_t h)
Draw a PROGMEM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position. For 16-bit display ...
GFXfont * gfxFont
Pointer to special font.
A GFX 16-bit canvas context for graphics.
GFXcanvas16(uint16_t w, uint16_t h)
Instatiate a GFX 16-bit canvas context for graphics.
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Speed optimized horizontal line drawing into the raw canvas buffer.
uint16_t * buffer
Raster data: no longer private, allow subclass access.
~GFXcanvas16(void)
Delete the canvas, free memory.
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Speed optimized vertical line drawing.
void byteSwap(void)
Reverses the "endian-ness" of each 16-bit pixel within the canvas; little-endian to big-endian,...
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Speed optimized vertical line drawing into the raw canvas buffer.
uint16_t * getBuffer(void) const
Get a pointer to the internal buffer memory.
uint16_t getPixel(int16_t x, int16_t y) const
Get the pixel color value at a given coordinate.
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Speed optimized horizontal line drawing.
void drawPixel(int16_t x, int16_t y, uint16_t color)
Draw a pixel to the canvas framebuffer.
void fillScreen(uint16_t color)
Fill the framebuffer completely with one color.
uint16_t getRawPixel(int16_t x, int16_t y) const
Get the pixel color value at a given, unrotated coordinate. This method is intended for hardware driv...
A GFX 1-bit canvas context for graphics.
void drawPixel(int16_t x, int16_t y, uint16_t color)
Draw a pixel to the canvas framebuffer.
GFXcanvas1(uint16_t w, uint16_t h)
Instatiate a GFX 1-bit canvas context for graphics.
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Speed optimized vertical line drawing.
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Speed optimized vertical line drawing into the raw canvas buffer.
bool getRawPixel(int16_t x, int16_t y) const
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Speed optimized horizontal line drawing into the raw canvas buffer.
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Speed optimized horizontal line drawing.
~GFXcanvas1(void)
Delete the canvas, free memory.
bool getPixel(int16_t x, int16_t y) const
void fillScreen(uint16_t color)
Fill the framebuffer completely with one color.
uint8_t * buffer
Raster data: no longer private, allow subclass access.
uint8_t * getBuffer(void) const
Get a pointer to the internal buffer memory.
A GFX 8-bit canvas context for graphics.
~GFXcanvas8(void)
Delete the canvas, free memory.
uint8_t getRawPixel(int16_t x, int16_t y) const
Get the pixel color value at a given, unrotated coordinate. This method is intended for hardware driv...
GFXcanvas8(uint16_t w, uint16_t h)
Instatiate a GFX 8-bit canvas context for graphics.
void drawPixel(int16_t x, int16_t y, uint16_t color)
Draw a pixel to the canvas framebuffer.
uint8_t getPixel(int16_t x, int16_t y) const
Get the pixel color value at a given coordinate.
uint8_t * getBuffer(void) const
Get a pointer to the internal buffer memory.
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Speed optimized horizontal line drawing into the raw canvas buffer.
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Speed optimized vertical line drawing.
void fillScreen(uint16_t color)
Fill the framebuffer completely with one color.
uint8_t * buffer
Raster data: no longer private, allow subclass access.
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Speed optimized vertical line drawing into the raw canvas buffer.
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Speed optimized horizontal line drawing.
Data stored for FONT AS A WHOLE.