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