Adafruit HX8357 Arduino Library
Adafruit_HX8357.h
Go to the documentation of this file.
1 
31 #ifndef _ADAFRUIT_HX8357_H
32 #define _ADAFRUIT_HX8357_H
33 
34 #include <Adafruit_SPITFT.h>
35 
36 #define HX8357D 0xD
37 #define HX8357B 0xB
38 
39 #define HX8357_TFTWIDTH 320
40 #define HX8357_TFTHEIGHT 480
41 
42 #define HX8357_NOP 0x00
43 #define HX8357_SWRESET 0x01
44 #define HX8357_RDDID 0x04
45 #define HX8357_RDDST 0x09
46 
47 #define HX8357_RDPOWMODE 0x0A
48 #define HX8357_RDMADCTL 0x0B
49 #define HX8357_RDCOLMOD 0x0C
50 #define HX8357_RDDIM 0x0D
51 #define HX8357_RDDSDR 0x0F
52 
53 #define HX8357_SLPIN 0x10
54 #define HX8357_SLPOUT 0x11
55 #define HX8357B_PTLON 0x12
56 #define HX8357B_NORON 0x13
57 
58 #define HX8357_INVOFF 0x20
59 #define HX8357_INVON 0x21
60 #define HX8357_DISPOFF 0x28
61 #define HX8357_DISPON 0x29
62 
63 #define HX8357_CASET 0x2A
64 #define HX8357_PASET 0x2B
65 #define HX8357_RAMWR 0x2C
66 #define HX8357_RAMRD 0x2E
67 
68 #define HX8357B_PTLAR 0x30
69 #define HX8357_TEON 0x35
70 #define HX8357_TEARLINE 0x44
71 #define HX8357_MADCTL 0x36
72 #define HX8357_COLMOD 0x3A
73 
74 #define HX8357_SETOSC 0xB0
75 #define HX8357_SETPWR1 0xB1
76 #define HX8357B_SETDISPLAY 0xB2
77 #define HX8357_SETRGB 0xB3
78 #define HX8357D_SETCOM 0xB6
79 
80 #define HX8357B_SETDISPMODE 0xB4
81 #define HX8357D_SETCYC 0xB4
82 #define HX8357B_SETOTP 0xB7
83 #define HX8357D_SETC 0xB9
84 
85 #define HX8357B_SET_PANEL_DRIVING 0xC0
86 #define HX8357D_SETSTBA 0xC0
87 #define HX8357B_SETDGC 0xC1
88 #define HX8357B_SETID 0xC3
89 #define HX8357B_SETDDB 0xC4
90 #define HX8357B_SETDISPLAYFRAME 0xC5
91 #define HX8357B_GAMMASET 0xC8
92 #define HX8357B_SETCABC 0xC9
93 #define HX8357_SETPANEL 0xCC
94 
95 #define HX8357B_SETPOWER 0xD0
96 #define HX8357B_SETVCOM 0xD1
97 #define HX8357B_SETPWRNORMAL 0xD2
98 
99 #define HX8357B_RDID1 0xDA
100 #define HX8357B_RDID2 0xDB
101 #define HX8357B_RDID3 0xDC
102 #define HX8357B_RDID4 0xDD
103 
104 #define HX8357D_SETGAMMA 0xE0
105 
106 #define HX8357B_SETGAMMA 0xC8
107 #define HX8357B_SETPANELRELATED 0xE9
108 
109 // Plan is to move this to GFX header (with different prefix), though
110 // defines will be kept here for existing code that might be referencing
111 // them. Some additional ones are in the ILI9341 lib -- add all in GFX!
112 // Color definitions
113 #define HX8357_BLACK 0x0000
114 #define HX8357_BLUE 0x001F
115 #define HX8357_RED 0xF800
116 #define HX8357_GREEN 0x07E0
117 #define HX8357_CYAN 0x07FF
118 #define HX8357_MAGENTA 0xF81F
119 #define HX8357_YELLOW 0xFFE0
120 #define HX8357_WHITE 0xFFFF
121 
122 
125 class Adafruit_HX8357 : public Adafruit_SPITFT {
126 public:
127  Adafruit_HX8357(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK,
128  int8_t _RST, int8_t _MISO, uint8_t type = HX8357D);
129  Adafruit_HX8357(int8_t _CS, int8_t _DC, int8_t _RST = -1,
130  uint8_t type = HX8357D);
131 #if !defined(ESP8266)
132  Adafruit_HX8357(SPIClass *spi, int8_t _CS, int8_t _DC, int8_t _RST = -1,
133  uint8_t type = HX8357D);
134 #endif // end !ESP8266
135  Adafruit_HX8357(tftBusWidth busWidth, int8_t d0, int8_t wr, int8_t dc,
136  int8_t cs = -1, int8_t rst = -1, int8_t rd = -1);
137  ~Adafruit_HX8357(void);
138 
139  void begin(uint32_t freq = 0), setRotation(uint8_t r),
140  invertDisplay(boolean i),
141  setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
142 
143 private:
144  uint8_t displayType; // HX8357D vs HX8357B
145 };
146 
147 #endif // _ADAFRUIT_HX8357_H
void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Set the "address window" - the rectangle we will write to graphics RAM with the next chunk of SPI dat...
Definition: Adafruit_HX8357.cpp:469
void begin(uint32_t freq=0)
Initialize HX8357 chip. Connects to the HX8357 over SPI and sends initialization commands.
Definition: Adafruit_HX8357.cpp:364
void invertDisplay(boolean i)
Enable/Disable display color inversion.
Definition: Adafruit_HX8357.cpp:451
Adafruit_HX8357(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK, int8_t _RST, int8_t _MISO, uint8_t type=HX8357D)
Constructor for Adafruit_HX8357 displays, using software (bitbang) SPI.
Definition: Adafruit_HX8357.cpp:93
Class to manage hardware interface with HX8357 chipset.
Definition: Adafruit_HX8357.h:125
void setRotation(uint8_t r)
Set origin of (0,0) and orientation of TFT display.
Definition: Adafruit_HX8357.cpp:417
~Adafruit_HX8357(void)
Destructor for Adafruit_HX8357 object.
Definition: Adafruit_HX8357.cpp:165
#define HX8357D
Our internal const for D type.
Definition: Adafruit_HX8357.h:36