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 #if defined(__AVR__)
32 typedef uint8_t ADAGFX_PORT_t;
33 #define USE_FAST_PINIO
34 #elif defined(ARDUINO_STM32_FEATHER) // WICED
35 typedef class HardwareSPI SPIClass;
36 typedef uint32_t ADAGFX_PORT_t;
37 #elif defined(__arm__)
38 #if defined(ARDUINO_ARCH_SAMD)
39 // Adafruit M0, M4
40 typedef uint32_t ADAGFX_PORT_t;
41 #define USE_FAST_PINIO
42 #define HAS_PORT_SET_CLR
43 #elif defined(CORE_TEENSY)
44 // PJRC Teensy 4.x
45 #if defined(__IMXRT1052__) || defined(__IMXRT1062__) // Teensy 4.x
46 typedef uint32_t ADAGFX_PORT_t;
47  // PJRC Teensy 3.x
48 #else
49 typedef uint8_t ADAGFX_PORT_t;
50 #endif
51 #define USE_FAST_PINIO
52 #define HAS_PORT_SET_CLR
53 #else
54 // Arduino Due?
55 typedef uint32_t ADAGFX_PORT_t;
56 // USE_FAST_PINIO not available here (yet)...Due has a totally different
57 // GPIO register set and will require some changes elsewhere (e.g. in
58 // constructors especially).
59 #endif
60 #else // !ARM
61 // Probably ESP8266 or ESP32. USE_FAST_PINIO is not available here (yet)
62 // but don't worry about it too much...the digitalWrite() implementation
63 // on these platforms is reasonably efficient and already RAM-resident,
64 // only gotcha then is no parallel connection support for now.
65 typedef uint32_t ADAGFX_PORT_t;
66 #endif // end !ARM
67 typedef volatile ADAGFX_PORT_t *PORTreg_t;
68 
69 #if defined(__AVR__) && !defined(__LGT8F__)
70 #define DEFAULT_SPI_FREQ 8000000L
71 #else
72 #define DEFAULT_SPI_FREQ 16000000L
73 #endif
74 
75 #if defined(ADAFRUIT_PYPORTAL) || defined(ADAFRUIT_PYPORTAL_M4_TITANO) || \
76  defined(ADAFRUIT_PYBADGE_M4_EXPRESS) || \
77  defined(ADAFRUIT_PYGAMER_M4_EXPRESS) || \
78  defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) || defined(NRF52_SERIES) || \
79  defined(ADAFRUIT_CIRCUITPLAYGROUND_M0)
80 #define USE_SPI_DMA
81 #else
82  // #define USE_SPI_DMA ///< If set,
83  // use DMA if available
84 #endif
85 // Another "oops" name -- this now also handles parallel DMA.
86 // If DMA is enabled, Arduino sketch MUST #include <Adafruit_ZeroDMA.h>
87 // Estimated RAM usage:
88 // 4 bytes/pixel on display major axis + 8 bytes/pixel on minor axis,
89 // e.g. 320x240 pixels = 320 * 4 + 240 * 8 = 3,200 bytes.
90 
91 #if defined(USE_SPI_DMA) && (defined(__SAMD51__) || defined(ARDUINO_SAMD_ZERO))
92 #include <Adafruit_ZeroDMA.h>
93 #endif
94 
95 // This is kind of a kludge. Needed a way to disambiguate the software SPI
96 // and parallel constructors via their argument lists. Originally tried a
97 // bool as the first argument to the parallel constructor (specifying 8-bit
98 // vs 16-bit interface) but the compiler regards this as equivalent to an
99 // integer and thus still ambiguous. SO...the parallel constructor requires
100 // an enumerated type as the first argument: tft8 (for 8-bit parallel) or
101 // tft16 (for 16-bit)...even though 16-bit isn't fully implemented or tested
102 // and might never be, still needed that disambiguation from soft SPI.
104 enum tftBusWidth { tft8bitbus, tft16bitbus };
105 
106 // SPI defaults for RP2040
107 #if defined(ARDUINO_ARCH_RP2040)
108 #ifndef __SPI0_DEVICE
109 #define __SPI0_DEVICE spi0
110 #endif
111 #ifndef __SPI1_DEVICE
112 #define __SPI1_DEVICE spi1
113 #endif
114 #endif
115 
116 // CLASS DEFINITION --------------------------------------------------------
117 
132 
133 public:
134  // CONSTRUCTORS --------------------------------------------------------
135 
136  // Software SPI constructor: expects width & height (at default rotation
137  // setting 0), 4 signal pins (cs, dc, mosi, sclk), 2 optional pins
138  // (reset, miso). cs argument is required but can be -1 if unused --
139  // rather than moving it to the optional arguments, it was done this way
140  // to avoid breaking existing code (-1 option was a later addition).
141  Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t cs, int8_t dc, int8_t mosi,
142  int8_t sck, int8_t rst = -1, int8_t miso = -1);
143 
144  // Hardware SPI constructor using the default SPI port: expects width &
145  // height (at default rotation setting 0), 2 signal pins (cs, dc),
146  // optional reset pin. cs is required but can be -1 if unused -- rather
147  // than moving it to the optional arguments, it was done this way to
148  // avoid breaking existing code (-1 option was a later addition).
149  Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t cs, int8_t dc,
150  int8_t rst = -1);
151 
152 #if !defined(ESP8266) // See notes in .cpp
153  // Hardware SPI constructor using an arbitrary SPI peripheral: expects
154  // width & height (rotation 0), SPIClass pointer, 2 signal pins (cs, dc)
155  // and optional reset pin. cs is required but can be -1 if unused.
156  Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass, int8_t cs,
157  int8_t dc, int8_t rst = -1);
158 #endif // end !ESP8266
159 
160  // Parallel constructor: expects width & height (rotation 0), flag
161  // indicating whether 16-bit (true) or 8-bit (false) interface, 3 signal
162  // pins (d0, wr, dc), 3 optional pins (cs, rst, rd). 16-bit parallel
163  // isn't even fully implemented but the 'wide' flag was added as a
164  // required argument to avoid ambiguity with other constructors.
165  Adafruit_SPITFT(uint16_t w, uint16_t h, tftBusWidth busWidth, int8_t d0,
166  int8_t wr, int8_t dc, int8_t cs = -1, int8_t rst = -1,
167  int8_t rd = -1);
168 
169  // DESTRUCTOR ----------------------------------------------------------
170 
171  ~Adafruit_SPITFT(){};
172 
173  // CLASS MEMBER FUNCTIONS ----------------------------------------------
174 
175  // These first two functions MUST be declared by subclasses:
176 
181  virtual void begin(uint32_t freq) = 0;
182 
195  virtual void setAddrWindow(uint16_t x, uint16_t y, uint16_t w,
196  uint16_t h) = 0;
197 
198  // Remaining functions do not need to be declared in subclasses
199  // unless they wish to provide hardware-specific optimizations.
200  // Brief comments here...documented more thoroughly in .cpp file.
201 
202  // Subclass' begin() function invokes this to initialize hardware.
203  // freq=0 to use default SPI speed. spiMode must be one of the SPI_MODEn
204  // values defined in SPI.h, which are NOT the same as 0 for SPI_MODE0,
205  // 1 for SPI_MODE1, etc...use ONLY the SPI_MODEn defines! Only!
206  // Name is outdated (interface may be parallel) but for compatibility:
207  void initSPI(uint32_t freq = 0, uint8_t spiMode = SPI_MODE0);
208  void setSPISpeed(uint32_t freq);
209  // Chip select and/or hardware SPI transaction start as needed:
210  void startWrite(void);
211  // Chip deselect and/or hardware SPI transaction end as needed:
212  void endWrite(void);
213  void sendCommand(uint8_t commandByte, uint8_t *dataBytes,
214  uint8_t numDataBytes);
215  void sendCommand(uint8_t commandByte, const uint8_t *dataBytes = NULL,
216  uint8_t numDataBytes = 0);
217  void sendCommand16(uint16_t commandWord, const uint8_t *dataBytes = NULL,
218  uint8_t numDataBytes = 0);
219  uint8_t readcommand8(uint8_t commandByte, uint8_t index = 0);
220  uint16_t readcommand16(uint16_t addr);
221 
222  // These functions require a chip-select and/or SPI transaction
223  // around them. Higher-level graphics primitives might start a
224  // single transaction and then make multiple calls to these functions
225  // (e.g. circle or text rendering might make repeated lines or rects)
226  // before ending the transaction. It's more efficient than starting a
227  // transaction every time.
228  void writePixel(int16_t x, int16_t y, uint16_t color);
229  void writePixels(uint16_t *colors, uint32_t len, bool block = true,
230  bool bigEndian = false);
231  void writeColor(uint16_t color, uint32_t len);
232  void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h,
233  uint16_t color);
234  void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
235  void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
236  // This is a new function, similar to writeFillRect() except that
237  // all arguments MUST be onscreen, sorted and clipped. If higher-level
238  // primitives can handle their own sorting/clipping, it avoids repeating
239  // such operations in the low-level code, making it potentially faster.
240  // CALLING THIS WITH UNCLIPPED OR NEGATIVE VALUES COULD BE DISASTROUS.
241  inline void writeFillRectPreclipped(int16_t x, int16_t y, int16_t w,
242  int16_t h, uint16_t color);
243  // Another new function, companion to the new non-blocking
244  // writePixels() variant.
245  void dmaWait(void);
246  // Used by writePixels() in some situations, but might have rare need in
247  // user code, so it's public...
248  bool dmaBusy(void) const; // true if DMA is used and busy, false otherwise
249  void swapBytes(uint16_t *src, uint32_t len, uint16_t *dest = NULL);
250 
251  // These functions are similar to the 'write' functions above, but with
252  // a chip-select and/or SPI transaction built-in. They're typically used
253  // solo -- that is, as graphics primitives in themselves, not invoked by
254  // higher-level primitives (which should use the functions above).
255  void drawPixel(int16_t x, int16_t y, uint16_t color);
256  void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
257  void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
258  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
259  // A single-pixel push encapsulated in a transaction. I don't think
260  // this is used anymore (BMP demos might've used it?) but is provided
261  // for backward compatibility, consider it deprecated:
262  void pushColor(uint16_t color);
263 
264  using Adafruit_GFX::drawRGBBitmap; // Check base class first
265  void drawRGBBitmap(int16_t x, int16_t y, uint16_t *pcolors, int16_t w,
266  int16_t h);
267 
268  void invertDisplay(bool i);
269  uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
270 
271  // Despite parallel additions, function names kept for compatibility:
272  void spiWrite(uint8_t b); // Write single byte as DATA
273  void writeCommand(uint8_t cmd); // Write single byte as COMMAND
274  uint8_t spiRead(void); // Read single byte of data
275  void write16(uint16_t w); // Write 16-bit value as DATA
276  void writeCommand16(uint16_t cmd); // Write 16-bit value as COMMAND
277  uint16_t read16(void); // Read single 16-bit value
278 
279  // Most of these low-level functions were formerly macros in
280  // Adafruit_SPITFT_Macros.h. Some have been made into inline functions
281  // to avoid macro mishaps. Despite the addition of code for a parallel
282  // display interface, the names have been kept for backward
283  // compatibility (some subclasses may be invoking these):
284  void SPI_WRITE16(uint16_t w); // Not inline
285  void SPI_WRITE32(uint32_t l); // Not inline
286  // Old code had both a spiWrite16() function and SPI_WRITE16 macro
287  // in addition to the SPI_WRITE32 macro. The latter two have been
288  // made into functions here, and spiWrite16() removed (use SPI_WRITE16()
289  // instead). It looks like most subclasses had gotten comfortable with
290  // SPI_WRITE16 and SPI_WRITE32 anyway so those names were kept rather
291  // than the less-obnoxious camelcase variants, oh well.
292 
293  // Placing these functions entirely in the class definition inlines
294  // them implicitly them while allowing their use in other code:
295 
302  void SPI_CS_HIGH(void) {
303 #if defined(USE_FAST_PINIO)
304 #if defined(HAS_PORT_SET_CLR)
305 #if defined(KINETISK)
306  *csPortSet = 1;
307 #else // !KINETISK
308  *csPortSet = csPinMask;
309 #endif // end !KINETISK
310 #else // !HAS_PORT_SET_CLR
311  *csPort |= csPinMaskSet;
312 #endif // end !HAS_PORT_SET_CLR
313 #else // !USE_FAST_PINIO
314  digitalWrite(_cs, HIGH);
315 #endif // end !USE_FAST_PINIO
316  }
317 
324  void SPI_CS_LOW(void) {
325 #if defined(USE_FAST_PINIO)
326 #if defined(HAS_PORT_SET_CLR)
327 #if defined(KINETISK)
328  *csPortClr = 1;
329 #else // !KINETISK
330  *csPortClr = csPinMask;
331 #endif // end !KINETISK
332 #else // !HAS_PORT_SET_CLR
333  *csPort &= csPinMaskClr;
334 #endif // end !HAS_PORT_SET_CLR
335 #else // !USE_FAST_PINIO
336  digitalWrite(_cs, LOW);
337 #endif // end !USE_FAST_PINIO
338  }
339 
343  void SPI_DC_HIGH(void) {
344 #if defined(USE_FAST_PINIO)
345 #if defined(HAS_PORT_SET_CLR)
346 #if defined(KINETISK)
347  *dcPortSet = 1;
348 #else // !KINETISK
349  *dcPortSet = dcPinMask;
350 #endif // end !KINETISK
351 #else // !HAS_PORT_SET_CLR
352  *dcPort |= dcPinMaskSet;
353 #endif // end !HAS_PORT_SET_CLR
354 #else // !USE_FAST_PINIO
355  digitalWrite(_dc, HIGH);
356 #endif // end !USE_FAST_PINIO
357  }
358 
362  void SPI_DC_LOW(void) {
363 #if defined(USE_FAST_PINIO)
364 #if defined(HAS_PORT_SET_CLR)
365 #if defined(KINETISK)
366  *dcPortClr = 1;
367 #else // !KINETISK
368  *dcPortClr = dcPinMask;
369 #endif // end !KINETISK
370 #else // !HAS_PORT_SET_CLR
371  *dcPort &= dcPinMaskClr;
372 #endif // end !HAS_PORT_SET_CLR
373 #else // !USE_FAST_PINIO
374  digitalWrite(_dc, LOW);
375 #endif // end !USE_FAST_PINIO
376  }
377 
378 protected:
379  // A few more low-level member functions -- some may have previously
380  // been macros. Shouldn't have a need to access these externally, so
381  // they've been moved to the protected section. Additionally, they're
382  // declared inline here and the code is in the .cpp file, since outside
383  // code doesn't need to see these.
384  inline void SPI_MOSI_HIGH(void);
385  inline void SPI_MOSI_LOW(void);
386  inline void SPI_SCK_HIGH(void);
387  inline void SPI_SCK_LOW(void);
388  inline bool SPI_MISO_READ(void);
389  inline void SPI_BEGIN_TRANSACTION(void);
390  inline void SPI_END_TRANSACTION(void);
391  inline void TFT_WR_STROBE(void); // Parallel interface write strobe
392  inline void TFT_RD_HIGH(void); // Parallel interface read high
393  inline void TFT_RD_LOW(void); // Parallel interface read low
394 
395  // CLASS INSTANCE VARIABLES --------------------------------------------
396 
397  // Here be dragons! There's a big union of three structures here --
398  // one each for hardware SPI, software (bitbang) SPI, and parallel
399  // interfaces. This is to save some memory, since a display's connection
400  // will be only one of these. The order of some things is a little weird
401  // in an attempt to get values to align and pack better in RAM.
402 
403 #if defined(USE_FAST_PINIO)
404 #if defined(HAS_PORT_SET_CLR)
405  PORTreg_t csPortSet;
406  PORTreg_t csPortClr;
407  PORTreg_t dcPortSet;
408  PORTreg_t dcPortClr;
409 #else // !HAS_PORT_SET_CLR
410  PORTreg_t csPort;
411  PORTreg_t dcPort;
412 #endif // end HAS_PORT_SET_CLR
413 #endif // end USE_FAST_PINIO
414 #if defined(__cplusplus) && (__cplusplus >= 201100)
415  union {
416 #endif
417  struct { // Values specific to HARDWARE SPI:
418  SPIClass *_spi;
419 #if defined(SPI_HAS_TRANSACTION)
420  SPISettings settings;
421 #else
422  uint32_t _freq;
423 #endif
424  uint32_t _mode;
425  } hwspi;
426  struct { // Values specific to SOFTWARE SPI:
427 #if defined(USE_FAST_PINIO)
428  PORTreg_t misoPort;
429 #if defined(HAS_PORT_SET_CLR)
430  PORTreg_t mosiPortSet;
431  PORTreg_t mosiPortClr;
432  PORTreg_t sckPortSet;
433  PORTreg_t sckPortClr;
434 #if !defined(KINETISK)
435  ADAGFX_PORT_t mosiPinMask;
436  ADAGFX_PORT_t sckPinMask;
437 #endif // end !KINETISK
438 #else // !HAS_PORT_SET_CLR
439  PORTreg_t mosiPort;
440  PORTreg_t sckPort;
441  ADAGFX_PORT_t mosiPinMaskSet;
442  ADAGFX_PORT_t mosiPinMaskClr;
443  ADAGFX_PORT_t sckPinMaskSet;
444  ADAGFX_PORT_t sckPinMaskClr;
445 #endif // end HAS_PORT_SET_CLR
446 #if !defined(KINETISK)
447  ADAGFX_PORT_t misoPinMask;
448 #endif // end !KINETISK
449 #endif // end USE_FAST_PINIO
450  int8_t _mosi;
451  int8_t _miso;
452  int8_t _sck;
453  } swspi;
454  struct { // Values specific to 8-bit parallel:
455 #if defined(USE_FAST_PINIO)
456 
457 #if defined(__IMXRT1052__) || defined(__IMXRT1062__) // Teensy 4.x
458  volatile uint32_t *writePort;
459  volatile uint32_t *readPort;
460 #else
461  volatile uint8_t *writePort;
462  volatile uint8_t *readPort;
463 #endif
464 #if defined(HAS_PORT_SET_CLR)
465  // Port direction register pointers are always 8-bit regardless of
466  // PORTreg_t -- even if 32-bit port, we modify a byte-aligned 8 bits.
467 #if defined(__IMXRT1052__) || defined(__IMXRT1062__) // Teensy 4.x
468  volatile uint32_t *dirSet;
469  volatile uint32_t *dirClr;
470 #else
471  volatile uint8_t *dirSet;
472  volatile uint8_t *dirClr;
473 #endif
474  PORTreg_t wrPortSet;
475  PORTreg_t wrPortClr;
476  PORTreg_t rdPortSet;
477  PORTreg_t rdPortClr;
478 #if !defined(KINETISK)
479  ADAGFX_PORT_t wrPinMask;
480 #endif // end !KINETISK
481  ADAGFX_PORT_t rdPinMask;
482 #else // !HAS_PORT_SET_CLR
483  // Port direction register pointer is always 8-bit regardless of
484  // PORTreg_t -- even if 32-bit port, we modify a byte-aligned 8 bits.
485  volatile uint8_t *portDir;
486  PORTreg_t wrPort;
487  PORTreg_t rdPort;
488  ADAGFX_PORT_t wrPinMaskSet;
489  ADAGFX_PORT_t wrPinMaskClr;
490  ADAGFX_PORT_t rdPinMaskSet;
491  ADAGFX_PORT_t rdPinMaskClr;
492 #endif // end HAS_PORT_SET_CLR
493 #endif // end USE_FAST_PINIO
494  int8_t _d0;
495  int8_t _wr;
496  int8_t _rd;
497  bool wide = 0;
498  } tft8;
499 #if defined(__cplusplus) && (__cplusplus >= 201100)
500  };
501 #endif
502 #if defined(USE_SPI_DMA) && \
503  (defined(__SAMD51__) || \
504  defined(ARDUINO_SAMD_ZERO)) // Used by hardware SPI and tft8
505  Adafruit_ZeroDMA dma;
506  DmacDescriptor *dptr = NULL;
507  DmacDescriptor *descriptor = NULL;
508  uint16_t *pixelBuf[2];
509  uint16_t maxFillLen;
510  uint16_t lastFillColor = 0;
511  uint32_t lastFillLen = 0;
512  uint8_t onePixelBuf;
513 #endif
514 #if defined(USE_FAST_PINIO)
515 #if defined(HAS_PORT_SET_CLR)
516 #if !defined(KINETISK)
517  ADAGFX_PORT_t csPinMask;
518  ADAGFX_PORT_t dcPinMask;
519 #endif // end !KINETISK
520 #else // !HAS_PORT_SET_CLR
521  ADAGFX_PORT_t csPinMaskSet;
522  ADAGFX_PORT_t csPinMaskClr;
523  ADAGFX_PORT_t dcPinMaskSet;
524  ADAGFX_PORT_t dcPinMaskClr;
525 #endif // end HAS_PORT_SET_CLR
526 #endif // end USE_FAST_PINIO
527  uint8_t connection;
528  int8_t _rst;
529  int8_t _cs;
530  int8_t _dc;
531 
532  int16_t _xstart = 0;
533  int16_t _ystart = 0;
534  uint8_t invertOnCommand = 0;
535  uint8_t invertOffCommand = 0;
536 
537  uint32_t _freq = 0;
538 };
539 
540 #endif // end __AVR_ATtiny85__ __AVR_ATtiny84__
541 #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:1956
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:2287
uint32_t _freq
SPI bitrate (if no SPI transactions)
Definition: Adafruit_SPITFT.h:422
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:1004
uint8_t invertOffCommand
Command to disable invert mode.
Definition: Adafruit_SPITFT.h:535
int8_t _rd
Read strobe pin # (or -1)
Definition: Adafruit_SPITFT.h:496
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:954
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:2449
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:2078
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:2120
int8_t _sck
SCK pin #.
Definition: Adafruit_SPITFT.h:452
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:1884
void TFT_RD_LOW(void)
Set the RD line LOW. Used for parallel-connected interfaces when reading data.
Definition: Adafruit_SPITFT.cpp:2609
int8_t _cs
Chip select pin # (or -1)
Definition: Adafruit_SPITFT.h:529
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:1211
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:2307
void SPI_SCK_HIGH(void)
Set the software (bitbang) SPI SCK line HIGH.
Definition: Adafruit_SPITFT.cpp:2388
int8_t _miso
MISO pin #.
Definition: Adafruit_SPITFT.h:451
uint8_t connection
TFT_HARD_SPI, TFT_SOFT_SPI, etc.
Definition: Adafruit_SPITFT.h:527
bool SPI_MISO_READ(void)
Read the state of the software (bitbang) SPI MISO line.
Definition: Adafruit_SPITFT.cpp:2427
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:1788
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:1676
void invertDisplay(bool i)
Invert the colors of the display (if supported by hardware). Self-contained, no transaction setup req...
Definition: Adafruit_SPITFT.cpp:1929
tftBusWidth
Definition: Adafruit_SPITFT.h:104
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:1177
Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t cs, int8_t dc, int8_t mosi, int8_t sck, int8_t rst=-1, int8_t miso=-1)
Adafruit_SPITFT constructor for software (bitbang) SPI.
Definition: Adafruit_SPITFT.cpp:126
void setSPISpeed(uint32_t freq)
Allow changing the SPI clock speed after initialization.
Definition: Adafruit_SPITFT.cpp:907
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:1001
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:324
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:1829
int8_t _wr
Write strobe pin #.
Definition: Adafruit_SPITFT.h:495
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:1862
int16_t _ystart
Internal framebuffer Y offset.
Definition: Adafruit_SPITFT.h:533
void SPI_SCK_LOW(void)
Set the software (bitbang) SPI SCK line LOW.
Definition: Adafruit_SPITFT.cpp:2407
void SPI_MOSI_HIGH(void)
Set the software (bitbang) SPI MOSI line HIGH.
Definition: Adafruit_SPITFT.cpp:2350
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:2023
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:1730
uint32_t _mode
SPI data mode (transactions or no)
Definition: Adafruit_SPITFT.h:424
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:2208
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:1544
bool dmaBusy(void) const
Check if DMA transfer is active. Always returts false if DMA is not enabled.
Definition: Adafruit_SPITFT.cpp:1197
void SPI_DC_HIGH(void)
Set the data/command line HIGH (data mode).
Definition: Adafruit_SPITFT.h:343
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:302
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:2321
volatile ADAGFX_PORT_t * PORTreg_t
PORT register type.
Definition: Adafruit_SPITFT.h:67
SPIClass * _spi
SPI class pointer.
Definition: Adafruit_SPITFT.h:418
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:2369
Adafruit_SPITFT is an intermediary class between Adafruit_GFX and various hardware-specific subclasse...
Definition: Adafruit_SPITFT.h:131
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:1700
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:2165
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:1945
int8_t _d0
Data pin 0 #.
Definition: Adafruit_SPITFT.h:494
void SPI_DC_LOW(void)
Set the data/command line LOW (command mode).
Definition: Adafruit_SPITFT.h:362
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:933
uint8_t invertOnCommand
Command to enable invert mode.
Definition: Adafruit_SPITFT.h:534
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:921
void TFT_WR_STROBE(void)
Set the WR line LOW, then HIGH. Used for parallel-connected interfaces when writing data...
Definition: Adafruit_SPITFT.cpp:2569
bool wide
If true, is 16-bit interface.
Definition: Adafruit_SPITFT.h:497
int8_t _dc
Data/command pin #.
Definition: Adafruit_SPITFT.h:530
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:2148
int16_t _xstart
Internal framebuffer X offset.
Definition: Adafruit_SPITFT.h:532
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:536
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:2593
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:1596
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:2505
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:2224
uint32_t ADAGFX_PORT_t
PORT values are 32-bit.
Definition: Adafruit_SPITFT.h:65
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:2059
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:971
int8_t _rst
Reset pin # (or -1)
Definition: Adafruit_SPITFT.h:528
int8_t _mosi
MOSI pin #.
Definition: Adafruit_SPITFT.h:450
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:1632