![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Please run it on your NUCLEO-L152
MCUFRIEND_kbv/MCUFRIEND_kbv.h@1:d88d2ad55fac, 2019-09-18 (annotated)
- Committer:
- davidprentice
- Date:
- Wed Sep 18 10:38:19 2019 +0000
- Revision:
- 1:d88d2ad55fac
- Parent:
- 0:b608c7f02f80
Added messages to Serial Terminal (9600 baud)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
davidprentice | 0:b608c7f02f80 | 1 | /* |
davidprentice | 0:b608c7f02f80 | 2 | * MCUFRIEND_kbv class inherits from Adafruit_GFX class and the Arduino Print class. |
davidprentice | 0:b608c7f02f80 | 3 | * Any use of MCUFRIEND_kbv class and examples is dependent on Adafruit and Arduino licenses |
davidprentice | 0:b608c7f02f80 | 4 | * The license texts are in the accompanying license.txt file |
davidprentice | 0:b608c7f02f80 | 5 | */ |
davidprentice | 0:b608c7f02f80 | 6 | |
davidprentice | 0:b608c7f02f80 | 7 | #ifndef MCUFRIEND_KBV_H_ |
davidprentice | 0:b608c7f02f80 | 8 | #define MCUFRIEND_KBV_H_ 299 |
davidprentice | 0:b608c7f02f80 | 9 | |
davidprentice | 0:b608c7f02f80 | 10 | //#define USE_SERIAL |
davidprentice | 0:b608c7f02f80 | 11 | |
davidprentice | 0:b608c7f02f80 | 12 | #if ARDUINO < 101 |
davidprentice | 0:b608c7f02f80 | 13 | #define USE_GFX_KBV |
davidprentice | 0:b608c7f02f80 | 14 | #include "ADA_GFX_kbv.h" |
davidprentice | 0:b608c7f02f80 | 15 | #else |
davidprentice | 0:b608c7f02f80 | 16 | #include "Adafruit_GFX.h" |
davidprentice | 0:b608c7f02f80 | 17 | #endif |
davidprentice | 0:b608c7f02f80 | 18 | |
davidprentice | 0:b608c7f02f80 | 19 | class MCUFRIEND_kbv : public Adafruit_GFX { |
davidprentice | 0:b608c7f02f80 | 20 | |
davidprentice | 0:b608c7f02f80 | 21 | public: |
davidprentice | 0:b608c7f02f80 | 22 | // MCUFRIEND_kbv(int CS=A3, int RS=A2, int WR=A1, int RD=A0, int RST=A4); //shield wiring |
davidprentice | 0:b608c7f02f80 | 23 | MCUFRIEND_kbv(int CS=0, int RS=0, int WR=0, int RD=0, int _RST=0); //dummy arguments |
davidprentice | 0:b608c7f02f80 | 24 | void reset(void); // you only need the constructor |
davidprentice | 0:b608c7f02f80 | 25 | void begin(uint16_t ID = 0x9341); // you only need the constructor |
davidprentice | 0:b608c7f02f80 | 26 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color); // and these three |
davidprentice | 0:b608c7f02f80 | 27 | void WriteCmdData(uint16_t cmd, uint16_t dat); // ?public methods !!! |
davidprentice | 0:b608c7f02f80 | 28 | void pushCommand(uint16_t cmd, uint8_t * block, int8_t N); |
davidprentice | 0:b608c7f02f80 | 29 | uint16_t color565(uint8_t r, uint8_t g, uint8_t b) { return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3); } |
davidprentice | 0:b608c7f02f80 | 30 | uint16_t readID(void); |
davidprentice | 0:b608c7f02f80 | 31 | virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); |
davidprentice | 0:b608c7f02f80 | 32 | virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) { fillRect(x, y, 1, h, color); } |
davidprentice | 0:b608c7f02f80 | 33 | virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) { fillRect(x, y, w, 1, color); } |
davidprentice | 0:b608c7f02f80 | 34 | virtual void fillScreen(uint16_t color) { fillRect(0, 0, _width, _height, color); } |
davidprentice | 0:b608c7f02f80 | 35 | virtual void setRotation(uint8_t r); |
davidprentice | 0:b608c7f02f80 | 36 | virtual void invertDisplay(boolean i); |
davidprentice | 0:b608c7f02f80 | 37 | |
davidprentice | 0:b608c7f02f80 | 38 | uint16_t readReg(uint16_t reg, int8_t index=0); |
davidprentice | 0:b608c7f02f80 | 39 | int16_t readGRAM(int16_t x, int16_t y, uint16_t *block, int16_t w, int16_t h); |
davidprentice | 0:b608c7f02f80 | 40 | uint16_t readPixel(int16_t x, int16_t y) { uint16_t color; readGRAM(x, y, &color, 1, 1); return color; } |
davidprentice | 0:b608c7f02f80 | 41 | void setAddrWindow(int16_t x, int16_t y, int16_t x1, int16_t y1); |
davidprentice | 0:b608c7f02f80 | 42 | void pushColors(uint16_t *block, int16_t n, bool first); |
davidprentice | 0:b608c7f02f80 | 43 | void pushColors(uint8_t *block, int16_t n, bool first); |
davidprentice | 0:b608c7f02f80 | 44 | void pushColors(const uint8_t *block, int16_t n, bool first, bool bigend = false); |
davidprentice | 0:b608c7f02f80 | 45 | void vertScroll(int16_t top, int16_t scrollines, int16_t offset); |
davidprentice | 0:b608c7f02f80 | 46 | |
davidprentice | 0:b608c7f02f80 | 47 | protected: |
davidprentice | 0:b608c7f02f80 | 48 | uint32_t readReg32(uint16_t reg); |
davidprentice | 0:b608c7f02f80 | 49 | uint32_t readReg40(uint16_t reg); |
davidprentice | 0:b608c7f02f80 | 50 | uint16_t _lcd_xor, _lcd_capable; |
davidprentice | 0:b608c7f02f80 | 51 | |
davidprentice | 0:b608c7f02f80 | 52 | private: |
davidprentice | 0:b608c7f02f80 | 53 | uint16_t _lcd_ID, _lcd_rev, _lcd_madctl, _lcd_drivOut, _MC, _MP, _MW, _SC, _EC, _SP, _EP; |
davidprentice | 0:b608c7f02f80 | 54 | }; |
davidprentice | 0:b608c7f02f80 | 55 | |
davidprentice | 0:b608c7f02f80 | 56 | // New color definitions. thanks to Bodmer |
davidprentice | 0:b608c7f02f80 | 57 | #define TFT_BLACK 0x0000 /* 0, 0, 0 */ |
davidprentice | 0:b608c7f02f80 | 58 | #define TFT_NAVY 0x000F /* 0, 0, 128 */ |
davidprentice | 0:b608c7f02f80 | 59 | #define TFT_DARKGREEN 0x03E0 /* 0, 128, 0 */ |
davidprentice | 0:b608c7f02f80 | 60 | #define TFT_DARKCYAN 0x03EF /* 0, 128, 128 */ |
davidprentice | 0:b608c7f02f80 | 61 | #define TFT_MAROON 0x7800 /* 128, 0, 0 */ |
davidprentice | 0:b608c7f02f80 | 62 | #define TFT_PURPLE 0x780F /* 128, 0, 128 */ |
davidprentice | 0:b608c7f02f80 | 63 | #define TFT_OLIVE 0x7BE0 /* 128, 128, 0 */ |
davidprentice | 0:b608c7f02f80 | 64 | #define TFT_LIGHTGREY 0xC618 /* 192, 192, 192 */ |
davidprentice | 0:b608c7f02f80 | 65 | #define TFT_DARKGREY 0x7BEF /* 128, 128, 128 */ |
davidprentice | 0:b608c7f02f80 | 66 | #define TFT_BLUE 0x001F /* 0, 0, 255 */ |
davidprentice | 0:b608c7f02f80 | 67 | #define TFT_GREEN 0x07E0 /* 0, 255, 0 */ |
davidprentice | 0:b608c7f02f80 | 68 | #define TFT_CYAN 0x07FF /* 0, 255, 255 */ |
davidprentice | 0:b608c7f02f80 | 69 | #define TFT_RED 0xF800 /* 255, 0, 0 */ |
davidprentice | 0:b608c7f02f80 | 70 | #define TFT_MAGENTA 0xF81F /* 255, 0, 255 */ |
davidprentice | 0:b608c7f02f80 | 71 | #define TFT_YELLOW 0xFFE0 /* 255, 255, 0 */ |
davidprentice | 0:b608c7f02f80 | 72 | #define TFT_WHITE 0xFFFF /* 255, 255, 255 */ |
davidprentice | 0:b608c7f02f80 | 73 | #define TFT_ORANGE 0xFDA0 /* 255, 180, 0 */ |
davidprentice | 0:b608c7f02f80 | 74 | #define TFT_GREENYELLOW 0xB7E0 /* 180, 255, 0 */ |
davidprentice | 0:b608c7f02f80 | 75 | #define TFT_PINK 0xFC9F |
davidprentice | 0:b608c7f02f80 | 76 | |
davidprentice | 0:b608c7f02f80 | 77 | #endif |