Junichi Katsu
/
BLE_MPU6050_test6_challenge_sb
テスト用です。
Adafruit_LEDBackpack/Adafruit_GFX.h@0:8468a4403fea, 2016-10-11 (annotated)
- Committer:
- jksoft
- Date:
- Tue Oct 11 11:09:42 2016 +0000
- Revision:
- 0:8468a4403fea
SB??ver;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:8468a4403fea | 1 | /*********************************** |
jksoft | 0:8468a4403fea | 2 | This is a our graphics core library, for all our displays. |
jksoft | 0:8468a4403fea | 3 | We'll be adapting all the |
jksoft | 0:8468a4403fea | 4 | existing libaries to use this core to make updating, support |
jksoft | 0:8468a4403fea | 5 | and upgrading easier! |
jksoft | 0:8468a4403fea | 6 | |
jksoft | 0:8468a4403fea | 7 | Adafruit invests time and resources providing this open source code, |
jksoft | 0:8468a4403fea | 8 | please support Adafruit and open-source hardware by purchasing |
jksoft | 0:8468a4403fea | 9 | products from Adafruit! |
jksoft | 0:8468a4403fea | 10 | |
jksoft | 0:8468a4403fea | 11 | Written by Limor Fried/Ladyada for Adafruit Industries. |
jksoft | 0:8468a4403fea | 12 | BSD license, check license.txt for more information |
jksoft | 0:8468a4403fea | 13 | All text above must be included in any redistribution |
jksoft | 0:8468a4403fea | 14 | ****************************************/ |
jksoft | 0:8468a4403fea | 15 | |
jksoft | 0:8468a4403fea | 16 | /* |
jksoft | 0:8468a4403fea | 17 | * Modified by Neal Horman 7/14/2012 for use in LPC1768 |
jksoft | 0:8468a4403fea | 18 | */ |
jksoft | 0:8468a4403fea | 19 | |
jksoft | 0:8468a4403fea | 20 | #ifndef _ADAFRUIT_GFX_H_ |
jksoft | 0:8468a4403fea | 21 | #define _ADAFRUIT_GFX_H_ |
jksoft | 0:8468a4403fea | 22 | |
jksoft | 0:8468a4403fea | 23 | static inline void swap(int16_t &a, int16_t &b) |
jksoft | 0:8468a4403fea | 24 | { |
jksoft | 0:8468a4403fea | 25 | int16_t t = a; |
jksoft | 0:8468a4403fea | 26 | |
jksoft | 0:8468a4403fea | 27 | a = b; |
jksoft | 0:8468a4403fea | 28 | b = t; |
jksoft | 0:8468a4403fea | 29 | } |
jksoft | 0:8468a4403fea | 30 | |
jksoft | 0:8468a4403fea | 31 | #ifndef _BV |
jksoft | 0:8468a4403fea | 32 | #define _BV(bit) (1<<(bit)) |
jksoft | 0:8468a4403fea | 33 | #endif |
jksoft | 0:8468a4403fea | 34 | |
jksoft | 0:8468a4403fea | 35 | #define BLACK 0 |
jksoft | 0:8468a4403fea | 36 | #define WHITE 1 |
jksoft | 0:8468a4403fea | 37 | |
jksoft | 0:8468a4403fea | 38 | class Adafruit_GFX : public Stream |
jksoft | 0:8468a4403fea | 39 | { |
jksoft | 0:8468a4403fea | 40 | public: |
jksoft | 0:8468a4403fea | 41 | Adafruit_GFX(int16_t w, int16_t h) |
jksoft | 0:8468a4403fea | 42 | : _rawWidth(w) |
jksoft | 0:8468a4403fea | 43 | , _rawHeight(h) |
jksoft | 0:8468a4403fea | 44 | , _width(w) |
jksoft | 0:8468a4403fea | 45 | , _height(h) |
jksoft | 0:8468a4403fea | 46 | , cursor_x(0) |
jksoft | 0:8468a4403fea | 47 | , cursor_y(0) |
jksoft | 0:8468a4403fea | 48 | , textcolor(WHITE) |
jksoft | 0:8468a4403fea | 49 | , textbgcolor(BLACK) |
jksoft | 0:8468a4403fea | 50 | , textsize(1) |
jksoft | 0:8468a4403fea | 51 | , rotation(0) |
jksoft | 0:8468a4403fea | 52 | , wrap(true) |
jksoft | 0:8468a4403fea | 53 | {}; |
jksoft | 0:8468a4403fea | 54 | |
jksoft | 0:8468a4403fea | 55 | // this must be defined by the subclass |
jksoft | 0:8468a4403fea | 56 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; |
jksoft | 0:8468a4403fea | 57 | // this is optional |
jksoft | 0:8468a4403fea | 58 | virtual void invertDisplay(bool i) {}; |
jksoft | 0:8468a4403fea | 59 | |
jksoft | 0:8468a4403fea | 60 | // Stream implementation - provides printf() interface |
jksoft | 0:8468a4403fea | 61 | // You would otherwise be forced to use writeChar() |
jksoft | 0:8468a4403fea | 62 | virtual int _putc(int value) { return writeChar(value); }; |
jksoft | 0:8468a4403fea | 63 | virtual int _getc() { return -1; }; |
jksoft | 0:8468a4403fea | 64 | |
jksoft | 0:8468a4403fea | 65 | #ifdef WANT_ABSTRACTS |
jksoft | 0:8468a4403fea | 66 | // these are 'generic' drawing functions, so we can share them! |
jksoft | 0:8468a4403fea | 67 | virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); |
jksoft | 0:8468a4403fea | 68 | virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); |
jksoft | 0:8468a4403fea | 69 | virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); |
jksoft | 0:8468a4403fea | 70 | virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); |
jksoft | 0:8468a4403fea | 71 | virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); |
jksoft | 0:8468a4403fea | 72 | virtual void fillScreen(uint16_t color); |
jksoft | 0:8468a4403fea | 73 | |
jksoft | 0:8468a4403fea | 74 | void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); |
jksoft | 0:8468a4403fea | 75 | void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color); |
jksoft | 0:8468a4403fea | 76 | void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); |
jksoft | 0:8468a4403fea | 77 | void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color); |
jksoft | 0:8468a4403fea | 78 | |
jksoft | 0:8468a4403fea | 79 | void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); |
jksoft | 0:8468a4403fea | 80 | void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); |
jksoft | 0:8468a4403fea | 81 | void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); |
jksoft | 0:8468a4403fea | 82 | void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); |
jksoft | 0:8468a4403fea | 83 | #endif |
jksoft | 0:8468a4403fea | 84 | |
jksoft | 0:8468a4403fea | 85 | void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color); |
jksoft | 0:8468a4403fea | 86 | void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size); |
jksoft | 0:8468a4403fea | 87 | size_t writeChar(uint8_t); |
jksoft | 0:8468a4403fea | 88 | |
jksoft | 0:8468a4403fea | 89 | int16_t width(void) { return _width; }; |
jksoft | 0:8468a4403fea | 90 | int16_t height(void) { return _height; }; |
jksoft | 0:8468a4403fea | 91 | |
jksoft | 0:8468a4403fea | 92 | void setCursor(int16_t x, int16_t y) { cursor_x = x; cursor_y = y; }; |
jksoft | 0:8468a4403fea | 93 | void setTextSize(uint8_t s) { textsize = (s > 0) ? s : 1; }; |
jksoft | 0:8468a4403fea | 94 | void setTextColor(uint16_t c) { textcolor = c; textbgcolor = c; } |
jksoft | 0:8468a4403fea | 95 | void setTextColor(uint16_t c, uint16_t b) { textcolor = c; textbgcolor = b; }; |
jksoft | 0:8468a4403fea | 96 | void setTextWrap(bool w) { wrap = w; }; |
jksoft | 0:8468a4403fea | 97 | |
jksoft | 0:8468a4403fea | 98 | void setRotation(uint8_t r); |
jksoft | 0:8468a4403fea | 99 | uint8_t getRotation(void) { rotation %= 4; return rotation; }; |
jksoft | 0:8468a4403fea | 100 | |
jksoft | 0:8468a4403fea | 101 | protected: |
jksoft | 0:8468a4403fea | 102 | int16_t _rawWidth, _rawHeight; // this is the 'raw' display w/h - never changes |
jksoft | 0:8468a4403fea | 103 | int16_t _width, _height; // dependent on rotation |
jksoft | 0:8468a4403fea | 104 | int16_t cursor_x, cursor_y; |
jksoft | 0:8468a4403fea | 105 | uint16_t textcolor, textbgcolor; |
jksoft | 0:8468a4403fea | 106 | uint8_t textsize; |
jksoft | 0:8468a4403fea | 107 | uint8_t rotation; |
jksoft | 0:8468a4403fea | 108 | bool wrap; // If set, 'wrap' text at right edge of display |
jksoft | 0:8468a4403fea | 109 | }; |
jksoft | 0:8468a4403fea | 110 | |
jksoft | 0:8468a4403fea | 111 | #endif |