Adafruit GFX Library
Adafruit_SPITFT.h
Go to the documentation of this file.
1 
20 #ifndef _ADAFRUIT_SPITFT_H_
21 #define _ADAFRUIT_SPITFT_H_
22 
23 // Not for ATtiny, at all
24 #if !defined(__AVR_ATtiny85__) && !defined(__AVR_ATtiny84__)
25 
26 #include "Adafruit_GFX.h"
27 #include <SPI.h>
28 
29 // HARDWARE CONFIG ---------------------------------------------------------
30 
31 #include "arch/arch.h"
32 
33 typedef volatile ADAGFX_PORT_t *PORTreg_t;
34 
35 #if defined(__AVR__) && !defined(__LGT8F__)
36 #define DEFAULT_SPI_FREQ 8000000L
37 #else
38 #define DEFAULT_SPI_FREQ 16000000L
39 #endif
40 
41 #if defined(ADAFRUIT_PYPORTAL) || defined(ADAFRUIT_PYPORTAL_M4_TITANO) || \
42  defined(ADAFRUIT_PYBADGE_M4_EXPRESS) || \
43  defined(ADAFRUIT_PYGAMER_M4_EXPRESS) || \
44  defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) || defined(NRF52_SERIES) || \
45  defined(ADAFRUIT_CIRCUITPLAYGROUND_M0)
46 #define USE_SPI_DMA
47 #else
48  // #define USE_SPI_DMA ///< If set,
49  // use DMA if available
50 #endif
51 // Another "oops" name -- this now also handles parallel DMA.
52 // If DMA is enabled, Arduino sketch MUST #include <Adafruit_ZeroDMA.h>
53 // Estimated RAM usage:
54 // 4 bytes/pixel on display major axis + 8 bytes/pixel on minor axis,
55 // e.g. 320x240 pixels = 320 * 4 + 240 * 8 = 3,200 bytes.
56 
57 #if defined(USE_SPI_DMA) && (defined(__SAMD51__) || defined(ARDUINO_SAMD_ZERO))
58 #include <Adafruit_ZeroDMA.h>
59 #endif
60 
61 // This is kind of a kludge. Needed a way to disambiguate the software SPI
62 // and parallel constructors via their argument lists. Originally tried a
63 // bool as the first argument to the parallel constructor (specifying 8-bit
64 // vs 16-bit interface) but the compiler regards this as equivalent to an
65 // integer and thus still ambiguous. SO...the parallel constructor requires
66 // an enumerated type as the first argument: tft8 (for 8-bit parallel) or
67 // tft16 (for 16-bit)...even though 16-bit isn't fully implemented or tested
68 // and might never be, still needed that disambiguation from soft SPI.
70 enum tftBusWidth { tft8bitbus, tft16bitbus };
71 
72 // SPI defaults for RP2040
73 #if defined(ARDUINO_ARCH_RP2040)
74 #ifndef __SPI0_DEVICE
75 #define __SPI0_DEVICE spi0
76 #endif
77 #ifndef __SPI1_DEVICE
78 #define __SPI1_DEVICE spi1
79 #endif
80 #endif
81 
82 // CLASS DEFINITION --------------------------------------------------------
83 
97 class Adafruit_SPITFT : public Adafruit_GFX {
98 
99 public:
100  // CONSTRUCTORS --------------------------------------------------------
101 
102  // Software SPI constructor: expects width & height (at default rotation
103  // setting 0), 4 signal pins (cs, dc, mosi, sclk), 2 optional pins
104  // (reset, miso). cs argument is required but can be -1 if unused --
105  // rather than moving it to the optional arguments, it was done this way
106  // to avoid breaking existing code (-1 option was a later addition).
107  Adafruit_SPITFT(uint16_t w, uint16_t h, int16_t cs, int16_t dc, int16_t mosi,
108  int16_t sck, int16_t rst = -1, int16_t miso = -1);
109 
110  // Hardware SPI constructor using the default SPI port: expects width &
111  // height (at default rotation setting 0), 2 signal pins (cs, dc),
112  // optional reset pin. cs is required but can be -1 if unused -- rather
113  // than moving it to the optional arguments, it was done this way to
114  // avoid breaking existing code (-1 option was a later addition).
115  Adafruit_SPITFT(uint16_t w, uint16_t h, int16_t cs, int16_t dc,
116  int16_t rst = -1);
117 
118 #if !defined(ESP8266) // See notes in .cpp
119  // Hardware SPI constructor using an arbitrary SPI peripheral: expects
120  // width & height (rotation 0), SPIClass pointer, 2 signal pins (cs, dc)
121  // and optional reset pin. cs is required but can be -1 if unused.
122  Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass, int16_t cs,
123  int16_t dc, int16_t rst = -1);
124 #endif // end !ESP8266
125 
126  // Parallel constructor: expects width & height (rotation 0), flag
127  // indicating whether 16-bit (true) or 8-bit (false) interface, 3 signal
128  // pins (d0, wr, dc), 3 optional pins (cs, rst, rd). 16-bit parallel
129  // isn't even fully implemented but the 'wide' flag was added as a
130  // required argument to avoid ambiguity with other constructors.
131  Adafruit_SPITFT(uint16_t w, uint16_t h, tftBusWidth busWidth, int16_t d0,
132  int16_t wr, int16_t dc, int16_t cs = -1, int16_t rst = -1,
133  int16_t rd = -1);
134 
135  // DESTRUCTOR ----------------------------------------------------------
136 
137  ~Adafruit_SPITFT() {};
138 
139  // CLASS MEMBER FUNCTIONS ----------------------------------------------
140 
141  // These first two functions MUST be declared by subclasses:
142 
147  virtual void begin(uint32_t freq) = 0;
148 
161  virtual void setAddrWindow(uint16_t x, uint16_t y, uint16_t w,
162  uint16_t h) = 0;
163 
164  // Remaining functions do not need to be declared in subclasses
165  // unless they wish to provide hardware-specific optimizations.
166  // Brief comments here...documented more thoroughly in .cpp file.
167 
168  // Subclass' begin() function invokes this to initialize hardware.
169  // freq=0 to use default SPI speed. spiMode must be one of the SPI_MODEn
170  // values defined in SPI.h, which are NOT the same as 0 for SPI_MODE0,
171  // 1 for SPI_MODE1, etc...use ONLY the SPI_MODEn defines! Only!
172  // Name is outdated (interface may be parallel) but for compatibility:
173  void initSPI(uint32_t freq = 0, uint8_t spiMode = SPI_MODE0);
174  void setSPISpeed(uint32_t freq);
175  // Chip select and/or hardware SPI transaction start as needed:
176  void startWrite(void);
177  // Chip deselect and/or hardware SPI transaction end as needed:
178  void endWrite(void);
179  void sendCommand(uint8_t commandByte, uint8_t *dataBytes,
180  uint8_t numDataBytes);
181  void sendCommand(uint8_t commandByte, const uint8_t *dataBytes = NULL,
182  uint8_t numDataBytes = 0);
183  void sendCommand16(uint16_t commandWord, const uint8_t *dataBytes = NULL,
184  uint8_t numDataBytes = 0);
185  uint8_t readcommand8(uint8_t commandByte, uint8_t index = 0);
186  uint16_t readcommand16(uint16_t addr);
187 
188  // These functions require a chip-select and/or SPI transaction
189  // around them. Higher-level graphics primitives might start a
190  // single transaction and then make multiple calls to these functions
191  // (e.g. circle or text rendering might make repeated lines or rects)
192  // before ending the transaction. It's more efficient than starting a
193  // transaction every time.
194  void writePixel(int16_t x, int16_t y, uint16_t color);
195  void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
196  uint16_t color);
197  void writePixels(uint16_t *colors, uint32_t len, bool block = true,
198  bool bigEndian = false);
199  void writeColor(uint16_t color, uint32_t len);
200  void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h,
201  uint16_t color);
202  void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
203  void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
204  // This is a new function, similar to writeFillRect() except that
205  // all arguments MUST be onscreen, sorted and clipped. If higher-level
206  // primitives can handle their own sorting/clipping, it avoids repeating
207  // such operations in the low-level code, making it potentially faster.
208  // CALLING THIS WITH UNCLIPPED OR NEGATIVE VALUES COULD BE DISASTROUS.
209  inline void writeFillRectPreclipped(int16_t x, int16_t y, int16_t w,
210  int16_t h, uint16_t color);
211  // Another new function, companion to the new non-blocking
212  // writePixels() variant.
213  void dmaWait(void);
214  // Used by writePixels() in some situations, but might have rare need in
215  // user code, so it's public...
216  bool dmaBusy(void) const; // true if DMA is used and busy, false otherwise
217  void swapBytes(uint16_t *src, uint32_t len, uint16_t *dest = NULL);
218 
219  // These functions are similar to the 'write' functions above, but with
220  // a chip-select and/or SPI transaction built-in. They're typically used
221  // solo -- that is, as graphics primitives in themselves, not invoked by
222  // higher-level primitives (which should use the functions above).
223  void drawPixel(int16_t x, int16_t y, uint16_t color);
224  void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
225  void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
226  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
227  // A single-pixel push encapsulated in a transaction. I don't think
228  // this is used anymore (BMP demos might've used it?) but is provided
229  // for backward compatibility, consider it deprecated:
230  void pushColor(uint16_t color);
231 
232  using Adafruit_GFX::drawRGBBitmap; // Check base class first
233  void drawRGBBitmap(int16_t x, int16_t y, uint16_t *pcolors, int16_t w,
234  int16_t h);
235 
236  void invertDisplay(bool i);
237  uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
238 
239  // Despite parallel additions, function names kept for compatibility:
240  void spiWrite(uint8_t b); // Write single byte as DATA
241  void writeCommand(uint8_t cmd); // Write single byte as COMMAND
242  uint8_t spiRead(void); // Read single byte of data
243  void write16(uint16_t w); // Write 16-bit value as DATA
244  void writeCommand16(uint16_t cmd); // Write 16-bit value as COMMAND
245  uint16_t read16(void); // Read single 16-bit value
246 
247  // Most of these low-level functions were formerly macros in
248  // Adafruit_SPITFT_Macros.h. Some have been made into inline functions
249  // to avoid macro mishaps. Despite the addition of code for a parallel
250  // display interface, the names have been kept for backward
251  // compatibility (some subclasses may be invoking these):
252  void SPI_WRITE16(uint16_t w); // Not inline
253  void SPI_WRITE32(uint32_t l); // Not inline
254  // Old code had both a spiWrite16() function and SPI_WRITE16 macro
255  // in addition to the SPI_WRITE32 macro. The latter two have been
256  // made into functions here, and spiWrite16() removed (use SPI_WRITE16()
257  // instead). It looks like most subclasses had gotten comfortable with
258  // SPI_WRITE16 and SPI_WRITE32 anyway so those names were kept rather
259  // than the less-obnoxious camelcase variants, oh well.
260 
261  // Placing these functions entirely in the class definition inlines
262  // them implicitly them while allowing their use in other code:
263 
270  void SPI_CS_HIGH(void) {
271 #if defined(USE_FAST_PINIO)
272 #if defined(HAS_PORT_SET_CLR)
273 #if defined(KINETISK)
274  *csPortSet = 1;
275 #else // !KINETISK
276  *csPortSet = csPinMask;
277 #endif // end !KINETISK
278 #else // !HAS_PORT_SET_CLR
279  *csPort |= csPinMaskSet;
280 #endif // end !HAS_PORT_SET_CLR
281 #else // !USE_FAST_PINIO
282  digitalWrite(_cs, HIGH);
283 #endif // end !USE_FAST_PINIO
284  }
285 
292  void SPI_CS_LOW(void) {
293 #if defined(USE_FAST_PINIO)
294 #if defined(HAS_PORT_SET_CLR)
295 #if defined(KINETISK)
296  *csPortClr = 1;
297 #else // !KINETISK
298  *csPortClr = csPinMask;
299 #endif // end !KINETISK
300 #else // !HAS_PORT_SET_CLR
301  *csPort &= csPinMaskClr;
302 #endif // end !HAS_PORT_SET_CLR
303 #else // !USE_FAST_PINIO
304  digitalWrite(_cs, LOW);
305 #endif // end !USE_FAST_PINIO
306  }
307 
311  void SPI_DC_HIGH(void) {
312 #if defined(USE_FAST_PINIO)
313 #if defined(HAS_PORT_SET_CLR)
314 #if defined(KINETISK)
315  *dcPortSet = 1;
316 #else // !KINETISK
317  *dcPortSet = dcPinMask;
318 #endif // end !KINETISK
319 #else // !HAS_PORT_SET_CLR
320  *dcPort |= dcPinMaskSet;
321 #endif // end !HAS_PORT_SET_CLR
322 #else // !USE_FAST_PINIO
323  digitalWrite(_dc, HIGH);
324 #endif // end !USE_FAST_PINIO
325  }
326 
330  void SPI_DC_LOW(void) {
331 #if defined(USE_FAST_PINIO)
332 #if defined(HAS_PORT_SET_CLR)
333 #if defined(KINETISK)
334  *dcPortClr = 1;
335 #else // !KINETISK
336  *dcPortClr = dcPinMask;
337 #endif // end !KINETISK
338 #else // !HAS_PORT_SET_CLR
339  *dcPort &= dcPinMaskClr;
340 #endif // end !HAS_PORT_SET_CLR
341 #else // !USE_FAST_PINIO
342  digitalWrite(_dc, LOW);
343 #endif // end !USE_FAST_PINIO
344  }
345 
346 protected:
352  void writeColorHardSPI(uint16_t color, uint32_t len);
353  // A few more low-level member functions -- some may have previously
354  // been macros. Shouldn't have a need to access these externally, so
355  // they've been moved to the protected section. Additionally, they're
356  // declared inline here and the code is in the .cpp file, since outside
357  // code doesn't need to see these.
358  inline void SPI_MOSI_HIGH(void);
359  inline void SPI_MOSI_LOW(void);
360  inline void SPI_SCK_HIGH(void);
361  inline void SPI_SCK_LOW(void);
362  inline bool SPI_MISO_READ(void);
363  inline void SPI_BEGIN_TRANSACTION(void);
364  inline void SPI_END_TRANSACTION(void);
365  inline void TFT_WR_STROBE(void); // Parallel interface write strobe
366  inline void TFT_RD_HIGH(void); // Parallel interface read high
367  inline void TFT_RD_LOW(void); // Parallel interface read low
368 
369  // CLASS INSTANCE VARIABLES --------------------------------------------
370 
371  // Here be dragons! There's a big union of three structures here --
372  // one each for hardware SPI, software (bitbang) SPI, and parallel
373  // interfaces. This is to save some memory, since a display's connection
374  // will be only one of these. The order of some things is a little weird
375  // in an attempt to get values to align and pack better in RAM.
376 
377 #if defined(USE_FAST_PINIO)
378 #if defined(HAS_PORT_SET_CLR)
379  PORTreg_t csPortSet;
380  PORTreg_t csPortClr;
381  PORTreg_t dcPortSet;
382  PORTreg_t dcPortClr;
383 #else // !HAS_PORT_SET_CLR
384  PORTreg_t csPort;
385  PORTreg_t dcPort;
386 #endif // end HAS_PORT_SET_CLR
387 #endif // end USE_FAST_PINIO
388 #if defined(__cplusplus) && (__cplusplus >= 201100)
389  union {
390 #endif
391  struct { // Values specific to HARDWARE SPI:
392  SPIClass *_spi;
393 #if defined(SPI_HAS_TRANSACTION)
394  SPISettings settings;
395 #else
396  uint32_t _freq;
397 #endif
398  uint32_t _mode;
399  } hwspi;
400  struct { // Values specific to SOFTWARE SPI:
401 #if defined(USE_FAST_PINIO)
402  PORTreg_t misoPort;
403 #if defined(HAS_PORT_SET_CLR)
404  PORTreg_t mosiPortSet;
405  PORTreg_t mosiPortClr;
406  PORTreg_t sckPortSet;
407  PORTreg_t sckPortClr;
408 #if !defined(KINETISK)
409  ADAGFX_PORT_t mosiPinMask;
410  ADAGFX_PORT_t sckPinMask;
411 #endif // end !KINETISK
412 #else // !HAS_PORT_SET_CLR
413  PORTreg_t mosiPort;
414  PORTreg_t sckPort;
415  ADAGFX_PORT_t mosiPinMaskSet;
416  ADAGFX_PORT_t mosiPinMaskClr;
417  ADAGFX_PORT_t sckPinMaskSet;
418  ADAGFX_PORT_t sckPinMaskClr;
419 #endif // end HAS_PORT_SET_CLR
420 #if !defined(KINETISK)
421  ADAGFX_PORT_t misoPinMask;
422 #endif // end !KINETISK
423 #endif // end USE_FAST_PINIO
424  int16_t _mosi;
425  int16_t _miso;
426  int16_t _sck;
427  } swspi;
428  struct { // Values specific to 8-bit parallel:
429 #if defined(USE_FAST_PINIO)
430 
431 #if defined(__IMXRT1052__) || defined(__IMXRT1062__) // Teensy 4.x
432  volatile uint32_t *writePort;
433  volatile uint32_t *readPort;
434 #else
435  volatile uint8_t *writePort;
436  volatile uint8_t *readPort;
437 #endif
438 #if defined(HAS_PORT_SET_CLR)
439  // Port direction register pointers are always 8-bit regardless of
440  // PORTreg_t -- even if 32-bit port, we modify a byte-aligned 8 bits.
441 #if defined(__IMXRT1052__) || defined(__IMXRT1062__) // Teensy 4.x
442  volatile uint32_t *dirSet;
443  volatile uint32_t *dirClr;
444 #else
445  volatile uint8_t *dirSet;
446  volatile uint8_t *dirClr;
447 #endif
448  PORTreg_t wrPortSet;
449  PORTreg_t wrPortClr;
450  PORTreg_t rdPortSet;
451  PORTreg_t rdPortClr;
452 #if !defined(KINETISK)
453  ADAGFX_PORT_t wrPinMask;
454 #endif // end !KINETISK
455  ADAGFX_PORT_t rdPinMask;
456 #else // !HAS_PORT_SET_CLR
457  // Port direction register pointer is always 8-bit regardless of
458  // PORTreg_t -- even if 32-bit port, we modify a byte-aligned 8 bits.
459  volatile uint8_t *portDir;
460  PORTreg_t wrPort;
461  PORTreg_t rdPort;
462  ADAGFX_PORT_t wrPinMaskSet;
463  ADAGFX_PORT_t wrPinMaskClr;
464  ADAGFX_PORT_t rdPinMaskSet;
465  ADAGFX_PORT_t rdPinMaskClr;
466 #endif // end HAS_PORT_SET_CLR
467 #endif // end USE_FAST_PINIO
468  int16_t _d0;
469  int16_t _wr;
470  int16_t _rd;
471  bool wide = 0;
472  } tft8;
473 #if defined(__cplusplus) && (__cplusplus >= 201100)
474  };
475 #endif
476 #if defined(USE_SPI_DMA) && \
477  (defined(__SAMD51__) || \
478  defined(ARDUINO_SAMD_ZERO)) // Used by hardware SPI and tft8
479  Adafruit_ZeroDMA dma;
480  DmacDescriptor *dptr = NULL;
481  DmacDescriptor *descriptor = NULL;
482  uint16_t *pixelBuf[2];
483  uint16_t maxFillLen;
484  uint16_t lastFillColor = 0;
485  uint32_t lastFillLen = 0;
486  uint8_t onePixelBuf;
487 #endif
488 #if defined(USE_FAST_PINIO)
489 #if defined(HAS_PORT_SET_CLR)
490 #if !defined(KINETISK)
491  ADAGFX_PORT_t csPinMask;
492  ADAGFX_PORT_t dcPinMask;
493 #endif // end !KINETISK
494 #else // !HAS_PORT_SET_CLR
495  ADAGFX_PORT_t csPinMaskSet;
496  ADAGFX_PORT_t csPinMaskClr;
497  ADAGFX_PORT_t dcPinMaskSet;
498  ADAGFX_PORT_t dcPinMaskClr;
499 #endif // end HAS_PORT_SET_CLR
500 #endif // end USE_FAST_PINIO
501  uint8_t connection;
502  int16_t _rst;
503  int16_t _cs;
504  int16_t _dc;
505 
506  int16_t _xstart = 0;
507  int16_t _ystart = 0;
508  uint8_t invertOnCommand = 0;
509  uint8_t invertOffCommand = 0;
510 
511  uint32_t _freq = 0;
512 };
513 
514 #endif // end __AVR_ATtiny85__ __AVR_ATtiny84__
515 #endif // end _ADAFRUIT_SPITFT_H_
void sendCommand(uint8_t commandByte, uint8_t *dataBytes, uint8_t numDataBytes)
Adafruit_SPITFT Send Command handles complete sending of commands and data.
Definition: Adafruit_SPITFT.cpp:2038
void write16(uint16_t w)
Issue a single 16-bit value to the display. Chip-select, transaction and data/command selection must ...
Definition: Adafruit_SPITFT.cpp:2369
uint32_t _freq
SPI bitrate (if no SPI transactions)
Definition: Adafruit_SPITFT.h:396
void writePixels(uint16_t *colors, uint32_t len, bool block=true, bool bigEndian=false)
Issue a series of pixels from memory to the display. Not self- contained; should follow startWrite() ...
Definition: Adafruit_SPITFT.cpp:1074
uint8_t invertOffCommand
Command to disable invert mode.
Definition: Adafruit_SPITFT.h:509
void writePixel(int16_t x, int16_t y, uint16_t color)
Draw a single pixel to the display at requested coordinates. Not self-contained; should follow a star...
Definition: Adafruit_SPITFT.cpp:949
struct Adafruit_SPITFT::@2 tft8
Parallel interface settings.
virtual void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h)=0
Set up the specific display hardware&#39;s "address window" for subsequent pixel-pushing operations...
void SPI_WRITE16(uint16_t w)
Issue a single 16-bit value to the display. Chip-select, transaction and data/command selection must ...
Definition: Adafruit_SPITFT.cpp:2531
Definition: Adafruit_GFX.h:18
uint16_t readcommand16(uint16_t addr)
Read 16 bits of data from display register. For 16-bit parallel displays only.
Definition: Adafruit_SPITFT.cpp:2160
int16_t _rd
Read strobe pin # (or -1)
Definition: Adafruit_SPITFT.h:470
void writeColorHardSPI(uint16_t color, uint32_t len)
Family-specific hardware SPI solid fill.
void SPI_BEGIN_TRANSACTION(void)
Start an SPI transaction if using the hardware SPI interface to the display. If using an earlier vers...
Definition: Adafruit_SPITFT.cpp:2202
void drawRGBBitmap(int16_t x, int16_t y, uint16_t *pcolors, int16_t w, int16_t h)
Draw a 16-bit image (565 RGB) at the specified (x,y) position. For 16-bit display devices; no color r...
Definition: Adafruit_SPITFT.cpp:1965
Adafruit_SPITFT(uint16_t w, uint16_t h, int16_t cs, int16_t dc, int16_t mosi, int16_t sck, int16_t rst=-1, int16_t miso=-1)
Adafruit_SPITFT constructor for software (bitbang) SPI.
Definition: Adafruit_SPITFT.cpp:121
void TFT_RD_LOW(void)
Set the RD line LOW. Used for parallel-connected interfaces when reading data.
Definition: Adafruit_SPITFT.cpp:2691
void writeColor(uint16_t color, uint32_t len)
Issue a series of pixels, all the same color. Not self- contained; should follow startWrite() and set...
Definition: Adafruit_SPITFT.cpp:1306
void writeCommand16(uint16_t cmd)
Write a single command word to the display. Chip-select and transaction must have been previously set...
Definition: Adafruit_SPITFT.cpp:2389
void SPI_SCK_HIGH(void)
Set the software (bitbang) SPI SCK line HIGH.
Definition: Adafruit_SPITFT.cpp:2470
uint8_t connection
TFT_HARD_SPI, TFT_SOFT_SPI, etc.
Definition: Adafruit_SPITFT.h:501
bool SPI_MISO_READ(void)
Read the state of the software (bitbang) SPI MISO line.
Definition: Adafruit_SPITFT.cpp:2509
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Draw a horizontal line on the display. Self-contained and provides its own transaction as needed (see...
Definition: Adafruit_SPITFT.cpp:1869
void writeFillRectPreclipped(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
A lower-level version of writeFillRect(). This version requires all inputs are in-bounds, that width and height are positive, and no part extends offscreen. NO EDGE CLIPPING OR REJECTION IS PERFORMED. If higher-level graphics primitives are written to handle their own clipping earlier in the drawing process, this can avoid unnecessary function calls and repeated clipping operations in the lower-level functions.
Definition: Adafruit_SPITFT.cpp:1757
int16_t _cs
Chip select pin # (or -1)
Definition: Adafruit_SPITFT.h:503
void invertDisplay(bool i)
Invert the colors of the display (if supported by hardware). Self-contained, no transaction setup req...
Definition: Adafruit_SPITFT.cpp:2011
tftBusWidth
Definition: Adafruit_SPITFT.h:70
void dmaWait(void)
Wait for the last DMA transfer in a prior non-blocking writePixels() call to complete. This does nothing if DMA is not enabled, and is not needed if blocking writePixels() was used (as is the default case).
Definition: Adafruit_SPITFT.cpp:1272
void setSPISpeed(uint32_t freq)
Allow changing the SPI clock speed after initialization.
Definition: Adafruit_SPITFT.cpp:902
void drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[], int16_t w, int16_t h)
Draw a PROGMEM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position. For 16-bit display ...
Definition: Adafruit_GFX.cpp:1381
void SPI_CS_LOW(void)
Set the chip-select line LOW. Does NOT check whether CS pin is set (>=0), that should be handled in c...
Definition: Adafruit_SPITFT.h:292
struct Adafruit_SPITFT::@0 hwspi
Hardware SPI values.
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Draw a vertical line on the display. Self-contained and provides its own transaction as needed (see w...
Definition: Adafruit_SPITFT.cpp:1910
void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Write a line using horizontal or vertical runs where possible. Not self-contained; should follow a st...
Definition: Adafruit_SPITFT.cpp:965
void pushColor(uint16_t color)
Essentially writePixel() with a transaction around it. I don&#39;t think this is in use by any of our cod...
Definition: Adafruit_SPITFT.cpp:1943
int16_t _ystart
Internal framebuffer Y offset.
Definition: Adafruit_SPITFT.h:507
void SPI_SCK_LOW(void)
Set the software (bitbang) SPI SCK line LOW.
Definition: Adafruit_SPITFT.cpp:2489
int16_t _rst
Reset pin # (or -1)
Definition: Adafruit_SPITFT.h:502
void SPI_MOSI_HIGH(void)
Set the software (bitbang) SPI MOSI line HIGH.
Definition: Adafruit_SPITFT.cpp:2432
void sendCommand16(uint16_t commandWord, const uint8_t *dataBytes=NULL, uint8_t numDataBytes=0)
Adafruit_SPITFT sendCommand16 handles complete sending of commands and data for 16-bit parallel displ...
Definition: Adafruit_SPITFT.cpp:2105
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Draw a filled rectangle to the display. Self-contained and provides its own transaction as needed (se...
Definition: Adafruit_SPITFT.cpp:1811
uint32_t _mode
SPI data mode (transactions or no)
Definition: Adafruit_SPITFT.h:398
void writeCommand(uint8_t cmd)
Write a single command byte to the display. Chip-select and transaction must have been previously set...
Definition: Adafruit_SPITFT.cpp:2290
void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Draw a filled rectangle to the display. Not self-contained; should follow startWrite(). Typically used by higher-level graphics primitives; user code shouldn&#39;t need to call this and is likely to use the self-contained fillRect() instead. writeFillRect() performs its own edge clipping and rejection; see writeFillRectPreclipped() for a more &#39;raw&#39; implementation.
Definition: Adafruit_SPITFT.cpp:1625
bool dmaBusy(void) const
Check if DMA transfer is active. Always returts false if DMA is not enabled.
Definition: Adafruit_SPITFT.cpp:1292
void SPI_DC_HIGH(void)
Set the data/command line HIGH (data mode).
Definition: Adafruit_SPITFT.h:311
int16_t _miso
MISO pin #.
Definition: Adafruit_SPITFT.h:425
void SPI_CS_HIGH(void)
Set the chip-select line HIGH. Does NOT check whether CS pin is set (>=0), that should be handled in ...
Definition: Adafruit_SPITFT.h:270
uint16_t read16(void)
Read a single 16-bit value from the display. Chip-select and transaction must have been previously se...
Definition: Adafruit_SPITFT.cpp:2403
volatile ADAGFX_PORT_t * PORTreg_t
PORT register type.
Definition: Adafruit_SPITFT.h:33
SPIClass * _spi
SPI class pointer.
Definition: Adafruit_SPITFT.h:392
struct Adafruit_SPITFT::@1 swspi
Software SPI values.
void SPI_MOSI_LOW(void)
Set the software (bitbang) SPI MOSI line LOW.
Definition: Adafruit_SPITFT.cpp:2451
Adafruit_SPITFT is an intermediary class between Adafruit_GFX and various hardware-specific subclasse...
Definition: Adafruit_SPITFT.h:97
void drawPixel(int16_t x, int16_t y, uint16_t color)
Draw a single pixel to the display at requested coordinates. Self-contained and provides its own tran...
Definition: Adafruit_SPITFT.cpp:1781
void spiWrite(uint8_t b)
Issue a single 8-bit value to the display. Chip-select, transaction and data/command selection must h...
Definition: Adafruit_SPITFT.cpp:2247
uint16_t color565(uint8_t r, uint8_t g, uint8_t b)
Given 8-bit red, green and blue values, return a &#39;packed&#39; 16-bit color value in &#39;565&#39; RGB format (5 b...
Definition: Adafruit_SPITFT.cpp:2027
void SPI_DC_LOW(void)
Set the data/command line LOW (command mode).
Definition: Adafruit_SPITFT.h:330
void endWrite(void)
Call after issuing command(s) or data to display. Performs chip-deselect (if required) and ends an SP...
Definition: Adafruit_SPITFT.cpp:928
uint8_t invertOnCommand
Command to enable invert mode.
Definition: Adafruit_SPITFT.h:508
int16_t _dc
Data/command pin #.
Definition: Adafruit_SPITFT.h:504
void startWrite(void)
Call before issuing command(s) or data to display. Performs chip-select (if required) and starts an S...
Definition: Adafruit_SPITFT.cpp:916
void TFT_WR_STROBE(void)
Set the WR line LOW, then HIGH. Used for parallel-connected interfaces when writing data...
Definition: Adafruit_SPITFT.cpp:2651
bool wide
If true, is 16-bit interface.
Definition: Adafruit_SPITFT.h:471
int16_t _d0
Data pin 0 #.
Definition: Adafruit_SPITFT.h:468
void SPI_END_TRANSACTION(void)
End an SPI transaction if using the hardware SPI interface to the display. No action is taken if the ...
Definition: Adafruit_SPITFT.cpp:2230
int16_t _xstart
Internal framebuffer X offset.
Definition: Adafruit_SPITFT.h:506
int16_t _mosi
MOSI pin #.
Definition: Adafruit_SPITFT.h:424
int16_t _wr
Write strobe pin #.
Definition: Adafruit_SPITFT.h:469
void initSPI(uint32_t freq=0, uint8_t spiMode=SPI_MODE0)
Configure microcontroller pins for TFT interfacing. Typically called by a subclass&#39; begin() function...
Definition: Adafruit_SPITFT.cpp:531
virtual void begin(uint32_t freq)=0
Display-specific initialization function.
void TFT_RD_HIGH(void)
Set the RD line HIGH. Used for parallel-connected interfaces when reading data.
Definition: Adafruit_SPITFT.cpp:2675
void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Draw a horizontal line on the display. Performs edge clipping and rejection. Not self-contained; shou...
Definition: Adafruit_SPITFT.cpp:1677
void SPI_WRITE32(uint32_t l)
Issue a single 32-bit value to the display. Chip-select, transaction and data/command selection must ...
Definition: Adafruit_SPITFT.cpp:2587
uint8_t spiRead(void)
Read a single 8-bit value from the display. Chip-select and transaction must have been previously set...
Definition: Adafruit_SPITFT.cpp:2306
uint8_t readcommand8(uint8_t commandByte, uint8_t index=0)
Read 8 bits of data from display configuration memory (not RAM). This is highly undocumented/supporte...
Definition: Adafruit_SPITFT.cpp:2141
void swapBytes(uint16_t *src, uint32_t len, uint16_t *dest=NULL)
Swap bytes in an array of pixels; converts little-to-big or big-to-little endian. Used by writePixels...
Definition: Adafruit_SPITFT.cpp:1041
int16_t _sck
SCK pin #.
Definition: Adafruit_SPITFT.h:426
void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Draw a vertical line on the display. Performs edge clipping and rejection. Not self-contained; should...
Definition: Adafruit_SPITFT.cpp:1713