Adafruit GFX Library
Adafruit_GFX.h
1 #ifndef _ADAFRUIT_GFX_H
2 #define _ADAFRUIT_GFX_H
3 
4 #if ARDUINO >= 100
5 #include "Arduino.h"
6 #include "Print.h"
7 #else
8 #include "WProgram.h"
9 #endif
10 #include "gfxfont.h"
11 
12 #include <Adafruit_I2CDevice.h>
13 #include <Adafruit_SPIDevice.h>
14 
18 class Adafruit_GFX : public Print {
19 
20 public:
21  Adafruit_GFX(int16_t w, int16_t h); // Constructor
22 #if !defined(__AVR__)
23  // Virtual so deleting a canvas or display through an Adafruit_GFX pointer
24  // frees it. Skipped on AVR, where it links malloc/free into every sketch.
25  virtual ~Adafruit_GFX() {}
26 #endif
27 
28  /**********************************************************************/
36  /**********************************************************************/
37  virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
38 
39  // TRANSACTION API / CORE DRAW API
40  // These MAY be overridden by the subclass to provide device-specific
41  // optimized code. Otherwise 'generic' versions are used.
42  virtual void startWrite(void);
43  virtual void writePixel(int16_t x, int16_t y, uint16_t color);
44  virtual void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h,
45  uint16_t color);
46  virtual void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
47  virtual void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
48  virtual void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
49  uint16_t color);
50  virtual void endWrite(void);
51  virtual void clearDisplay(void);
52  virtual void display(void);
53 
54  // CONTROL API
55  // These MAY be overridden by the subclass to provide device-specific
56  // optimized code. Otherwise 'generic' versions are used.
57  virtual void setRotation(uint8_t r);
58  virtual void invertDisplay(bool i);
59 
60  // BASIC DRAW API
61  // These MAY be overridden by the subclass to provide device-specific
62  // optimized code. Otherwise 'generic' versions are used.
63 
64  // It's good to implement those, even if using transaction API
65  virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
66  virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
67  virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
68  uint16_t color);
69  virtual void fillScreen(uint16_t color);
70  // Optional and probably not necessary to change
71  virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
72  uint16_t color);
73  virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h,
74  uint16_t color);
75 
76  // These exist only with Adafruit_GFX (no subclass overrides)
77  void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
78  void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
79  uint16_t color);
80  void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
81  void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
82  int16_t delta, uint16_t color);
83  void fillQuarterCircle(int16_t x0, int16_t y0, int16_t r, uint8_t corners,
84  uint16_t color);
85  void drawEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh,
86  uint16_t color);
87  void fillEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh,
88  uint16_t color);
89  void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2,
90  int16_t y2, uint16_t color);
91  void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2,
92  int16_t y2, uint16_t color);
93  void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
94  int16_t radius, uint16_t color);
95  void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
96  int16_t radius, uint16_t color);
97  void drawRotatedRect(int16_t cenX, int16_t cenY, int16_t w, int16_t h,
98  int16_t angleDeg, uint16_t color);
99  void fillRotatedRect(int16_t cenX, int16_t cenY, int16_t w, int16_t h,
100  int16_t angleDeg, uint16_t color);
101  void rotatePoint(int16_t &x0, int16_t &y0, int16_t angleDeg);
102  void drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w,
103  int16_t h, uint16_t color);
104  void drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w,
105  int16_t h, uint16_t color, uint16_t bg);
106  void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h,
107  uint16_t color);
108  void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h,
109  uint16_t color, uint16_t bg);
110  void drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w,
111  int16_t h, uint16_t color);
112  void drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w,
113  int16_t h, uint16_t color, uint16_t bg);
114  void drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
115  int16_t w, int16_t h);
116  void drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w,
117  int16_t h);
118  void drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
119  const uint8_t mask[], int16_t w, int16_t h);
120  void drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap, uint8_t *mask,
121  int16_t w, int16_t h);
122  void drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[], int16_t w,
123  int16_t h);
124  void drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w,
125  int16_t h);
126  void drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[],
127  const uint8_t mask[], int16_t w, int16_t h);
128  void drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, uint8_t *mask,
129  int16_t w, int16_t h);
130  void drawChar(int16_t x, int16_t y, uint16_t c, uint16_t color, uint16_t bg,
131  uint8_t size);
132  void drawChar(int16_t x, int16_t y, uint16_t c, uint16_t color, uint16_t bg,
133  uint8_t size_x, uint8_t size_y);
134  void getTextBounds(const char *string, int16_t x, int16_t y, int16_t *x1,
135  int16_t *y1, uint16_t *w, uint16_t *h, int16_t *xF = NULL,
136  int16_t *yF = NULL);
137  void getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
138  int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h,
139  int16_t *xF = NULL, int16_t *yF = NULL);
140  void getTextBounds(const String &str, int16_t x, int16_t y, int16_t *x1,
141  int16_t *y1, uint16_t *w, uint16_t *h, int16_t *xF = NULL,
142  int16_t *yF = NULL);
143  void setTextSize(uint8_t s);
144  void setTextSize(uint8_t sx, uint8_t sy);
145  void setFont(const GFXfont *f = NULL);
146 
147  // Serial UTF-8 decoder
148  uint16_t decodeUTF8(uint8_t c);
149 
150  /**********************************************************************/
155  /**********************************************************************/
156  GFXfont *getFont() const { return gfxFont; }
157 
158  /**********************************************************************/
163  /**********************************************************************/
164  uint8_t getTextSizeX() const { return textsize_x; }
165 
166  /**********************************************************************/
171  /**********************************************************************/
172  uint8_t getTextSizeY() const { return textsize_y; }
173 
174  /**********************************************************************/
180  /**********************************************************************/
181  void setCursor(int16_t x, int16_t y) {
182  cursor_x = x;
183  cursor_y = y;
184  }
185 
186  /**********************************************************************/
191  /**********************************************************************/
192  void setCursorX(int16_t x) { cursor_x = x; }
193 
194  /**********************************************************************/
199  /**********************************************************************/
200  void setCursorY(int16_t y) { cursor_y = y; }
201 
202  /**********************************************************************/
209  /**********************************************************************/
210  void setTextColor(uint16_t c) { textcolor = textbgcolor = c; }
211 
212  /**********************************************************************/
218  /**********************************************************************/
219  void setTextColor(uint16_t c, uint16_t bg) {
220  textcolor = c;
221  textbgcolor = bg;
222  }
223 
224  /**********************************************************************/
229  /**********************************************************************/
230  uint16_t getTextColor() const { return textcolor; }
231 
232  /**********************************************************************/
237  /**********************************************************************/
238  uint16_t getTextBgColor() const { return textbgcolor; }
239 
240  /**********************************************************************/
246  /**********************************************************************/
247  void setTextWrap(bool w) { wrap = w; }
248 
249  /**********************************************************************/
262  /**********************************************************************/
263  void cp437(bool x = true) { _cp437 = x; }
264 
265  /**********************************************************************/
275  /**********************************************************************/
276  void utf8(bool x = true) { _utf8 = x; }
277 
278  using Print::write;
279 #if ARDUINO >= 100
280  virtual size_t write(uint8_t);
281 #else
282  virtual void write(uint8_t);
283 #endif
284 
285  /************************************************************************/
290  /************************************************************************/
291  int16_t width(void) const { return _width; };
292 
293  /************************************************************************/
298  /************************************************************************/
299  int16_t height(void) const { return _height; }
300 
301  /************************************************************************/
306  /************************************************************************/
307  uint8_t getRotation(void) const { return rotation; }
308 
309  /************************************************************************/
316  /************************************************************************/
317  [[gnu::always_inline]] void applyRotation(int16_t *x, int16_t *y) const {
318  int16_t t;
319  switch (rotation) {
320  case 1:
321  t = *x;
322  *x = WIDTH - 1 - *y;
323  *y = t;
324  break;
325  case 2:
326  *x = WIDTH - 1 - *x;
327  *y = HEIGHT - 1 - *y;
328  break;
329  case 3:
330  t = *x;
331  *x = *y;
332  *y = HEIGHT - 1 - t;
333  break;
334  }
335  }
336 
337  /************************************************************************/
345  /************************************************************************/
346  void undoRotation(int16_t *x, int16_t *y) const {
347  int16_t t;
348  switch (rotation) {
349  case 1:
350  t = *x;
351  *x = *y;
352  *y = WIDTH - 1 - t;
353  break;
354  case 2:
355  *x = WIDTH - 1 - *x;
356  *y = HEIGHT - 1 - *y;
357  break;
358  case 3:
359  t = *x;
360  *x = HEIGHT - 1 - *y;
361  *y = t;
362  break;
363  }
364  }
365 
366  // get current cursor position (get rotation safe maximum values,
367  // using: width() for x, height() for y)
368  /************************************************************************/
373  /************************************************************************/
374  int16_t getCursorX(void) const { return cursor_x; }
375 
376  /************************************************************************/
381  /************************************************************************/
382  int16_t getCursorY(void) const { return cursor_y; };
383 
384 protected:
385  void charBounds(uint16_t c, int16_t *x, int16_t *y, int16_t *minx,
386  int16_t *miny, int16_t *maxx, int16_t *maxy);
387  int16_t WIDTH;
388  int16_t HEIGHT;
389  int16_t _width;
390  int16_t _height;
391  int16_t cursor_x;
392  int16_t cursor_y;
393  uint16_t textcolor;
394  uint16_t textbgcolor;
395  uint8_t textsize_x;
396  uint8_t textsize_y;
397  uint8_t rotation;
398  bool wrap;
399  bool _cp437;
400  bool _utf8;
402 
403  uint8_t decoderState = 0;
404  uint32_t decoderBuffer = 0;
405 };
406 
409 
410 public:
411  Adafruit_GFX_Button(void);
412  // "Classic" initButton() uses center & size
413  void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y, uint16_t w,
414  uint16_t h, uint16_t outline, uint16_t fill,
415  uint16_t textcolor, const char *label, uint8_t textsize);
416  void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y, uint16_t w,
417  uint16_t h, uint16_t outline, uint16_t fill,
418  uint16_t textcolor, const char *label, uint8_t textsize_x,
419  uint8_t textsize_y);
420  // New/alt initButton() uses upper-left corner & size
421  void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1, uint16_t w,
422  uint16_t h, uint16_t outline, uint16_t fill,
423  uint16_t textcolor, const char *label, uint8_t textsize);
424  void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1, uint16_t w,
425  uint16_t h, uint16_t outline, uint16_t fill,
426  uint16_t textcolor, const char *label, uint8_t textsize_x,
427  uint8_t textsize_y);
428  void drawButton(bool inverted = false);
429  bool contains(int16_t x, int16_t y);
430 
431  /**********************************************************************/
436  /**********************************************************************/
437  void press(bool p) {
438  laststate = currstate;
439  currstate = p;
440  }
441 
442  bool justPressed();
443  bool justReleased();
444 
445  /**********************************************************************/
450  /**********************************************************************/
451  bool isPressed(void) { return currstate; };
452 
453  /**********************************************************************/
458  /**********************************************************************/
459  const char *getLabel(void) const { return _label; };
460 
461  void setLabel(const char *label);
462 
463 private:
464  Adafruit_GFX *_gfx;
465  int16_t _x1, _y1; // Coordinates of top-left corner
466  uint16_t _w, _h;
467  uint8_t _textsize_x;
468  uint8_t _textsize_y;
469  uint16_t _outlinecolor, _fillcolor, _textcolor;
470  char _label[10];
471 
472  bool currstate, laststate;
473 };
474 
476 class GFXcanvas1 : public Adafruit_GFX {
477 public:
478  GFXcanvas1(uint16_t w, uint16_t h, bool allocate_buffer = true);
479  ~GFXcanvas1(void);
480  void drawPixel(int16_t x, int16_t y, uint16_t color);
481  void fillScreen(uint16_t color);
482  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
483  void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
484  bool getPixel(int16_t x, int16_t y) const;
485  /**********************************************************************/
490  /**********************************************************************/
491  uint8_t *getBuffer(void) const { return buffer; }
492 
493 protected:
494  bool getRawPixel(int16_t x, int16_t y) const;
495  void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
496  void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
497  uint8_t *buffer;
499 
501 private:
502  // No copies: the copy and the original would both free the buffer
503  GFXcanvas1(const GFXcanvas1 &) = delete;
504  GFXcanvas1 &operator=(const GFXcanvas1 &) = delete;
505 #ifdef __AVR__
506  // Bitmask tables of 0x80>>X and ~(0x80>>X), because X>>Y is slow on AVR
507  static const uint8_t PROGMEM GFXsetBit[], GFXclrBit[];
508 #endif
509 };
510 
512 class GFXcanvas8 : public Adafruit_GFX {
513 public:
514  GFXcanvas8(uint16_t w, uint16_t h, bool allocate_buffer = true);
515  ~GFXcanvas8(void);
516  void drawPixel(int16_t x, int16_t y, uint16_t color);
517  void fillScreen(uint16_t color);
518  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
519  void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
520  uint8_t getPixel(int16_t x, int16_t y) const;
521  /**********************************************************************/
526  /**********************************************************************/
527  uint8_t *getBuffer(void) const { return buffer; }
528 
529 protected:
530  uint8_t getRawPixel(int16_t x, int16_t y) const;
531  void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
532  void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
533  uint8_t *buffer;
535 
537 private:
538  // No copies: the copy and the original would both free the buffer
539  GFXcanvas8(const GFXcanvas8 &) = delete;
540  GFXcanvas8 &operator=(const GFXcanvas8 &) = delete;
541 };
542 
544 class GFXcanvas16 : public Adafruit_GFX {
545 public:
546  GFXcanvas16(uint16_t w, uint16_t h, bool allocate_buffer = true);
547  ~GFXcanvas16(void);
548  void drawPixel(int16_t x, int16_t y, uint16_t color);
549  void fillScreen(uint16_t color);
550  void byteSwap(void);
551  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
552  void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
553  uint16_t getPixel(int16_t x, int16_t y) const;
554  /**********************************************************************/
559  /**********************************************************************/
560  uint16_t *getBuffer(void) const { return buffer; }
561 
562 protected:
563  uint16_t getRawPixel(int16_t x, int16_t y) const;
564  void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
565  void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
566  uint16_t *buffer;
568 
570 private:
571  // No copies: the copy and the original would both free the buffer
572  GFXcanvas16(const GFXcanvas16 &) = delete;
573  GFXcanvas16 &operator=(const GFXcanvas16 &) = delete;
574 };
575 
576 #endif // _ADAFRUIT_GFX_H
uint8_t * getBuffer(void) const
Get a pointer to the internal buffer memory.
Definition: Adafruit_GFX.h:527
void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)
Half-circle drawer with fill, used for circles and roundrects.
Definition: Adafruit_GFX.cpp:604
void charBounds(uint16_t 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&#39;s used by both t...
Definition: Adafruit_GFX.cpp:1824
bool isPressed(void)
Query whether the button is currently pressed.
Definition: Adafruit_GFX.h:451
virtual void writePixel(int16_t x, int16_t y, uint16_t color)
Write a pixel, overwrite in subclasses if startWrite is defined!
Definition: Adafruit_GFX.cpp:205
void setTextColor(uint16_t c, uint16_t bg)
Set text font color with custom background color.
Definition: Adafruit_GFX.h:219
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 *...
Definition: Adafruit_GFX.cpp:1194
void drawChar(int16_t x, int16_t y, uint16_t c, uint16_t color, uint16_t bg, uint8_t size)
Draw a single character.
Definition: Adafruit_GFX.cpp:1497
Data stored for FONT AS A WHOLE.
Definition: gfxfont.h:21
void setTextWrap(bool w)
Set whether text that is too long for the screen width should automatically wrap around to the next l...
Definition: Adafruit_GFX.h:247
Definition: Adafruit_GFX.h:18
bool buffer_owned
Definition: Adafruit_GFX.h:498
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draw a circle with filled color.
Definition: Adafruit_GFX.cpp:584
uint8_t * getBuffer(void) const
Get a pointer to the internal buffer memory.
Definition: Adafruit_GFX.h:491
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
Draw to the screen/framebuffer/etc. Must be overridden in subclass.
void setCursorX(int16_t x)
Set text cursor X location, leaving Y as is.
Definition: Adafruit_GFX.h:192
void fillRotatedRect(int16_t cenX, int16_t cenY, int16_t w, int16_t h, int16_t angleDeg, uint16_t color)
Draw a filled rotated rectangle.
Definition: Adafruit_GFX.cpp:867
virtual void endWrite(void)
End a display-writing routine, overwrite in subclasses if startWrite is defined!
Definition: Adafruit_GFX.cpp:268
uint16_t getTextColor() const
Get text color.
Definition: Adafruit_GFX.h:230
uint8_t * buffer
Raster data: no longer private, allow subclass access.
Definition: Adafruit_GFX.h:497
void fillEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh, uint16_t color)
Draw an ellipse with filled colour.
Definition: Adafruit_GFX.cpp:432
bool _utf8
If set, use correct UTF-8 charset (default is off)
Definition: Adafruit_GFX.h:400
int16_t getCursorX(void) const
Get text cursor X location.
Definition: Adafruit_GFX.h:374
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! ...
Definition: Adafruit_GFX.cpp:256
int16_t cursor_y
y location to start print()ing text
Definition: Adafruit_GFX.h:392
uint8_t decoderState
UTF-8 decoder state.
Definition: Adafruit_GFX.h:403
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.
Definition: Adafruit_GFX.cpp:943
void fillQuarterCircle(int16_t x0, int16_t y0, int16_t r, uint8_t corners, uint16_t color)
Quarter-circle drawer with fill.
Definition: Adafruit_GFX.cpp:660
GFXfont * gfxFont
Pointer to special font.
Definition: Adafruit_GFX.h:401
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.
Definition: Adafruit_GFX.cpp:746
A GFX 1-bit canvas context for graphics.
Definition: Adafruit_GFX.h:476
void setFont(const GFXfont *f=NULL)
Set the font to display when print()ing, either custom or default.
Definition: Adafruit_GFX.cpp:1791
uint8_t textsize_x
Desired magnification in X-axis of text to print()
Definition: Adafruit_GFX.h:395
uint16_t getTextBgColor() const
Get text background color.
Definition: Adafruit_GFX.h:238
uint8_t * buffer
Raster data: no longer private, allow subclass access.
Definition: Adafruit_GFX.h:533
A GFX 16-bit canvas context for graphics.
Definition: Adafruit_GFX.h:544
virtual void invertDisplay(bool i)
Invert the display (ideally using built-in hardware command)
Definition: Adafruit_GFX.cpp:2102
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.
Definition: Adafruit_GFX.cpp:537
void press(bool p)
Sets button state, should be done by some touch function.
Definition: Adafruit_GFX.h:437
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 ...
Definition: Adafruit_GFX.cpp:1382
bool _cp437
If set, use correct CP437 charset (default is off)
Definition: Adafruit_GFX.h:399
A GFX 8-bit canvas context for graphics.
Definition: Adafruit_GFX.h:512
void setTextColor(uint16_t c)
Set text font color with transparant background.
Definition: Adafruit_GFX.h:210
uint32_t decoderBuffer
Code point being decoded.
Definition: Adafruit_GFX.h:404
virtual void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Write a line. Bresenham&#39;s algorithm - thx Wikipedia.
Definition: Adafruit_GFX.cpp:133
void setCursorY(int16_t y)
Set text cursor Y location, leaving X as is.
Definition: Adafruit_GFX.h:200
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!
Definition: Adafruit_GFX.cpp:315
void applyRotation(int16_t *x, int16_t *y) const
Convert rotated (drawing) coordinates to physical, unrotated display coordinates for the current rota...
Definition: Adafruit_GFX.h:317
int16_t height(void) const
Get height of the display, accounting for current rotation.
Definition: Adafruit_GFX.h:299
void getTextBounds(const char *string, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h, int16_t *xF=NULL, int16_t *yF=NULL)
Helper to determine size of a string with current font/size. Pass string and a cursor position...
Definition: Adafruit_GFX.cpp:1962
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 &#39;light shade&#39; 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 &#39;wrong&#39; behavior and old sketches will still work. Pass &#39;true&#39; to this function to use correct CP437 character values in your code.
Definition: Adafruit_GFX.h:263
virtual void setRotation(uint8_t r)
Set rotation setting for display.
Definition: Adafruit_GFX.cpp:1769
void drawRotatedRect(int16_t cenX, int16_t cenY, int16_t w, int16_t h, int16_t angleDeg, uint16_t color)
Draw a rotated rectangle.
Definition: Adafruit_GFX.cpp:807
bool buffer_owned
Definition: Adafruit_GFX.h:534
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...
Definition: Adafruit_GFX.cpp:1266
void utf8(bool x=true)
Turn UTF-8 decoding of printed text on or off. Off by default. Code points up to U+FFFF (the Basic Mu...
Definition: Adafruit_GFX.h:276
bool buffer_owned
Definition: Adafruit_GFX.h:567
uint8_t getRotation(void) const
Get rotation setting for display.
Definition: Adafruit_GFX.h:307
void setTextSize(uint8_t s)
Set text &#39;magnification&#39; size. Each increase in s makes 1 pixel that much bigger. ...
Definition: Adafruit_GFX.cpp:1748
uint16_t textbgcolor
16-bit background color for print()
Definition: Adafruit_GFX.h:394
Adafruit_GFX(int16_t w, int16_t h)
Instantiate a GFX context for graphics! Can only be done by a superclass.
Definition: Adafruit_GFX.cpp:110
int16_t cursor_x
x location to start print()ing text
Definition: Adafruit_GFX.h:391
uint8_t textsize_y
Desired magnification in Y-axis of text to print()
Definition: Adafruit_GFX.h:396
GFXfont * getFont() const
Get GFX font.
Definition: Adafruit_GFX.h:156
int16_t _height
Display height as modified by current rotation.
Definition: Adafruit_GFX.h:390
void rotatePoint(int16_t &x0, int16_t &y0, int16_t angleDeg)
Rotate a point in standard position.
Definition: Adafruit_GFX.cpp:918
int16_t _width
Display width as modified by current rotation.
Definition: Adafruit_GFX.h:389
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.
Definition: Adafruit_GFX.cpp:776
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!)
Definition: Adafruit_GFX.cpp:297
int16_t getCursorY(void) const
Get text cursor Y location.
Definition: Adafruit_GFX.h:382
uint8_t rotation
Display rotation (0 thru 3)
Definition: Adafruit_GFX.h:397
virtual void display(void)
Update the display, overwrite in subclasses.
Definition: Adafruit_GFX.cpp:188
void setCursor(int16_t x, int16_t y)
Set text cursor location.
Definition: Adafruit_GFX.h:181
uint16_t * buffer
Raster data: no longer private, allow subclass access.
Definition: Adafruit_GFX.h:566
uint8_t getTextSizeX() const
Get text size multiplier x.
Definition: Adafruit_GFX.h:164
uint16_t decodeUTF8(uint8_t c)
Decode UTF-8 one byte at a time.
Definition: Adafruit_GFX.cpp:1653
void drawEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh, uint16_t color)
Draw an ellipse outline.
Definition: Adafruit_GFX.cpp:373
uint16_t textcolor
16-bit text color for print()
Definition: Adafruit_GFX.h:393
virtual void clearDisplay(void)
Clear the display, overwrite in subclasses.
Definition: Adafruit_GFX.cpp:181
bool wrap
If set, &#39;wrap&#39; text at right edge of display.
Definition: Adafruit_GFX.h:398
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.
Definition: Adafruit_GFX.cpp:962
uint16_t * getBuffer(void) const
Get a pointer to the internal buffer memory.
Definition: Adafruit_GFX.h:560
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!)
Definition: Adafruit_GFX.cpp:280
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Draw a line.
Definition: Adafruit_GFX.cpp:345
virtual void startWrite(void)
Start a display-writing routine, overwrite in subclasses.
Definition: Adafruit_GFX.cpp:195
const char * getLabel(void) const
Get the label text.
Definition: Adafruit_GFX.h:459
int16_t HEIGHT
This is the &#39;raw&#39; display height - never changes.
Definition: Adafruit_GFX.h:388
void undoRotation(int16_t *x, int16_t *y) const
Convert physical, unrotated display coordinates (such as a raw touch point) to rotated (drawing) coor...
Definition: Adafruit_GFX.h:346
void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draw a circle outline.
Definition: Adafruit_GFX.cpp:487
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! ...
Definition: Adafruit_GFX.cpp:237
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...
Definition: Adafruit_GFX.cpp:1060
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! ...
Definition: Adafruit_GFX.cpp:219
A simple drawn button UI element.
Definition: Adafruit_GFX.h:408
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.
Definition: Adafruit_GFX.cpp:725
virtual void write(uint8_t)
Print one byte/character of data, used to support print()
Definition: Adafruit_GFX.cpp:1687
virtual void fillScreen(uint16_t color)
Fill the screen completely with one color. Update in subclasses if desired!
Definition: Adafruit_GFX.cpp:331
uint8_t getTextSizeY() const
Get text size multiplier y.
Definition: Adafruit_GFX.h:172
int16_t WIDTH
This is the &#39;raw&#39; display width - never changes.
Definition: Adafruit_GFX.h:387
int16_t width(void) const
Get width of the display, accounting for current rotation.
Definition: Adafruit_GFX.h:291