Adafruit-GFX porting for mbed OS6. Needed to add #include "Stream.h" in beginning of the Adafruit_GFX.h

Dependents:   ollin-ja-samin-hieno-ihmislaskin MCLAB10 OLEDrgb_MP OLEDrgb_MIC3_L432KC_OS6_hk McLab10_OLEDrgb_L432KC_OS60_tk2

Committer:
timo_k2
Date:
Sat Aug 29 11:03:56 2020 +0000
Revision:
5:27c133247105
Parent:
4:ca74c390a0de
For the Mbed OS 6 needed to add ; #include "Stream.h"; in beginning of the Adafruit_GFX.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lelect 0:3e9c32359703 1 #ifndef _ADAFRUIT_GFX_H
lelect 0:3e9c32359703 2 #define _ADAFRUIT_GFX_H
lelect 3:3ffdf181555c 3
lelect 3:3ffdf181555c 4 #include "mbed.h"
lelect 3:3ffdf181555c 5 #include "glcdfont.h"
timo_k2 5:27c133247105 6 #include "Stream.h" // testing tk
lelect 3:3ffdf181555c 7
lelect 0:3e9c32359703 8 #define BLACK 0
lelect 0:3e9c32359703 9 #define WHITE 1
lelect 0:3e9c32359703 10 #ifndef _BV
lelect 0:3e9c32359703 11 #define _BV(bit) (1<<(bit))
lelect 0:3e9c32359703 12 #endif
lelect 3:3ffdf181555c 13 #define swap(a, b) { int16_t t = a; a = b; b = t; }
lelect 0:3e9c32359703 14
lelect 3:3ffdf181555c 15 /** Adafruit_GFX class. This is the Adafruit_GFX class.\n drawPixel(int16_t x,int16_t y,uint16_t color) needing implementation in derived implementation class
lelect 1:c2715acb7466 16 */
lelect 0:3e9c32359703 17 class Adafruit_GFX : public Stream
lelect 0:3e9c32359703 18 {
lelect 0:3e9c32359703 19 public:
lelect 0:3e9c32359703 20 Adafruit_GFX(int16_t w, int16_t h)
lelect 2:66a3fe0dc83a 21 : _rawWidth(w),_rawHeight(h)
lelect 2:66a3fe0dc83a 22 ,_width(w),_height(h)
lelect 2:66a3fe0dc83a 23 ,cursor_x(0),cursor_y(0)
lelect 2:66a3fe0dc83a 24 ,textcolor(WHITE),textbgcolor(BLACK)
lelect 1:c2715acb7466 25 ,textsize(1)
lelect 1:c2715acb7466 26 ,rotation(0)
lelect 1:c2715acb7466 27 ,wrap(true)
lelect 2:66a3fe0dc83a 28 {};
lelect 0:3e9c32359703 29
lelect 3:3ffdf181555c 30 /** @fn void Adafruit_GFX::drawPixel(int16_t x, int16_t y, uint16_t color) = 0
lelect 2:66a3fe0dc83a 31 * @bref This MUST be defined by the subclass!
lelect 2:66a3fe0dc83a 32 * @param x x
lelect 2:66a3fe0dc83a 33 * @param y y
lelect 2:66a3fe0dc83a 34 * @param color 16bit color
lelect 2:66a3fe0dc83a 35 */
lelect 0:3e9c32359703 36 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
lelect 3:3ffdf181555c 37 // These are overridden for the Stream subclass
lelect 0:3e9c32359703 38 virtual int _putc(int value) {
lelect 0:3e9c32359703 39 return writeChar(value);
lelect 0:3e9c32359703 40 };
lelect 0:3e9c32359703 41 virtual int _getc() {
lelect 0:3e9c32359703 42 return -1;
lelect 0:3e9c32359703 43 };
lelect 3:3ffdf181555c 44 /** @fn void Adafruit_GFX::invertDisplay(bool i)
lelect 2:66a3fe0dc83a 45 * @bref Do nothing, must be subclassed if supported
lelect 2:66a3fe0dc83a 46 * @param i invert
lelect 2:66a3fe0dc83a 47 */
lelect 0:3e9c32359703 48 virtual void invertDisplay(bool i);
lelect 0:3e9c32359703 49
lelect 2:66a3fe0dc83a 50 // These MAY be overridden by the subclass to provide device-specific
lelect 2:66a3fe0dc83a 51 // optimized code. Otherwise 'generic' versions are used.
lelect 0:3e9c32359703 52 virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
lelect 0:3e9c32359703 53 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
lelect 0:3e9c32359703 54 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
lelect 0:3e9c32359703 55 virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
lelect 0:3e9c32359703 56 virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
lelect 0:3e9c32359703 57 virtual void fillScreen(uint16_t color);
lelect 0:3e9c32359703 58
lelect 2:66a3fe0dc83a 59 //These exist only with Adafruit_GFX (no subclass overrides)
lelect 3:3ffdf181555c 60 /** @fn void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
lelect 2:66a3fe0dc83a 61 * @bref draw a circle outline from the coordinates of the center.
lelect 2:66a3fe0dc83a 62 * @param x0 x position
lelect 2:66a3fe0dc83a 63 * @param y0 y position
lelect 2:66a3fe0dc83a 64 * @param r Radius of the circle
lelect 2:66a3fe0dc83a 65 * @param color 16bit color
lelect 2:66a3fe0dc83a 66 */
lelect 0:3e9c32359703 67 void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
lelect 0:3e9c32359703 68 void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color);
lelect 3:3ffdf181555c 69 /** @fn void Adafruit_GFX::fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
lelect 2:66a3fe0dc83a 70 * @bref draw a circle from the coordinates of the center.
lelect 2:66a3fe0dc83a 71 * @param x0 x position
lelect 2:66a3fe0dc83a 72 * @param y0 y position
lelect 2:66a3fe0dc83a 73 * @param r Radius of the circle
lelect 2:66a3fe0dc83a 74 * @param color 16bit color
lelect 2:66a3fe0dc83a 75 */
lelect 0:3e9c32359703 76 void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
lelect 0:3e9c32359703 77 void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color);
lelect 0:3e9c32359703 78
lelect 3:3ffdf181555c 79 /** @fn void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
lelect 2:66a3fe0dc83a 80 * @bref draw a triangle outline from the vertex with color.
lelect 2:66a3fe0dc83a 81 * @param x0 first vertex x
lelect 2:66a3fe0dc83a 82 * @param y0 first vertex y
lelect 2:66a3fe0dc83a 83 * @param x1 second vertex x
lelect 2:66a3fe0dc83a 84 * @param y1 second vertex y
lelect 2:66a3fe0dc83a 85 * @param x2 third vertex x
lelect 2:66a3fe0dc83a 86 * @param y2 third vertex y
lelect 2:66a3fe0dc83a 87 * @param color 16bit color
lelect 2:66a3fe0dc83a 88 */
lelect 0:3e9c32359703 89 void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
lelect 3:3ffdf181555c 90 /** @fn void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
lelect 2:66a3fe0dc83a 91 * @bref draw a triangle from the vertex with color.
lelect 2:66a3fe0dc83a 92 * @param x0 first vertex x
lelect 2:66a3fe0dc83a 93 * @param y0 first vertex y
lelect 2:66a3fe0dc83a 94 * @param x1 second vertex x
lelect 2:66a3fe0dc83a 95 * @param y1 second vertex y
lelect 2:66a3fe0dc83a 96 * @param x2 third vertex x
lelect 2:66a3fe0dc83a 97 * @param y2 third vertex y
lelect 2:66a3fe0dc83a 98 * @param color 16bit color
lelect 2:66a3fe0dc83a 99 */
lelect 0:3e9c32359703 100 void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
lelect 2:66a3fe0dc83a 101
lelect 3:3ffdf181555c 102 /** @fn void Adafruit_GFX::drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
lelect 2:66a3fe0dc83a 103 * @bref draw a round rectangle outline with color.
lelect 2:66a3fe0dc83a 104 * @param x0 first vertex x
lelect 2:66a3fe0dc83a 105 * @param y0 first vertex y
lelect 2:66a3fe0dc83a 106 * @param w width
lelect 2:66a3fe0dc83a 107 * @param h height
lelect 2:66a3fe0dc83a 108 * @param radius radius
lelect 2:66a3fe0dc83a 109 * @param color 16bit color
lelect 2:66a3fe0dc83a 110 */
lelect 0:3e9c32359703 111 void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
lelect 3:3ffdf181555c 112 /** @fn void Adafruit_GFX::drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
lelect 2:66a3fe0dc83a 113 * @bref draw a round rectangle with color.
lelect 2:66a3fe0dc83a 114 * @param x0 first vertex x
lelect 2:66a3fe0dc83a 115 * @param y0 first vertex y
lelect 2:66a3fe0dc83a 116 * @param w width
lelect 2:66a3fe0dc83a 117 * @param h height
lelect 2:66a3fe0dc83a 118 * @param radius radius
lelect 2:66a3fe0dc83a 119 * @param color 16bit color
lelect 2:66a3fe0dc83a 120 */
lelect 0:3e9c32359703 121 void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
lelect 0:3e9c32359703 122
lelect 0:3e9c32359703 123 void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);
lelect 2:66a3fe0dc83a 124
lelect 0:3e9c32359703 125 void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size);
lelect 0:3e9c32359703 126
lelect 0:3e9c32359703 127 void setCursor(int16_t x, int16_t y) {
lelect 0:3e9c32359703 128 cursor_x = x;
lelect 0:3e9c32359703 129 cursor_y = y;
lelect 0:3e9c32359703 130 };
lelect 2:66a3fe0dc83a 131
lelect 0:3e9c32359703 132 void setTextSize(uint8_t s) {
lelect 0:3e9c32359703 133 textsize = (s > 0) ? s : 1;
lelect 0:3e9c32359703 134 };
lelect 2:66a3fe0dc83a 135
lelect 0:3e9c32359703 136 void setTextColor(uint16_t c) {
lelect 0:3e9c32359703 137 textcolor = c;
lelect 0:3e9c32359703 138 textbgcolor = c;
lelect 0:3e9c32359703 139 }
lelect 0:3e9c32359703 140 void setTextColor(uint16_t c, uint16_t b) {
lelect 0:3e9c32359703 141 textcolor = c;
lelect 0:3e9c32359703 142 textbgcolor = b;
lelect 0:3e9c32359703 143 };
lelect 0:3e9c32359703 144 void setTextWrap(bool w) {
lelect 0:3e9c32359703 145 wrap = w;
lelect 0:3e9c32359703 146 };
lelect 0:3e9c32359703 147
lelect 0:3e9c32359703 148 virtual size_t writeChar(uint8_t);
lelect 0:3e9c32359703 149
lelect 0:3e9c32359703 150 int16_t height(void) {
lelect 0:3e9c32359703 151 return _height;
lelect 0:3e9c32359703 152 };
lelect 2:66a3fe0dc83a 153
lelect 0:3e9c32359703 154 int16_t width(void) {
lelect 0:3e9c32359703 155 return _width;
lelect 0:3e9c32359703 156 };
marcpl 4:ca74c390a0de 157 void setRotation(uint8_t r) {
marcpl 4:ca74c390a0de 158 rotation = r;
marcpl 4:ca74c390a0de 159 }
lelect 0:3e9c32359703 160
lelect 0:3e9c32359703 161 uint8_t getRotation(void) {
lelect 0:3e9c32359703 162 rotation%=4;
lelect 0:3e9c32359703 163 return rotation;
lelect 0:3e9c32359703 164 };
lelect 0:3e9c32359703 165
lelect 0:3e9c32359703 166 protected:
lelect 0:3e9c32359703 167 int16_t _rawWidth, _rawHeight; // Display w/h as modified by current rotation
lelect 0:3e9c32359703 168 int16_t _width, _height; // Display w/h as modified by current rotation
lelect 0:3e9c32359703 169 int16_t cursor_x, cursor_y;
lelect 0:3e9c32359703 170 uint16_t textcolor, textbgcolor;
lelect 0:3e9c32359703 171 uint8_t textsize,rotation;
lelect 0:3e9c32359703 172 bool wrap; // If set, 'wrap' text at right edge of display
lelect 0:3e9c32359703 173 };
lelect 0:3e9c32359703 174
lelect 0:3e9c32359703 175 #endif // _ADAFRUIT_GFX_H