34#include "Adafruit_GFX.h"
37#include <avr/pgmspace.h>
38#elif defined(ESP8266) || defined(ESP32)
47#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
50#define pgm_read_word(addr) (*(const unsigned short *)(addr))
53#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
59#if !defined(__INT_MAX__) || (__INT_MAX__ > 0xFFFF)
60#define pgm_read_pointer(addr) ((void *)pgm_read_dword(addr))
62#define pgm_read_pointer(addr) ((void *)pgm_read_word(addr))
71inline GFXglyph *pgm_read_glyph_ptr(
const GFXfont *gfxFont, uint8_t c) {
73 return &(((GFXglyph *)pgm_read_pointer(&gfxFont->glyph))[c]);
79 return gfxFont->glyph + c;
88inline uint8_t *pgm_read_bitmap_ptr(
const GFXfont *gfxFont) {
90 return (uint8_t *)pgm_read_pointer(&gfxFont->bitmap);
96 return gfxFont->bitmap;
101#define min(a, b) (((a) < (b)) ? (a) : (b))
105#define _swap_int16_t(a, b) \
146 int16_t steep = abs(y1 - y0) > abs(x1 - x0);
148 _swap_int16_t(x0, y0);
149 _swap_int16_t(x1, y1);
153 _swap_int16_t(x0, x1);
154 _swap_int16_t(y0, y1);
161 int16_t err = dx / 2;
170 for (; x0 <= x1; x0++) {
312 for (int16_t i = x; i < x + w; i++) {
344 _swap_int16_t(y0, y1);
346 }
else if (y0 == y1) {
348 _swap_int16_t(x0, x1);
373 int16_t x = 0, y = rh;
374 int32_t rw2 = rw * rw, rh2 = rh * rh;
375 int32_t twoRw2 = 2 * rw2, twoRh2 = 2 * rh2;
377 int32_t decision = rh2 - (rw2 * rh) + (rw2 / 4);
382 while ((twoRh2 * x) < (twoRw2 * y)) {
389 decision += rh2 + (twoRh2 * x);
391 decision += rh2 + (twoRh2 * x) - (twoRw2 * y);
397 decision = ((rh2 * (2 * x + 1) * (2 * x + 1)) >> 2) +
398 (rw2 * (y - 1) * (y - 1)) - (rw2 * rh2);
406 decision += rw2 - (twoRw2 * y);
408 decision += rw2 + (twoRh2 * x) - (twoRw2 * y);
432 int16_t x = 0, y = rh;
433 int32_t rw2 = rw * rw, rh2 = rh * rh;
434 int32_t twoRw2 = 2 * rw2, twoRh2 = 2 * rh2;
436 int32_t decision = rh2 - (rw2 * rh) + (rw2 / 4);
441 while ((twoRh2 * x) < (twoRw2 * y)) {
444 decision += rh2 + (twoRh2 * x);
446 decision += rh2 + (twoRh2 * x) - (twoRw2 * y);
454 decision = ((rh2 * (2 * x + 1) * (2 * x + 1)) >> 2) +
455 (rw2 * (y - 1) * (y - 1)) - (rw2 * rh2);
462 decision += rw2 - (twoRw2 * y);
464 decision += rw2 + (twoRh2 * x) - (twoRw2 * y);
488 int16_t ddF_y = -2 * r;
532 uint8_t cornername, uint16_t color) {
535 int16_t ddF_y = -2 * r;
548 if (cornername & 0x4) {
552 if (cornername & 0x2) {
556 if (cornername & 0x8) {
560 if (cornername & 0x1) {
597 uint8_t corners, int16_t delta,
602 int16_t ddF_y = -2 * r;
670 int16_t r, uint16_t color) {
671 int16_t max_radius = ((w < h) ? w : h) / 2;
700 int16_t r, uint16_t color) {
701 int16_t max_radius = ((w < h) ? w : h) / 2;
731 int16_t h, int16_t angleDeg,
740 int16_t halfW = (W / 2);
741 int16_t halfH = (H / 2);
743 int16_t x0 = W - halfW;
744 int16_t y0 = H - halfH;
746 int16_t y1 = H - halfH;
749 int16_t x3 = W - halfW;
791 int16_t h, int16_t angleDeg,
800 int16_t halfW = (W / 2);
801 int16_t halfH = (H / 2);
803 int16_t x0 = W - halfW;
804 int16_t y0 = H - halfH;
806 int16_t y1 = H - halfH;
809 int16_t x3 = W - halfW;
842 float angleRad = radians(angleDeg);
843 float s = sin(angleRad);
844 float c = cos(angleRad);
850 x0 = (int16_t)((x * c) - (y * s));
851 y0 = (int16_t)((x * s) + (y * c));
867 int16_t x2, int16_t y2, uint16_t color) {
886 int16_t x2, int16_t y2, uint16_t color) {
888 int16_t a, b, y, last;
892 _swap_int16_t(y0, y1);
893 _swap_int16_t(x0, x1);
896 _swap_int16_t(y2, y1);
897 _swap_int16_t(x2, x1);
900 _swap_int16_t(y0, y1);
901 _swap_int16_t(x0, x1);
920 int16_t dx01 = x1 - x0, dy01 = y1 - y0, dx02 = x2 - x0, dy02 = y2 - y0,
921 dx12 = x2 - x1, dy12 = y2 - y1;
922 int32_t sa = 0, sb = 0;
935 for (y = y0; y <= last; y++) {
951 sa = (int32_t)dx12 * (y - y1);
952 sb = (int32_t)dx02 * (y - y0);
953 for (; y <= y2; y++) {
984 int16_t w, int16_t h, uint16_t color) {
986 int16_t byteWidth = (w + 7) / 8;
990 for (int16_t j = 0; j < h; j++, y++) {
991 for (int16_t i = 0; i < w; i++) {
995 b = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
1018 int16_t w, int16_t h, uint16_t color,
1021 int16_t byteWidth = (w + 7) / 8;
1025 for (int16_t j = 0; j < h; j++, y++) {
1026 for (int16_t i = 0; i < w; i++) {
1030 b = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
1031 writePixel(x + i, y, (b & 0x80) ? color : bg);
1050 int16_t h, uint16_t color) {
1052 int16_t byteWidth = (w + 7) / 8;
1056 for (int16_t j = 0; j < h; j++, y++) {
1057 for (int16_t i = 0; i < w; i++) {
1061 b = bitmap[j * byteWidth + i / 8];
1084 int16_t h, uint16_t color, uint16_t bg) {
1086 int16_t byteWidth = (w + 7) / 8;
1090 for (int16_t j = 0; j < h; j++, y++) {
1091 for (int16_t i = 0; i < w; i++) {
1095 b = bitmap[j * byteWidth + i / 8];
1096 writePixel(x + i, y, (b & 0x80) ? color : bg);
1118 int16_t w, int16_t h, uint16_t color) {
1120 int16_t byteWidth = (w + 7) / 8;
1124 for (int16_t j = 0; j < h; j++, y++) {
1125 for (int16_t i = 0; i < w; i++) {
1129 b = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
1152 const uint8_t bitmap[], int16_t w,
1155 for (int16_t j = 0; j < h; j++, y++) {
1156 for (int16_t i = 0; i < w; i++) {
1157 writePixel(x + i, y, (uint8_t)pgm_read_byte(&bitmap[j * w + i]));
1176 int16_t w, int16_t h) {
1178 for (int16_t j = 0; j < h; j++, y++) {
1179 for (int16_t i = 0; i < w; i++) {
1202 const uint8_t bitmap[],
1203 const uint8_t mask[], int16_t w,
1205 int16_t bw = (w + 7) / 8;
1208 for (int16_t j = 0; j < h; j++, y++) {
1209 for (int16_t i = 0; i < w; i++) {
1213 b = pgm_read_byte(&mask[j * bw + i / 8]);
1215 writePixel(x + i, y, (uint8_t)pgm_read_byte(&bitmap[j * w + i]));
1238 uint8_t *mask, int16_t w, int16_t h) {
1239 int16_t bw = (w + 7) / 8;
1242 for (int16_t j = 0; j < h; j++, y++) {
1243 for (int16_t i = 0; i < w; i++) {
1247 b = mask[j * bw + i / 8];
1268 int16_t w, int16_t h) {
1270 for (int16_t j = 0; j < h; j++, y++) {
1271 for (int16_t i = 0; i < w; i++) {
1272 writePixel(x + i, y, pgm_read_word(&bitmap[j * w + i]));
1290 int16_t w, int16_t h) {
1292 for (int16_t j = 0; j < h; j++, y++) {
1293 for (int16_t i = 0; i < w; i++) {
1315 const uint8_t mask[], int16_t w, int16_t h) {
1316 int16_t bw = (w + 7) / 8;
1319 for (int16_t j = 0; j < h; j++, y++) {
1320 for (int16_t i = 0; i < w; i++) {
1324 b = pgm_read_byte(&mask[j * bw + i / 8]);
1326 writePixel(x + i, y, pgm_read_word(&bitmap[j * w + i]));
1348 uint8_t *mask, int16_t w, int16_t h) {
1349 int16_t bw = (w + 7) / 8;
1352 for (int16_t j = 0; j < h; j++, y++) {
1353 for (int16_t i = 0; i < w; i++) {
1357 b = mask[j * bw + i / 8];
1382 uint16_t color, uint16_t bg, uint8_t size) {
1383 drawChar(x, y, c, color, bg, size, size);
1401 uint16_t color, uint16_t bg, uint8_t size_x,
1408 ((x + 6 * size_x - 1) < 0) ||
1409 ((y + 8 * size_y - 1) < 0))
1412 if (!
_cp437 && (c >= 176))
1416 for (int8_t i = 0; i < 5; i++) {
1417 uint8_t line = pgm_read_byte(&font[c * 5 + i]);
1418 for (int8_t j = 0; j < 8; j++, line >>= 1) {
1420 if (size_x == 1 && size_y == 1)
1423 writeFillRect(x + i * size_x, y + j * size_y, size_x, size_y,
1425 }
else if (bg != color) {
1426 if (size_x == 1 && size_y == 1)
1429 writeFillRect(x + i * size_x, y + j * size_y, size_x, size_y, bg);
1434 if (size_x == 1 && size_y == 1)
1447 c -= (uint8_t)pgm_read_byte(&
gfxFont->first);
1448 GFXglyph *glyph = pgm_read_glyph_ptr(
gfxFont, c);
1449 uint8_t *bitmap = pgm_read_bitmap_ptr(
gfxFont);
1451 uint16_t bo = pgm_read_word(&glyph->bitmapOffset);
1452 uint8_t w = pgm_read_byte(&glyph->width), h = pgm_read_byte(&glyph->height);
1453 int8_t xo = pgm_read_byte(&glyph->xOffset),
1454 yo = pgm_read_byte(&glyph->yOffset);
1455 uint8_t xx, yy, bits = 0, bit = 0;
1456 int16_t xo16 = 0, yo16 = 0;
1458 if (size_x > 1 || size_y > 1) {
1482 for (yy = 0; yy < h; yy++) {
1483 for (xx = 0; xx < w; xx++) {
1485 bits = pgm_read_byte(&bitmap[bo++]);
1488 if (size_x == 1 && size_y == 1) {
1491 writeFillRect(x + (xo16 + xx) * size_x, y + (yo16 + yy) * size_y,
1492 size_x, size_y, color);
1514 }
else if (c !=
'\r') {
1530 }
else if (c !=
'\r') {
1531 uint8_t first = pgm_read_byte(&
gfxFont->first);
1532 if ((c >= first) && (c <= (uint8_t)pgm_read_byte(&
gfxFont->last))) {
1533 GFXglyph *glyph = pgm_read_glyph_ptr(
gfxFont, c - first);
1534 uint8_t w = pgm_read_byte(&glyph->width),
1535 h = pgm_read_byte(&glyph->height);
1536 if ((w > 0) && (h > 0)) {
1537 int16_t xo = (int8_t)pgm_read_byte(&glyph->xOffset);
1541 (uint8_t)pgm_read_byte(&
gfxFont->yAdvance);
1547 (uint8_t)pgm_read_byte(&glyph->xAdvance) * (int16_t)
textsize_x;
1638 int16_t *minx, int16_t *miny, int16_t *maxx,
1646 }
else if (c !=
'\r') {
1647 uint8_t first = pgm_read_byte(&
gfxFont->first),
1648 last = pgm_read_byte(&
gfxFont->last);
1649 if ((c >= first) && (c <= last)) {
1650 GFXglyph *glyph = pgm_read_glyph_ptr(
gfxFont, c - first);
1651 uint8_t gw = pgm_read_byte(&glyph->width),
1652 gh = pgm_read_byte(&glyph->height),
1653 xa = pgm_read_byte(&glyph->xAdvance);
1654 int8_t xo = pgm_read_byte(&glyph->xOffset),
1655 yo = pgm_read_byte(&glyph->yOffset);
1661 x1 = *x + xo * tsx, y1 = *y + yo * tsy, x2 = x1 + gw * tsx - 1,
1662 y2 = y1 + gh * tsy - 1;
1681 }
else if (c !=
'\r') {
1715 int16_t *x1, int16_t *y1, uint16_t *w,
1719 int16_t minx = 0x7FFF, miny = 0x7FFF, maxx = -1, maxy = -1;
1726 while ((c = *str++)) {
1729 charBounds(c, &x, &y, &minx, &miny, &maxx, &maxy);
1734 *w = maxx - minx + 1;
1738 *h = maxy - miny + 1;
1756 int16_t *x1, int16_t *y1, uint16_t *w,
1777 int16_t y, int16_t *x1, int16_t *y1,
1778 uint16_t *w, uint16_t *h) {
1779 uint8_t *s = (uint8_t *)str, c;
1785 int16_t minx =
_width, miny =
_height, maxx = -1, maxy = -1;
1787 while ((c = pgm_read_byte(s++)))
1788 charBounds(c, &x, &y, &minx, &miny, &maxx, &maxy);
1792 *w = maxx - minx + 1;
1796 *h = maxy - miny + 1;
1837 uint16_t w, uint16_t h, uint16_t outline,
1838 uint16_t fill, uint16_t textcolor,
1839 char *label, uint8_t textsize) {
1841 initButtonUL(gfx, x - (w / 2), y - (h / 2), w, h, outline, fill, textcolor,
1863 uint16_t w, uint16_t h, uint16_t outline,
1864 uint16_t fill, uint16_t textcolor,
1865 char *label, uint8_t textsize_x,
1866 uint8_t textsize_y) {
1868 initButtonUL(gfx, x - (w / 2), y - (h / 2), w, h, outline, fill, textcolor,
1869 label, textsize_x, textsize_y);
1889 int16_t y1, uint16_t w, uint16_t h,
1890 uint16_t outline, uint16_t fill,
1891 uint16_t textcolor,
char *label,
1893 initButtonUL(gfx, x1, y1, w, h, outline, fill, textcolor, label, textsize,
1915 int16_t y1, uint16_t w, uint16_t h,
1916 uint16_t outline, uint16_t fill,
1917 uint16_t textcolor,
char *label,
1918 uint8_t textsize_x, uint8_t textsize_y) {
1923 _outlinecolor = outline;
1925 _textcolor = textcolor;
1926 _textsize_x = textsize_x;
1927 _textsize_y = textsize_y;
1929 strncpy(_label, label, 9);
1942 uint16_t fill, outline, text;
1946 outline = _outlinecolor;
1950 outline = _outlinecolor;
1954 uint8_t r = min(_w, _h) / 4;
1958 _gfx->
setCursor(_x1 + (_w / 2) - (strlen(_label) * 3 * _textsize_x),
1959 _y1 + (_h / 2) - (4 * _textsize_y));
1962 _gfx->
print(_label);
1975 return ((x >= _x1) && (x < (int16_t)(_x1 + _w)) && (y >= _y1) &&
1976 (y < (int16_t)(_y1 + _h)));
2016const uint8_t PROGMEM GFXcanvas1::GFXsetBit[] = {0x80, 0x40, 0x20, 0x10,
2017 0x08, 0x04, 0x02, 0x01};
2018const uint8_t PROGMEM GFXcanvas1::GFXclrBit[] = {0x7F, 0xBF, 0xDF, 0xEF,
2019 0xF7, 0xFB, 0xFD, 0xFE};
2035 if (allocate_buffer) {
2036 uint32_t bytes = ((w + 7) / 8) * h;
2037 if ((
buffer = (uint8_t *)malloc(bytes))) {
2038 memset(
buffer, 0, bytes);
2086 uint8_t *ptr = &
buffer[(x / 8) + y * ((
WIDTH + 7) / 8)];
2089 *ptr |= pgm_read_byte(&GFXsetBit[x & 7]);
2091 *ptr &= pgm_read_byte(&GFXclrBit[x & 7]);
2094 *ptr |= 0x80 >> (x & 7);
2096 *ptr &= ~(0x80 >> (x & 7));
2139 if ((x < 0) || (y < 0) || (x >=
WIDTH) || (y >=
HEIGHT))
2142 uint8_t *ptr = &
buffer[(x / 8) + y * ((
WIDTH + 7) / 8)];
2145 return ((*ptr) & pgm_read_byte(&GFXsetBit[x & 7])) != 0;
2147 return ((*ptr) & (0x80 >> (x & 7))) != 0;
2162 memset(
buffer, color ? 0xFF : 0x00, bytes);
2188 if ((x < 0) || (x >=
width()) || (y >=
height()) || ((y + h - 1) < 0)) {
2243 if ((y < 0) || (y >=
height()) || (x >=
width()) || ((x + w - 1) < 0)) {
2251 if (x + w >=
width()) {
2289 int16_t row_bytes = ((
WIDTH + 7) / 8);
2290 uint8_t *ptr = &
buffer[(x / 8) + y * row_bytes];
2294 uint8_t bit_mask = pgm_read_byte(&GFXsetBit[x & 7]);
2296 uint8_t bit_mask = (0x80 >> (x & 7));
2298 for (int16_t i = 0; i < h; i++) {
2304 uint8_t bit_mask = pgm_read_byte(&GFXclrBit[x & 7]);
2306 uint8_t bit_mask = ~(0x80 >> (x & 7));
2308 for (int16_t i = 0; i < h; i++) {
2327 int16_t rowBytes = ((
WIDTH + 7) / 8);
2328 uint8_t *ptr = &
buffer[(x / 8) + y * rowBytes];
2329 size_t remainingWidthBits = w;
2334 uint8_t startByteBitMask = 0x00;
2335 for (int8_t i = (x & 7); ((i < 8) && (remainingWidthBits > 0)); i++) {
2337 startByteBitMask |= pgm_read_byte(&GFXsetBit[i]);
2339 startByteBitMask |= (0x80 >> i);
2341 remainingWidthBits--;
2344 *ptr |= startByteBitMask;
2346 *ptr &= ~startByteBitMask;
2353 if (remainingWidthBits > 0) {
2354 size_t remainingWholeBytes = remainingWidthBits / 8;
2355 size_t lastByteBits = remainingWidthBits % 8;
2356 uint8_t wholeByteColor = color > 0 ? 0xFF : 0x00;
2358 memset(ptr, wholeByteColor, remainingWholeBytes);
2360 if (lastByteBits > 0) {
2361 uint8_t lastByteBitMask = 0x00;
2362 for (
size_t i = 0; i < lastByteBits; i++) {
2364 lastByteBitMask |= pgm_read_byte(&GFXsetBit[i]);
2366 lastByteBitMask |= (0x80 >> i);
2369 ptr += remainingWholeBytes;
2372 *ptr |= lastByteBitMask;
2374 *ptr &= ~lastByteBitMask;
2393 if (allocate_buffer) {
2394 uint32_t bytes = w * h;
2395 if ((
buffer = (uint8_t *)malloc(bytes))) {
2396 memset(
buffer, 0, bytes);
2487 if ((x < 0) || (y < 0) || (x >=
WIDTH) || (y >=
HEIGHT))
2529 if ((x < 0) || (x >=
width()) || (y >=
height()) || ((y + h - 1) < 0)) {
2586 if ((y < 0) || (y >=
height()) || (x >=
width()) || ((x + w - 1) < 0)) {
2594 if (x + w >=
width()) {
2634 for (int16_t i = 0; i < h; i++) {
2635 (*buffer_ptr) = color;
2636 buffer_ptr +=
WIDTH;
2669 if (allocate_buffer) {
2670 uint32_t bytes = w * h * 2;
2671 if ((
buffer = (uint16_t *)malloc(bytes))) {
2672 memset(
buffer, 0, bytes);
2764 if ((x < 0) || (y < 0) || (x >=
WIDTH) || (y >=
HEIGHT))
2780 uint8_t hi = color >> 8, lo = color & 0xFF;
2785 for (i = 0; i < pixels; i++)
2807 for (i = 0; i < pixels; i++)
2833 if ((x < 0) || (x >=
width()) || (y >=
height()) || ((y + h - 1) < 0)) {
2888 if ((y < 0) || (y >=
height()) || (x >=
width()) || ((x + w - 1) < 0)) {
2896 if (x + w >=
width()) {
2935 for (int16_t i = 0; i < h; i++) {
2936 (*buffer_ptr) = color;
2937 buffer_ptr +=
WIDTH;
2953 uint32_t buffer_index = y *
WIDTH + x;
2954 for (uint32_t i = buffer_index; i < buffer_index + w; i++) {
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)
Half-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.
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 rotatePoint(int16_t &x0, int16_t &y0, int16_t angleDeg)
Rotate a point in standard position.
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.
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.
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 fillEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh, uint16_t color)
Draw an ellipse with filled colour.
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...
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 drawEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh, uint16_t color)
Draw an ellipse outline.
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 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!
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 ...
void drawRotatedRect(int16_t cenX, int16_t cenY, int16_t w, int16_t h, int16_t angleDeg, uint16_t color)
Draw a rotated rectangle.
GFXfont * gfxFont
Pointer to special font.
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 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...
GFXcanvas16(uint16_t w, uint16_t h, bool allocate_buffer=true)
Instatiate a GFX 16-bit canvas context for graphics.
void drawPixel(int16_t x, int16_t y, uint16_t color)
Draw a pixel to the canvas framebuffer.
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.
GFXcanvas1(uint16_t w, uint16_t h, bool allocate_buffer=true)
Instatiate a GFX 1-bit canvas context for graphics.
bool 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...
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
Get the pixel color value at a given coordinate.
void fillScreen(uint16_t color)
Fill the framebuffer completely with one color.
uint8_t * buffer
Raster data: no longer private, allow subclass access.
~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...
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.
GFXcanvas8(uint16_t w, uint16_t h, bool allocate_buffer=true)
Instatiate a GFX 8-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.
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.
size_t print(const __FlashStringHelper *ifsh)
Print a flash-resident string, e.g. print(F("text")).
Minimal Arduino-String stand-in (see file description).
const char * c_str() const
unsigned int length() const