Adafruit-GFX porting for mbed
Dependents: RGB_matrix_Panel RGB_matrix_Panel_modif RGB_matrix_Panel Pmod_OLEDrgb_ALS1_K64F ... more
Adafruit_GFX.h
- Committer:
- lelect
- Date:
- 2014-05-23
- Revision:
- 0:3e9c32359703
- Child:
- 1:c2715acb7466
File content as of revision 0:3e9c32359703:
#ifndef _ADAFRUIT_GFX_H #define _ADAFRUIT_GFX_H #define BLACK 0 #define WHITE 1 #ifndef _BV #define _BV(bit) (1<<(bit)) #endif #define swap(a, b) { int16_t t = a; a = b; b = t; } class Adafruit_GFX : public Stream { public: Adafruit_GFX(int16_t w, int16_t h) : _rawWidth(w) , _rawHeight(h) , _width(w) , _height(h) , cursor_x(0) , cursor_y(0) , textcolor(WHITE) , textbgcolor(BLACK) , textsize(1) , rotation(0) , wrap(true) {}; // Constructor // This MUST be defined by the subclass: virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; virtual int _putc(int value) { return writeChar(value); }; virtual int _getc() { return -1; }; virtual void invertDisplay(bool i); // These MAY be overridden by the subclass to provide device-specific // optimized code. Otherwise 'generic' versions are used. virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); virtual void fillScreen(uint16_t color); // These exist only with Adafruit_GFX (no subclass overrides) void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color); void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color); void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color); void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size); void setCursor(int16_t x, int16_t y) { cursor_x = x; cursor_y = y; }; void setTextSize(uint8_t s) { textsize = (s > 0) ? s : 1; }; void setTextColor(uint16_t c) { textcolor = c; textbgcolor = c; } void setTextColor(uint16_t c, uint16_t b) { textcolor = c; textbgcolor = b; }; void setTextWrap(bool w) { wrap = w; }; virtual size_t writeChar(uint8_t); int16_t height(void) { return _height; }; int16_t width(void) { return _width; }; void setRotation(uint8_t r); uint8_t getRotation(void) { rotation%=4; return rotation; }; protected: int16_t _rawWidth, _rawHeight; // Display w/h as modified by current rotation int16_t _width, _height; // Display w/h as modified by current rotation int16_t cursor_x, cursor_y; uint16_t textcolor, textbgcolor; uint8_t textsize,rotation; bool wrap; // If set, 'wrap' text at right edge of display }; #endif // _ADAFRUIT_GFX_H