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:
lelect
Date:
Fri May 23 15:05:48 2014 +0000
Revision:
0:3e9c32359703
Child:
1:c2715acb7466
Initial Commit; No compile error

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 0:3e9c32359703 3 #define BLACK 0
lelect 0:3e9c32359703 4 #define WHITE 1
lelect 0:3e9c32359703 5 #ifndef _BV
lelect 0:3e9c32359703 6 #define _BV(bit) (1<<(bit))
lelect 0:3e9c32359703 7 #endif
lelect 0:3e9c32359703 8
lelect 0:3e9c32359703 9 #define swap(a, b) { int16_t t = a; a = b; b = t; }
lelect 0:3e9c32359703 10
lelect 0:3e9c32359703 11 class Adafruit_GFX : public Stream
lelect 0:3e9c32359703 12 {
lelect 0:3e9c32359703 13
lelect 0:3e9c32359703 14 public:
lelect 0:3e9c32359703 15 Adafruit_GFX(int16_t w, int16_t h)
lelect 0:3e9c32359703 16 : _rawWidth(w)
lelect 0:3e9c32359703 17 , _rawHeight(h)
lelect 0:3e9c32359703 18 , _width(w)
lelect 0:3e9c32359703 19 , _height(h)
lelect 0:3e9c32359703 20 , cursor_x(0)
lelect 0:3e9c32359703 21 , cursor_y(0)
lelect 0:3e9c32359703 22 , textcolor(WHITE)
lelect 0:3e9c32359703 23 , textbgcolor(BLACK)
lelect 0:3e9c32359703 24 , textsize(1)
lelect 0:3e9c32359703 25 , rotation(0)
lelect 0:3e9c32359703 26 , wrap(true)
lelect 0:3e9c32359703 27 {}; // Constructor
lelect 0:3e9c32359703 28
lelect 0:3e9c32359703 29 // This MUST be defined by the subclass:
lelect 0:3e9c32359703 30 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
lelect 0:3e9c32359703 31
lelect 0:3e9c32359703 32 virtual int _putc(int value) {
lelect 0:3e9c32359703 33 return writeChar(value);
lelect 0:3e9c32359703 34 };
lelect 0:3e9c32359703 35 virtual int _getc() {
lelect 0:3e9c32359703 36 return -1;
lelect 0:3e9c32359703 37 };
lelect 0:3e9c32359703 38
lelect 0:3e9c32359703 39 virtual void invertDisplay(bool i);
lelect 0:3e9c32359703 40
lelect 0:3e9c32359703 41 // These MAY be overridden by the subclass to provide device-specific
lelect 0:3e9c32359703 42 // optimized code. Otherwise 'generic' versions are used.
lelect 0:3e9c32359703 43 virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
lelect 0:3e9c32359703 44 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
lelect 0:3e9c32359703 45 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
lelect 0:3e9c32359703 46 virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
lelect 0:3e9c32359703 47 virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
lelect 0:3e9c32359703 48 virtual void fillScreen(uint16_t color);
lelect 0:3e9c32359703 49
lelect 0:3e9c32359703 50 // These exist only with Adafruit_GFX (no subclass overrides)
lelect 0:3e9c32359703 51 void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
lelect 0:3e9c32359703 52 void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color);
lelect 0:3e9c32359703 53 void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
lelect 0:3e9c32359703 54 void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color);
lelect 0:3e9c32359703 55
lelect 0:3e9c32359703 56 void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
lelect 0:3e9c32359703 57 void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
lelect 0:3e9c32359703 58 void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
lelect 0:3e9c32359703 59 void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
lelect 0:3e9c32359703 60
lelect 0:3e9c32359703 61 void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);
lelect 0:3e9c32359703 62 void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size);
lelect 0:3e9c32359703 63
lelect 0:3e9c32359703 64 void setCursor(int16_t x, int16_t y) {
lelect 0:3e9c32359703 65 cursor_x = x;
lelect 0:3e9c32359703 66 cursor_y = y;
lelect 0:3e9c32359703 67 };
lelect 0:3e9c32359703 68 void setTextSize(uint8_t s) {
lelect 0:3e9c32359703 69 textsize = (s > 0) ? s : 1;
lelect 0:3e9c32359703 70 };
lelect 0:3e9c32359703 71 void setTextColor(uint16_t c) {
lelect 0:3e9c32359703 72 textcolor = c;
lelect 0:3e9c32359703 73 textbgcolor = c;
lelect 0:3e9c32359703 74 }
lelect 0:3e9c32359703 75 void setTextColor(uint16_t c, uint16_t b) {
lelect 0:3e9c32359703 76 textcolor = c;
lelect 0:3e9c32359703 77 textbgcolor = b;
lelect 0:3e9c32359703 78 };
lelect 0:3e9c32359703 79 void setTextWrap(bool w) {
lelect 0:3e9c32359703 80 wrap = w;
lelect 0:3e9c32359703 81 };
lelect 0:3e9c32359703 82
lelect 0:3e9c32359703 83 virtual size_t writeChar(uint8_t);
lelect 0:3e9c32359703 84
lelect 0:3e9c32359703 85 int16_t height(void) {
lelect 0:3e9c32359703 86 return _height;
lelect 0:3e9c32359703 87 };
lelect 0:3e9c32359703 88 int16_t width(void) {
lelect 0:3e9c32359703 89 return _width;
lelect 0:3e9c32359703 90 };
lelect 0:3e9c32359703 91
lelect 0:3e9c32359703 92 void setRotation(uint8_t r);
lelect 0:3e9c32359703 93 uint8_t getRotation(void) {
lelect 0:3e9c32359703 94 rotation%=4;
lelect 0:3e9c32359703 95 return rotation;
lelect 0:3e9c32359703 96 };
lelect 0:3e9c32359703 97
lelect 0:3e9c32359703 98 protected:
lelect 0:3e9c32359703 99 int16_t _rawWidth, _rawHeight; // Display w/h as modified by current rotation
lelect 0:3e9c32359703 100 int16_t _width, _height; // Display w/h as modified by current rotation
lelect 0:3e9c32359703 101 int16_t cursor_x, cursor_y;
lelect 0:3e9c32359703 102 uint16_t textcolor, textbgcolor;
lelect 0:3e9c32359703 103 uint8_t textsize,rotation;
lelect 0:3e9c32359703 104 bool wrap; // If set, 'wrap' text at right edge of display
lelect 0:3e9c32359703 105 };
lelect 0:3e9c32359703 106
lelect 0:3e9c32359703 107 #endif // _ADAFRUIT_GFX_H