うおーるぼっとLEDのワークショップ用

Dependencies:   mbed

Committer:
jksoft
Date:
Fri Feb 03 06:26:54 2017 +0000
Revision:
0:9fcc79b3f00e
??

Who changed what in which revision?

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