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