Adafruit ILI9341 Display Library
Adafruit_ILI9341.h
Go to the documentation of this file.
1 
36 #ifndef _ADAFRUIT_ILI9341H_
37 #define _ADAFRUIT_ILI9341H_
38 
39 #include "Adafruit_GFX.h"
40 #include "Arduino.h"
41 #include "Print.h"
42 #include <Adafruit_SPITFT.h>
43 #include <SPI.h>
44 
45 #define ILI9341_TFTWIDTH 240
46 #define ILI9341_TFTHEIGHT 320
47 
48 #define ILI9341_NOP 0x00
49 #define ILI9341_SWRESET 0x01
50 #define ILI9341_RDDID 0x04
51 #define ILI9341_RDDST 0x09
52 
53 #define ILI9341_SLPIN 0x10
54 #define ILI9341_SLPOUT 0x11
55 #define ILI9341_PTLON 0x12
56 #define ILI9341_NORON 0x13
57 
58 #define ILI9341_RDMODE 0x0A
59 #define ILI9341_RDMADCTL 0x0B
60 #define ILI9341_RDPIXFMT 0x0C
61 #define ILI9341_RDIMGFMT 0x0D
62 #define ILI9341_RDSELFDIAG 0x0F
63 
64 #define ILI9341_INVOFF 0x20
65 #define ILI9341_INVON 0x21
66 #define ILI9341_GAMMASET 0x26
67 #define ILI9341_DISPOFF 0x28
68 #define ILI9341_DISPON 0x29
69 
70 #define ILI9341_CASET 0x2A
71 #define ILI9341_PASET 0x2B
72 #define ILI9341_RAMWR 0x2C
73 #define ILI9341_RAMRD 0x2E
74 
75 #define ILI9341_PTLAR 0x30
76 #define ILI9341_VSCRDEF 0x33
77 #define ILI9341_MADCTL 0x36
78 #define ILI9341_VSCRSADD 0x37
79 #define ILI9341_PIXFMT 0x3A
80 
81 #define ILI9341_FRMCTR1 \
82  0xB1
83 #define ILI9341_FRMCTR2 0xB2
84 #define ILI9341_FRMCTR3 \
85  0xB3
86 #define ILI9341_INVCTR 0xB4
87 #define ILI9341_DFUNCTR 0xB6
88 
89 #define ILI9341_PWCTR1 0xC0
90 #define ILI9341_PWCTR2 0xC1
91 #define ILI9341_PWCTR3 0xC2
92 #define ILI9341_PWCTR4 0xC3
93 #define ILI9341_PWCTR5 0xC4
94 #define ILI9341_VMCTR1 0xC5
95 #define ILI9341_VMCTR2 0xC7
96 
97 #define ILI9341_RDID1 0xDA
98 #define ILI9341_RDID2 0xDB
99 #define ILI9341_RDID3 0xDC
100 #define ILI9341_RDID4 0xDD
101 
102 #define ILI9341_GMCTRP1 0xE0
103 #define ILI9341_GMCTRN1 0xE1
104 //#define ILI9341_PWCTR6 0xFC
105 
106 // Color definitions
107 #define ILI9341_BLACK 0x0000
108 #define ILI9341_NAVY 0x000F
109 #define ILI9341_DARKGREEN 0x03E0
110 #define ILI9341_DARKCYAN 0x03EF
111 #define ILI9341_MAROON 0x7800
112 #define ILI9341_PURPLE 0x780F
113 #define ILI9341_OLIVE 0x7BE0
114 #define ILI9341_LIGHTGREY 0xC618
115 #define ILI9341_DARKGREY 0x7BEF
116 #define ILI9341_BLUE 0x001F
117 #define ILI9341_GREEN 0x07E0
118 #define ILI9341_CYAN 0x07FF
119 #define ILI9341_RED 0xF800
120 #define ILI9341_MAGENTA 0xF81F
121 #define ILI9341_YELLOW 0xFFE0
122 #define ILI9341_WHITE 0xFFFF
123 #define ILI9341_ORANGE 0xFD20
124 #define ILI9341_GREENYELLOW 0xAFE5
125 #define ILI9341_PINK 0xFC18
126 
127 /**************************************************************************/
132 /**************************************************************************/
133 
134 class Adafruit_ILI9341 : public Adafruit_SPITFT {
135 public:
136  Adafruit_ILI9341(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK,
137  int8_t _RST = -1, int8_t _MISO = -1);
138  Adafruit_ILI9341(int8_t _CS, int8_t _DC, int8_t _RST = -1);
139 #if !defined(ESP8266)
140  Adafruit_ILI9341(SPIClass *spiClass, int8_t dc, int8_t cs = -1,
141  int8_t rst = -1);
142 #endif // end !ESP8266
143  Adafruit_ILI9341(tftBusWidth busWidth, int8_t d0, int8_t wr, int8_t dc,
144  int8_t cs = -1, int8_t rst = -1, int8_t rd = -1);
145 
146  void begin(uint32_t freq = 0);
147  void setRotation(uint8_t r);
148  void invertDisplay(bool i);
149  void scrollTo(uint16_t y);
150  void setScrollMargins(uint16_t top, uint16_t bottom);
151 
152  // Transaction API not used by GFX
153  void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
154 
155  uint8_t readcommand8(uint8_t reg, uint8_t index = 0);
156 };
157 
158 #endif // _ADAFRUIT_ILI9341H_
void setRotation(uint8_t r)
Set origin of (0,0) and orientation of TFT display.
Definition: Adafruit_ILI9341.cpp:219
Adafruit_ILI9341(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK, int8_t _RST=-1, int8_t _MISO=-1)
Instantiate Adafruit ILI9341 driver with software SPI.
Definition: Adafruit_ILI9341.cpp:95
uint8_t readcommand8(uint8_t reg, uint8_t index=0)
Read 8 bits of data from ILI9341 configuration memory. NOT from RAM! This is highly undocumented/supp...
Definition: Adafruit_ILI9341.cpp:336
void begin(uint32_t freq=0)
Initialize ILI9341 chip Connects to the ILI9341 over SPI and sends initialization procedure commands...
Definition: Adafruit_ILI9341.cpp:187
Class to manage hardware interface with ILI9341 chipset (also seems to work with ILI9340) ...
Definition: Adafruit_ILI9341.h:134
void invertDisplay(bool i)
Enable/Disable display color inversion.
Definition: Adafruit_ILI9341.cpp:253
void setScrollMargins(uint16_t top, uint16_t bottom)
Set the height of the Top and Bottom Scroll Margins.
Definition: Adafruit_ILI9341.cpp:277
void scrollTo(uint16_t y)
Scroll display memory.
Definition: Adafruit_ILI9341.cpp:263
void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Set the "address window" - the rectangle we will write to RAM with the next chunk of SPI data writes...
Definition: Adafruit_ILI9341.cpp:303