added the WANT_ABSTRACTS define so the library works with text sizes greater than 1
Fork of Adafruit_GFX by
Adafruit_GFX.h
00001 /*********************************** 00002 This is a our graphics core library, for all our displays. 00003 We'll be adapting all the 00004 existing libaries to use this core to make updating, support 00005 and upgrading easier! 00006 00007 Adafruit invests time and resources providing this open source code, 00008 please support Adafruit and open-source hardware by purchasing 00009 products from Adafruit! 00010 00011 Written by Limor Fried/Ladyada for Adafruit Industries. 00012 BSD license, check license.txt for more information 00013 All text above must be included in any redistribution 00014 ****************************************/ 00015 00016 /* 00017 * Modified by Neal Horman 7/14/2012 for use in LPC1768 00018 */ 00019 00020 #ifndef _ADAFRUIT_GFX_H_ 00021 #define _ADAFRUIT_GFX_H_ 00022 00023 static inline void swap(int16_t &a, int16_t &b) 00024 { 00025 int16_t t = a; 00026 00027 a = b; 00028 b = t; 00029 } 00030 00031 #ifndef _BV 00032 #define _BV(bit) (1<<(bit)) 00033 #endif 00034 00035 #define BLACK 0 00036 #define WHITE 1 00037 00038 // The WANT_AVSTRACTS define allows text sizes other than 1 to be selected 00039 #define WANT_ABSTRACTS 00040 00041 class Adafruit_GFX : public Stream 00042 { 00043 public: 00044 Adafruit_GFX(int16_t w, int16_t h) 00045 : _rawWidth(w) 00046 , _rawHeight(h) 00047 , _width(w) 00048 , _height(h) 00049 , cursor_x(0) 00050 , cursor_y(0) 00051 , textcolor(WHITE) 00052 , textbgcolor(BLACK) 00053 , textsize(1) 00054 , rotation(0) 00055 , wrap(true) 00056 {}; 00057 00058 // this must be defined by the subclass 00059 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; 00060 // this is optional 00061 virtual void invertDisplay(bool i) {}; 00062 00063 // Stream implementation - provides printf() interface 00064 // You would otherwise be forced to use writeChar() 00065 virtual int _putc(int value) { return writeChar(value); }; 00066 virtual int _getc() { return -1; }; 00067 00068 #ifdef WANT_ABSTRACTS 00069 // these are 'generic' drawing functions, so we can share them! 00070 virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); 00071 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 00072 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 00073 virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 00074 virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 00075 virtual void fillScreen(uint16_t color); 00076 00077 void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); 00078 void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color); 00079 void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); 00080 void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color); 00081 00082 void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); 00083 void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); 00084 void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); 00085 void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); 00086 #endif 00087 00088 void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color); 00089 void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size); 00090 size_t writeChar(uint8_t); 00091 00092 int16_t width(void) { return _width; }; 00093 int16_t height(void) { return _height; }; 00094 00095 void setCursor(int16_t x, int16_t y) { cursor_x = x; cursor_y = y; }; 00096 void setTextSize(uint8_t s) { textsize = (s > 0) ? s : 1; }; 00097 void setTextColor(uint16_t c) { textcolor = c; textbgcolor = c; } 00098 void setTextColor(uint16_t c, uint16_t b) { textcolor = c; textbgcolor = b; }; 00099 void setTextWrap(bool w) { wrap = w; }; 00100 00101 void setRotation(uint8_t r); 00102 uint8_t getRotation(void) { rotation %= 4; return rotation; }; 00103 00104 protected: 00105 int16_t _rawWidth, _rawHeight; // this is the 'raw' display w/h - never changes 00106 int16_t _width, _height; // dependent on rotation 00107 int16_t cursor_x, cursor_y; 00108 uint16_t textcolor, textbgcolor; 00109 uint8_t textsize; 00110 uint8_t rotation; 00111 bool wrap; // If set, 'wrap' text at right edge of display 00112 }; 00113 00114 #endif
Generated on Thu Jul 14 2022 05:30:13 by
1.7.2
