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
Go to the documentation of this file.
1 /*
2  MIT License
3 
4  Copyright (c) 2016-2026, Alexey Dynda
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files (the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23 */
60 #pragma once
61 
62 #include "lcd_hal/io.h"
63 #include <stdint.h>
64 #include <stddef.h>
65 
71 #ifndef _GFXFONT_H_
72 #define _GFXFONT_H_
73 
78 typedef struct
79 {
80  uint16_t bitmapOffset;
81  uint8_t width;
82  uint8_t height;
83  uint8_t xAdvance;
84  int8_t xOffset;
85  int8_t yOffset;
86 } GFXglyph;
87 
89 typedef struct
90 {
91  uint8_t *bitmap;
93  uint16_t first;
94  uint16_t last;
95  uint8_t yAdvance;
96 } GFXfont;
97 #endif // _GFXFONT_H_
98 
107 template <class D> class GfxCompat
108 {
109 public:
115  explicit GfxCompat(D &display)
116  : m_d(display)
117  {
118  }
119 
121  int16_t width()
122  {
123  return (int16_t)m_d.width();
124  }
125 
127  int16_t height()
128  {
129  return (int16_t)m_d.height();
130  }
131 
133  void drawPixel(int16_t x, int16_t y, uint16_t color)
134  {
135  // On 1-bit panels putPixel always draws "on"; honor Adafruit's 0 == off
136  // by clearing instead. The BITS_PER_PIXEL check folds away at compile time.
137  if ( D::BITS_PER_PIXEL == 1 && color == 0 )
138  {
139  m_d.clearRect((lcdint_t)x, (lcdint_t)y, (lcdint_t)x, (lcdint_t)y);
140  return;
141  }
142  m_d.setColor(mapColor(color));
143  m_d.putPixel((lcdint_t)x, (lcdint_t)y);
144  }
145 
147  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
148  {
149  if ( h <= 0 )
150  return;
151  m_d.setColor(mapColor(color));
152  m_d.drawVLine((lcdint_t)x, (lcdint_t)y, (lcdint_t)(y + h - 1));
153  }
154 
156  void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
157  {
158  if ( w <= 0 )
159  return;
160  m_d.setColor(mapColor(color));
161  m_d.drawHLine((lcdint_t)x, (lcdint_t)y, (lcdint_t)(x + w - 1));
162  }
163 
165  void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
166  {
167  m_d.setColor(mapColor(color));
168  m_d.drawLine((lcdint_t)x0, (lcdint_t)y0, (lcdint_t)x1, (lcdint_t)y1);
169  }
170 
172  void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
173  {
174  if ( w <= 0 || h <= 0 )
175  return;
176  m_d.setColor(mapColor(color));
177  m_d.drawRect((lcdint_t)x, (lcdint_t)y, (lcdint_t)(x + w - 1), (lcdint_t)(y + h - 1));
178  }
179 
181  void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
182  {
183  if ( w <= 0 || h <= 0 )
184  return;
185  m_d.setColor(mapColor(color));
186  m_d.fillRect((lcdint_t)x, (lcdint_t)y, (lcdint_t)(x + w - 1), (lcdint_t)(y + h - 1));
187  }
188 
190  void fillScreen(uint16_t color)
191  {
192  m_d.setColor(mapColor(color));
193  m_d.fillRect(0, 0, (lcdint_t)(m_d.width() - 1), (lcdint_t)(m_d.height() - 1));
194  }
195 
197  void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
198  {
199  if ( r < 0 )
200  return;
201  m_d.setColor(mapColor(color));
202  m_d.drawCircle((lcdint_t)x0, (lcdint_t)y0, (lcdint_t)r);
203  }
204 
206  void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
207  {
208  if ( r < 0 )
209  return;
210  drawFastVLine(x0, y0 - r, 2 * r + 1, color);
211  fillCircleHelper(x0, y0, r, 3, 0, color);
212  }
213 
215  void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
216  {
217  drawLine(x0, y0, x1, y1, color);
218  drawLine(x1, y1, x2, y2, color);
219  drawLine(x2, y2, x0, y0, color);
220  }
221 
230  void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
231  {
232  int16_t minX = x0, maxX = x0;
233  if ( x1 < minX )
234  minX = x1;
235  if ( x2 < minX )
236  minX = x2;
237  if ( x1 > maxX )
238  maxX = x1;
239  if ( x2 > maxX )
240  maxX = x2;
241  for ( int16_t x = minX; x <= maxX; x++ )
242  {
243  int16_t lo = 0, hi = 0;
244  bool hit = false;
245  edgeSpan(x, x0, y0, x1, y1, lo, hi, hit);
246  edgeSpan(x, x1, y1, x2, y2, lo, hi, hit);
247  edgeSpan(x, x2, y2, x0, y0, lo, hi, hit);
248  if ( hit )
249  drawFastVLine(x, lo, hi - lo + 1, color);
250  }
251  }
252 
254  void drawRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
255  {
256  if ( w <= 0 || h <= 0 )
257  return;
258  int16_t maxR = ((w < h) ? w : h) / 2;
259  if ( r > maxR )
260  r = maxR;
261  drawFastHLine(x + r, y, w - 2 * r, color);
262  drawFastHLine(x + r, y + h - 1, w - 2 * r, color);
263  drawFastVLine(x, y + r, h - 2 * r, color);
264  drawFastVLine(x + w - 1, y + r, h - 2 * r, color);
265  drawCircleHelper(x + r, y + r, r, 1, color);
266  drawCircleHelper(x + w - r - 1, y + r, r, 2, color);
267  drawCircleHelper(x + w - r - 1, y + h - r - 1, r, 4, color);
268  drawCircleHelper(x + r, y + h - r - 1, r, 8, color);
269  }
270 
272  void fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
273  {
274  if ( w <= 0 || h <= 0 )
275  return;
276  int16_t maxR = ((w < h) ? w : h) / 2;
277  if ( r > maxR )
278  r = maxR;
279  fillRect(x + r, y, w - 2 * r, h, color);
280  fillCircleHelper(x + w - r - 1, y + r, r, 1, h - 2 * r - 1, color);
281  fillCircleHelper(x + r, y + r, r, 2, h - 2 * r - 1, color);
282  }
283 
288  void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)
289  {
290  if ( w <= 0 || h <= 0 )
291  return;
292  m_d.setColor(mapColor(color));
293  m_d.drawBitmap1((lcdint_t)x, (lcdint_t)y, (lcduint_t)w, (lcduint_t)h, bitmap);
294  }
295 
297  void setCursor(int16_t x, int16_t y)
298  {
299  m_cursorX = x;
300  m_cursorY = y;
301  m_d.setTextCursor((lcdint_t)x, (lcdint_t)y);
302  }
303 
305  void setTextColor(uint16_t color)
306  {
307  m_textColor = color;
308  m_d.setColor(mapColor(color));
309  }
310 
312  void setTextColor(uint16_t color, uint16_t background)
313  {
314  m_textColor = color;
315  m_d.setColor(mapColor(color));
316  m_d.setBackground(mapColor(background));
317  }
318 
324  void setFont(const GFXfont *font)
325  {
326  m_gfxFont = font;
327  }
328 
333  void setTextSize(uint8_t size)
334  {
335  m_textSize = size;
336  }
337 
342  void setRotation(uint8_t rotation)
343  {
344  m_rotation = rotation & 0x03;
345  }
346 
348  uint8_t getRotation()
349  {
350  return m_rotation;
351  }
352 
354  size_t write(uint8_t ch)
355  {
356  if ( m_gfxFont )
357  {
358  writeGfxChar(ch);
359  }
360  else
361  {
362  char s[2] = {(char)ch, '\0'};
363  m_d.write(s);
364  }
365  return 1;
366  }
367 
369  void print(const char *str)
370  {
371  if ( m_gfxFont )
372  {
373  while ( *str )
374  {
375  writeGfxChar((uint8_t)*str++);
376  }
377  }
378  else
379  {
380  m_d.write(str);
381  }
382  }
383 
385  void print(char c)
386  {
387  write((uint8_t)c);
388  }
389 
391  void print(int number)
392  {
393  print((long)number);
394  }
395 
397  void print(long number)
398  {
399  char buf[12];
400  numToStr(number, buf);
401  print((const char *)buf);
402  }
403 
405  void println(const char *str)
406  {
407  print(str);
408  write((uint8_t)'\n');
409  }
410 
412  void println(int number)
413  {
414  print((long)number);
415  write((uint8_t)'\n');
416  }
417 
419  void println()
420  {
421  write((uint8_t)'\n');
422  }
423 
424  // ---- Adafruit_GFX transaction API (no-ops: lcdgfx has no global lock) ----
425 
427  void startWrite()
428  {
429  }
430 
432  void writePixel(int16_t x, int16_t y, uint16_t color)
433  {
434  drawPixel(x, y, color);
435  }
436 
438  void endWrite()
439  {
440  }
441 
443  D &display()
444  {
445  return m_d;
446  }
447 
448 private:
449  // Adafruit_GFX uses 0/1 for monochrome color; lcdgfx 1-bit ops expect a
450  // full 0x0000/0xFFFF mask. For deeper color panels the value (RGB332/RGB565)
451  // passes through untouched. The comparison is a compile-time constant.
452  static uint16_t mapColor(uint16_t color)
453  {
454  if ( D::BITS_PER_PIXEL == 1 )
455  return color ? 0xFFFF : 0x0000;
456  return color;
457  }
458 
459  // Accumulates the vertical extent (lo..hi) that triangle edge (xa,ya)-(xb,yb)
460  // contributes at column x, for the column-based fillTriangle.
461  static void edgeSpan(int16_t x, int16_t xa, int16_t ya, int16_t xb, int16_t yb, int16_t &lo, int16_t &hi, bool &hit)
462  {
463  int16_t xmin = xa < xb ? xa : xb;
464  int16_t xmax = xa > xb ? xa : xb;
465  if ( x < xmin || x > xmax )
466  return;
467  int16_t ey0, ey1;
468  if ( xa == xb )
469  { // vertical edge spans its whole segment at this column
470  ey0 = ya;
471  ey1 = yb;
472  }
473  else
474  {
475  ey0 = ey1 = (int16_t)((long)ya + (long)(yb - ya) * (x - xa) / (xb - xa));
476  }
477  if ( ey1 < ey0 )
478  {
479  int16_t t = ey0;
480  ey0 = ey1;
481  ey1 = t;
482  }
483  if ( !hit )
484  {
485  lo = ey0;
486  hi = ey1;
487  hit = true;
488  }
489  else
490  {
491  if ( ey0 < lo )
492  lo = ey0;
493  if ( ey1 > hi )
494  hi = ey1;
495  }
496  }
497 
498  // Formats a signed value in base 10 into buf (needs room for 12 chars).
499  static void numToStr(long value, char *buf)
500  {
501  char tmp[12];
502  uint8_t i = 0;
503  bool neg = value < 0;
504  unsigned long v = neg ? (unsigned long)(-value) : (unsigned long)value;
505  do
506  {
507  tmp[i++] = (char)('0' + (v % 10));
508  v /= 10;
509  } while ( v );
510  uint8_t j = 0;
511  if ( neg )
512  buf[j++] = '-';
513  while ( i )
514  buf[j++] = tmp[--i];
515  buf[j] = '\0';
516  }
517 
518  // Quarter-arc outline helper for drawRoundRect (Adafruit_GFX algorithm).
519  void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t corner, uint16_t color)
520  {
521  int16_t f = 1 - r, ddF_x = 1, ddF_y = -2 * r, x = 0, y = r;
522  while ( x < y )
523  {
524  if ( f >= 0 )
525  {
526  y--;
527  ddF_y += 2;
528  f += ddF_y;
529  }
530  x++;
531  ddF_x += 2;
532  f += ddF_x;
533  if ( corner & 0x4 )
534  {
535  drawPixel(x0 + x, y0 + y, color);
536  drawPixel(x0 + y, y0 + x, color);
537  }
538  if ( corner & 0x2 )
539  {
540  drawPixel(x0 + x, y0 - y, color);
541  drawPixel(x0 + y, y0 - x, color);
542  }
543  if ( corner & 0x8 )
544  {
545  drawPixel(x0 - y, y0 + x, color);
546  drawPixel(x0 - x, y0 + y, color);
547  }
548  if ( corner & 0x1 )
549  {
550  drawPixel(x0 - y, y0 - x, color);
551  drawPixel(x0 - x, y0 - y, color);
552  }
553  }
554  }
555 
556  // Filled half/quarter-circle helper for fillCircle/fillRoundRect.
557  void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t corner, int16_t delta, uint16_t color)
558  {
559  int16_t f = 1 - r, ddF_x = 1, ddF_y = -2 * r, x = 0, y = r, px = x, py = y;
560  delta++;
561  while ( x < y )
562  {
563  if ( f >= 0 )
564  {
565  y--;
566  ddF_y += 2;
567  f += ddF_y;
568  }
569  x++;
570  ddF_x += 2;
571  f += ddF_x;
572  if ( x < (y + 1) )
573  {
574  if ( corner & 1 )
575  drawFastVLine(x0 + x, y0 - y, 2 * y + delta, color);
576  if ( corner & 2 )
577  drawFastVLine(x0 - x, y0 - y, 2 * y + delta, color);
578  }
579  if ( y != py )
580  {
581  if ( corner & 1 )
582  drawFastVLine(x0 + py, y0 - px, 2 * px + delta, color);
583  if ( corner & 2 )
584  drawFastVLine(x0 - py, y0 - px, 2 * px + delta, color);
585  py = y;
586  }
587  px = x;
588  }
589  }
590 
591  // Byte-copies a PROGMEM-resident struct into RAM (correct on AVR and MCUs
592  // with memory-mapped flash alike).
593  static void readStruct(const void *src, void *dst, size_t n)
594  {
595  const uint8_t *s = (const uint8_t *)src;
596  uint8_t *d = (uint8_t *)dst;
597  for ( size_t i = 0; i < n; i++ )
598  {
599  d[i] = pgm_read_byte(s + i);
600  }
601  }
602 
603  // Largest glyph (width * ceil(height/8) bytes) the packing buffer can hold.
604  // Covers e.g. 32px-tall fonts up to 32px wide; larger glyphs are skipped.
605  static const uint16_t kGlyphBufSize = 128;
606 
607  // Renders one glyph of the active GFXfont at the current cursor, advancing
608  // the cursor. The row-major Adafruit glyph is repacked into lcdgfx's
609  // column-major/page format and drawn with a single drawBitmap1 call, so it
610  // renders correctly on paged monochrome displays (no per-pixel page clobber)
611  // and on color panels alike. Uses the current text color.
612  void writeGfxChar(uint8_t c)
613  {
614  GFXfont font;
615  readStruct(m_gfxFont, &font, sizeof(GFXfont));
616 
617  if ( c == '\n' )
618  {
619  m_cursorX = 0;
620  m_cursorY += (int16_t)font.yAdvance;
621  return;
622  }
623  if ( c == '\r' || c < font.first || c > font.last )
624  {
625  return;
626  }
627 
628  GFXglyph glyph;
629  readStruct(font.glyph + (c - font.first), &glyph, sizeof(GFXglyph));
630 
631  uint8_t w = glyph.width, h = glyph.height;
632  uint8_t xa = glyph.xAdvance;
633  if ( w == 0 || h == 0 ) // e.g. space: advance only
634  {
635  m_cursorX += (int16_t)xa;
636  return;
637  }
638 
639  // Draw at a page-aligned y (offset 0) and pre-shift the glyph inside the
640  // buffer by the sub-page amount. This avoids drawBitmap1's short-bitmap
641  // corner case (it drops data when a <1 page glyph lands at a non-zero
642  // page offset) and works uniformly on paged mono and color displays.
643  int16_t top = m_cursorY + glyph.yOffset;
644  uint8_t shift = (uint8_t)(((top % 8) + 8) % 8);
645  int16_t alignedTop = top - shift;
646  uint8_t packedH = (uint8_t)(h + shift);
647  uint8_t pages = (uint8_t)((packedH + 7) >> 3);
648  if ( (uint16_t)w * pages > kGlyphBufSize )
649  {
650  m_cursorX += (int16_t)xa; // glyph too large for the packing buffer
651  return;
652  }
653 
654  uint8_t buf[kGlyphBufSize];
655  for ( uint16_t k = 0; k < (uint16_t)w * pages; k++ )
656  buf[k] = 0;
657 
658  const uint8_t *bitmap = font.bitmap;
659  uint16_t bo = glyph.bitmapOffset;
660  uint8_t bits = 0, bit = 0;
661  for ( uint8_t row = 0; row < h; row++ )
662  {
663  uint8_t dst = (uint8_t)(row + shift);
664  uint8_t page = (uint8_t)(dst >> 3);
665  uint8_t pbit = (uint8_t)(dst & 7);
666  for ( uint8_t col = 0; col < w; col++ )
667  {
668  if ( (bit++ & 7) == 0 )
669  {
670  bits = pgm_read_byte(bitmap + bo++);
671  }
672  if ( bits & 0x80 )
673  {
674  buf[(uint16_t)page * w + col] |= (uint8_t)(1 << pbit);
675  }
676  bits <<= 1;
677  }
678  }
679 
680  m_d.setColor(mapColor(m_textColor));
681  m_d.drawBitmap1((lcdint_t)(m_cursorX + glyph.xOffset), (lcdint_t)alignedTop, (lcduint_t)w, (lcduint_t)packedH,
682  buf);
683  m_cursorX += (int16_t)xa;
684  }
685 
686  D &m_d;
687  const GFXfont *m_gfxFont = nullptr;
688  uint16_t m_textColor = 0xFFFF;
689  int16_t m_cursorX = 0;
690  int16_t m_cursorY = 0;
691  uint8_t m_textSize = 1;
692  uint8_t m_rotation = 0;
693 };
694 
699 template <class D> GfxCompat<D> makeGfxCompat(D &display)
700 {
701  return GfxCompat<D>(display);
702 }
703 
uint16_t bitmapOffset
Pointer into GFXfont->bitmap.
Definition: gfx_compat.h:80
void startWrite()
Adafruit_GFX transaction start hook.
Definition: gfx_compat.h:427
GFXglyph * glyph
Glyph array.
Definition: gfx_compat.h:92
uint8_t lcduint_t
internal int type, used by the library.
Definition: canvas_types.h:79
Adafruit_GFX font descriptor.
Definition: gfx_compat.h:89
void endWrite()
Adafruit_GFX transaction end hook.
Definition: gfx_compat.h:438
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()).
Definition: gfx_compat.h:272
uint8_t width
Bitmap dimensions in pixels.
Definition: gfx_compat.h:81
uint16_t first
ASCII extents (first char)
Definition: gfx_compat.h:93
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Draws a vertical run of h pixels (Adafruit_GFX::drawFastVLine()).
Definition: gfx_compat.h:147
void setTextSize(uint8_t size)
Accepts an Adafruit_GFX text size.
Definition: gfx_compat.h:333
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()).
Definition: gfx_compat.h:181
GfxCompat(D &display)
Creates an Adafruit_GFX-compatible facade bound to an existing display.
Definition: gfx_compat.h:115
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Draws a horizontal run of w pixels (Adafruit_GFX::drawFastHLine()).
Definition: gfx_compat.h:156
GfxCompat< D > makeGfxCompat(D &display)
Convenience factory that deduces the display type, so callers can write auto gfx = makeGfxCompat(disp...
Definition: gfx_compat.h:699
int8_t lcdint_t
internal int type, used by the library.
Definition: canvas_types.h:77
int16_t height()
Returns display height in pixels (Adafruit_GFX::height()).
Definition: gfx_compat.h:127
void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draws a circle outline (Adafruit_GFX::drawCircle()).
Definition: gfx_compat.h:197
SSD1306 HAL IO communication functions.
void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Draws an arbitrary line (Adafruit_GFX::drawLine()).
Definition: gfx_compat.h:165
size_t write(uint8_t ch)
Writes a single character at the text cursor (Adafruit_GFX::write()).
Definition: gfx_compat.h:354
void setCursor(int16_t x, int16_t y)
Positions the text cursor (Adafruit_GFX::setCursor()).
Definition: gfx_compat.h:297
uint8_t yAdvance
Newline distance (y axis)
Definition: gfx_compat.h:95
void setFont(const GFXfont *font)
Selects an Adafruit_GFX custom font (GFXfont) for text output.
Definition: gfx_compat.h:324
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()).
Definition: gfx_compat.h:215
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()).
Definition: gfx_compat.h:172
void writePixel(int16_t x, int16_t y, uint16_t color)
Adafruit_GFX transaction pixel write; identical to drawPixel().
Definition: gfx_compat.h:432
void println()
Emits a newline (Adafruit_GFX/Print::println()).
Definition: gfx_compat.h:419
void print(char c)
Prints a single character (Adafruit_GFX/Print::print()).
Definition: gfx_compat.h:385
void println(int number)
Prints an integer followed by a newline (Adafruit_GFX/Print::println()).
Definition: gfx_compat.h:412
uint8_t xAdvance
Distance to advance cursor (x axis)
Definition: gfx_compat.h:83
void fillScreen(uint16_t color)
Fills the whole screen with a single color (Adafruit_GFX::fillScreen()).
Definition: gfx_compat.h:190
uint16_t last
ASCII extents (last char)
Definition: gfx_compat.h:94
void println(const char *str)
Prints a string followed by a newline (Adafruit_GFX/Print::println()).
Definition: gfx_compat.h:405
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()).
Definition: gfx_compat.h:230
void setTextColor(uint16_t color, uint16_t background)
Sets text foreground and background color (Adafruit_GFX::setTextColor()).
Definition: gfx_compat.h:312
uint8_t height
Bitmap dimensions in pixels.
Definition: gfx_compat.h:82
void setTextColor(uint16_t color)
Sets text foreground color (Adafruit_GFX::setTextColor()).
Definition: gfx_compat.h:305
int8_t yOffset
Y dist from cursor pos to UL corner.
Definition: gfx_compat.h:85
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()).
Definition: gfx_compat.h:288
D & display()
Returns the wrapped lcdgfx display/canvas for native calls.
Definition: gfx_compat.h:443
uint8_t * bitmap
Glyph bitmaps, concatenated.
Definition: gfx_compat.h:91
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()).
Definition: gfx_compat.h:254
Adafruit_GFX glyph descriptor.
Definition: gfx_compat.h:78
void print(int number)
Prints a signed integer in base 10 (Adafruit_GFX/Print::print()).
Definition: gfx_compat.h:391
int8_t xOffset
X dist from cursor pos to UL corner.
Definition: gfx_compat.h:84
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draws a filled circle (Adafruit_GFX::fillCircle()).
Definition: gfx_compat.h:206
void drawPixel(int16_t x, int16_t y, uint16_t color)
Draws a single pixel of the given color (Adafruit_GFX::drawPixel()).
Definition: gfx_compat.h:133
void print(long number)
Prints a signed long in base 10 (Adafruit_GFX/Print::print()).
Definition: gfx_compat.h:397
void setRotation(uint8_t rotation)
Accepts an Adafruit_GFX rotation value for source compatibility.
Definition: gfx_compat.h:342
void print(const char *str)
Prints a null-terminated string (Adafruit_GFX/Print::print()).
Definition: gfx_compat.h:369
Adafruit_GFX-compatible adapter around any lcdgfx display or canvas type D.
Definition: gfx_compat.h:107
uint8_t getRotation()
Returns the stored rotation value (Adafruit_GFX::getRotation()).
Definition: gfx_compat.h:348
int16_t width()
Returns display width in pixels (Adafruit_GFX::width()).
Definition: gfx_compat.h:121