128x64 EasyC OLED Display 1.0.0
This is a library for Soldered OLED Display
Loading...
Searching...
No Matches
Adafruit_SPITFT Class Referenceabstract

Adafruit_SPITFT is an intermediary class between Adafruit_GFX and various hardware-specific subclasses for different displays. It handles certain operations that are common to a range of displays (address window, area fills, etc.). Originally these were all color TFT displays interfaced via SPI, but it's since expanded to include color OLEDs and parallel-interfaced TFTs. THE NAME HAS BEEN KEPT TO AVOID BREAKING A LOT OF SUBCLASSES AND EXAMPLE CODE. Many of the class member functions similarly live on with names that don't necessarily accurately describe what they're doing, again to avoid breaking a lot of other code. If in doubt, read the comments. More...

#include <Adafruit_SPITFT.h>

Inherits Adafruit_GFX.

Public Member Functions

 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.
 
 Adafruit_SPITFT (uint16_t w, uint16_t h, int8_t cs, int8_t dc, int8_t rst=-1)
 Adafruit_SPITFT constructor for hardware SPI using the board's default SPI peripheral.
 
 Adafruit_SPITFT (uint16_t w, uint16_t h, SPIClass *spiClass, int8_t cs, int8_t dc, int8_t rst=-1)
 Adafruit_SPITFT constructor for hardware SPI using a specific SPI peripheral.
 
 Adafruit_SPITFT (uint16_t w, uint16_t h, tftBusWidth busWidth, int8_t d0, int8_t wr, int8_t dc, int8_t cs=-1, int8_t rst=-1, int8_t rd=-1)
 Adafruit_SPITFT constructor for parallel display connection.
 
 ~Adafruit_SPITFT ()
 
virtual void begin (uint32_t freq)=0
 Display-specific initialization function.
 
virtual void setAddrWindow (uint16_t x, uint16_t y, uint16_t w, uint16_t h)=0
 Set up the specific display hardware's "address window" for subsequent pixel-pushing operations.
 
void initSPI (uint32_t freq=0, uint8_t spiMode=SPI_MODE0)
 Configure microcontroller pins for TFT interfacing. Typically called by a subclass' begin() function.
 
void setSPISpeed (uint32_t freq)
 Allow changing the SPI clock speed after initialization.
 
void startWrite (void)
 Call before issuing command(s) or data to display. Performs chip-select (if required) and starts an SPI transaction (if using hardware SPI and transactions are supported). Required for all display types; not an SPI-specific function.
 
void endWrite (void)
 Call after issuing command(s) or data to display. Performs chip-deselect (if required) and ends an SPI transaction (if using hardware SPI and transactions are supported). Required for all display types; not an SPI-specific function.
 
void sendCommand (uint8_t commandByte, uint8_t *dataBytes, uint8_t numDataBytes)
 Adafruit_SPITFT Send Command handles complete sending of commands and data.
 
void sendCommand (uint8_t commandByte, const uint8_t *dataBytes=NULL, uint8_t numDataBytes=0)
 Adafruit_SPITFT Send Command handles complete sending of commands and data.
 
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 displays. Currently somewhat rigged for the NT35510, which has the odd behavior of wanting commands 16-bit, but subsequent data as 8-bit values, despite the 16-bit bus (high byte is always 0). Also seems to require issuing and incrementing address with each transfer.
 
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/supported and should be avoided, function is only included because some of the examples use it.
 
uint16_t readcommand16 (uint16_t addr)
 Read 16 bits of data from display register. For 16-bit parallel displays only.
 
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 startWrite() call.
 
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() and setAddrWindow() calls.
 
void writeColor (uint16_t color, uint32_t len)
 Issue a series of pixels, all the same color. Not self- contained; should follow startWrite() and setAddrWindow() calls.
 
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'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 'raw' implementation.
 
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; should follow startWrite(). Typically used by higher-level graphics primitives; user code shouldn't need to call this and is likely to use the self- contained drawFastHLine() instead.
 
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 follow startWrite(). Typically used by higher-level graphics primitives; user code shouldn't need to call this and is likely to use the self- contained drawFastVLine() instead.
 
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.
 
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).
 
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() below in some situations, but may also be helpful for user code occasionally.
 
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 transaction as needed (see writePixel(x,y,color) for a lower-level variant). Edge clipping is performed here.
 
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 (see writeFillRect() or writeFillRectPreclipped() for lower-level variants). Edge clipping and rejection is performed here.
 
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 writeFastHLine() for a lower-level variant). Edge clipping and rejection is performed here.
 
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 writeFastHLine() for a lower- level variant). Edge clipping and rejection is performed here.
 
void pushColor (uint16_t color)
 Essentially writePixel() with a transaction around it. I don't think this is in use by any of our code anymore (believe it was for some older BMP-reading examples), but is kept here in case any user code relies on it. Consider it DEPRECATED.
 
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 reduction performed. Adapted from https://github.com/PaulStoffregen/ILI9341_t3 by Marc MERLIN. See examples/pictureEmbed to use this. 5/6/2017: function name and arguments have changed for compatibility with current GFX library and to avoid naming problems in prior implementation. Formerly drawBitmap() with arguments in different order. Handles its own transaction and edge clipping/rejection.
 
void invertDisplay (bool i)
 Invert the colors of the display (if supported by hardware). Self-contained, no transaction setup required.
 
uint16_t color565 (uint8_t r, uint8_t g, uint8_t b)
 Given 8-bit red, green and blue values, return a 'packed' 16-bit color value in '565' RGB format (5 bits red, 6 bits green, 5 bits blue). This is just a mathematical operation, no hardware is touched.
 
void spiWrite (uint8_t b)
 Issue a single 8-bit value to the display. Chip-select, transaction and data/command selection must have been previously set – this ONLY issues the byte. This is another of those functions in the library with a now-not-accurate name that's being maintained for compatibility with outside code. This function is used even if display connection is parallel.
 
void writeCommand (uint8_t cmd)
 Write a single command byte to the display. Chip-select and transaction must have been previously set – this ONLY sets the device to COMMAND mode, issues the byte and then restores DATA mode. There is no corresponding explicit writeData() function – just use spiWrite().
 
uint8_t spiRead (void)
 Read a single 8-bit value from the display. Chip-select and transaction must have been previously set – this ONLY reads the byte. This is another of those functions in the library with a now-not-accurate name that's being maintained for compatibility with outside code. This function is used even if display connection is parallel.
 
void write16 (uint16_t w)
 Issue a single 16-bit value to the display. Chip-select, transaction and data/command selection must have been previously set – this ONLY issues the word. Thus operates ONLY on 'wide' (16-bit) parallel displays!
 
void writeCommand16 (uint16_t cmd)
 Write a single command word to the display. Chip-select and transaction must have been previously set – this ONLY sets the device to COMMAND mode, issues the byte and then restores DATA mode. This operates ONLY on 'wide' (16-bit) parallel displays!
 
uint16_t read16 (void)
 Read a single 16-bit value from the display. Chip-select and transaction must have been previously set – this ONLY reads the byte. This operates ONLY on 'wide' (16-bit) parallel displays!
 
void SPI_WRITE16 (uint16_t w)
 Issue a single 16-bit value to the display. Chip-select, transaction and data/command selection must have been previously set – this ONLY issues the word. Despite the name, this function is used even if display connection is parallel; name was maintaned for backward compatibility. Naming is also not consistent with the 8-bit version, spiWrite(). Sorry about that. Again, staying compatible with outside code.
 
void SPI_WRITE32 (uint32_t l)
 Issue a single 32-bit value to the display. Chip-select, transaction and data/command selection must have been previously set – this ONLY issues the longword. Despite the name, this function is used even if display connection is parallel; name was maintaned for backward compatibility. Naming is also not consistent with the 8-bit version, spiWrite(). Sorry about that. Again, staying compatible with outside code.
 
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 calling function. Despite function name, this is used even if the display connection is parallel.
 
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 calling function. Despite function name, this is used even if the display connection is parallel.
 
void SPI_DC_HIGH (void)
 Set the data/command line HIGH (data mode).
 
void SPI_DC_LOW (void)
 Set the data/command line LOW (command mode).
 
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 devices; no color reduction performed.
 
void drawRGBBitmap (int16_t x, int16_t y, const uint16_t bitmap[], const uint8_t mask[], int16_t w, int16_t h)
 Draw a PROGMEM-resident 16-bit image (RGB 5/6/5) with a 1-bit mask (set bits = opaque, unset bits = clear) at the specified (x,y) position. BOTH buffers (color and mask) must be PROGMEM-resident. For 16-bit display devices; no color reduction performed.
 
void drawRGBBitmap (int16_t x, int16_t y, uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h)
 Draw a RAM-resident 16-bit image (RGB 5/6/5) with a 1-bit mask (set bits = opaque, unset bits = clear) at the specified (x,y) position. BOTH buffers (color and mask) must be RAM-resident. For 16-bit display devices; no color reduction performed.
 
- Public Member Functions inherited from Adafruit_GFX
 Adafruit_GFX (int16_t w, int16_t h)
 Instatiate a GFX context for graphics! Can only be done by a superclass.
 
virtual void writeLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 Write a line. Bresenham's algorithm - thx wikpedia.
 
virtual void setRotation (uint8_t r)
 Set rotation setting for display.
 
virtual void fillScreen (uint16_t color)
 Fill the screen completely with one color. Update in subclasses if desired!
 
virtual void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 Draw a line.
 
virtual void drawRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 Draw a rectangle with no fill color.
 
void drawCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 Draw a circle outline.
 
void drawCircleHelper (int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)
 Quarter-circle drawer, used to do circles and roundrects.
 
void fillCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 Draw a circle with filled color.
 
void fillCircleHelper (int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)
 Quarter-circle drawer with fill, used for circles and roundrects.
 
void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 Draw a triangle with no fill color.
 
void fillTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 Draw a triangle with color-fill.
 
void drawRoundRect (int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
 Draw a rounded rectangle with no fill color.
 
void fillRoundRect (int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
 Draw a rounded rectangle with fill color.
 
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 color (unset bits are transparent).
 
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 at the specified (x,y) position, using the specified foreground (for set bits) and background (unset bits) colors.
 
void drawBitmap (int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)
 Draw a RAM-resident 1-bit image at the specified (x,y) position, using the specified foreground color (unset bits are transparent).
 
void drawBitmap (int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg)
 Draw a RAM-resident 1-bit image at the specified (x,y) position, using the specified foreground (for set bits) and background (unset bits) colors.
 
void drawXBitmap (int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color)
 Draw PROGMEM-resident XBitMap Files (*.xbm), exported from GIMP. Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in editor. C Array can be directly used with this function. There is no RAM-resident version of this function; if generating bitmaps in RAM, use the format defined by drawBitmap() and call that instead.
 
void drawGrayscaleBitmap (int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h)
 Draw a PROGMEM-resident 8-bit image (grayscale) at the specified (x,y) pos. Specifically for 8-bit display devices such as IS31FL3731; no color reduction/expansion is performed.
 
void drawGrayscaleBitmap (int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h)
 Draw a RAM-resident 8-bit image (grayscale) at the specified (x,y) pos. Specifically for 8-bit display devices such as IS31FL3731; no color reduction/expansion is performed.
 
void drawGrayscaleBitmap (int16_t x, int16_t y, const uint8_t bitmap[], const uint8_t mask[], int16_t w, int16_t h)
 Draw a PROGMEM-resident 8-bit image (grayscale) with a 1-bit mask (set bits = opaque, unset bits = clear) at the specified (x,y) position. BOTH buffers (grayscale and mask) must be PROGMEM-resident. Specifically for 8-bit display devices such as IS31FL3731; no color reduction/expansion is performed.
 
void drawGrayscaleBitmap (int16_t x, int16_t y, uint8_t *bitmap, uint8_t *mask, int16_t w, int16_t h)
 Draw a RAM-resident 8-bit image (grayscale) with a 1-bit mask (set bits = opaque, unset bits = clear) at the specified (x,y) position. BOTH buffers (grayscale and mask) must be RAM-residentt, no mix-and-match Specifically for 8-bit display devices such as IS31FL3731; no color reduction/expansion is performed.
 
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 devices; no color reduction performed.
 
void drawRGBBitmap (int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h)
 Draw a RAM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position. For 16-bit display devices; no color reduction performed.
 
void drawRGBBitmap (int16_t x, int16_t y, const uint16_t bitmap[], const uint8_t mask[], int16_t w, int16_t h)
 Draw a PROGMEM-resident 16-bit image (RGB 5/6/5) with a 1-bit mask (set bits = opaque, unset bits = clear) at the specified (x,y) position. BOTH buffers (color and mask) must be PROGMEM-resident. For 16-bit display devices; no color reduction performed.
 
void drawRGBBitmap (int16_t x, int16_t y, uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h)
 Draw a RAM-resident 16-bit image (RGB 5/6/5) with a 1-bit mask (set bits = opaque, unset bits = clear) at the specified (x,y) position. BOTH buffers (color and mask) must be RAM-resident. For 16-bit display devices; no color reduction performed.
 
void drawChar (int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
 Draw a single character.
 
void drawChar (int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size_x, uint8_t size_y)
 Draw a single character.
 
void getTextBounds (const char *string, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)
 Helper to determine size of a string with current font/size. Pass string and a cursor position, returns UL corner and W,H.
 
void getTextBounds (const __FlashStringHelper *s, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)
 Helper to determine size of a PROGMEM string with current font/size. Pass string and a cursor position, returns UL corner and W,H.
 
void getTextBounds (const String &str, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)
 Helper to determine size of a string with current font/size. Pass string and a cursor position, returns UL corner and W,H.
 
void setTextSize (uint8_t s)
 Set text 'magnification' size. Each increase in s makes 1 pixel that much bigger.
 
void setTextSize (uint8_t sx, uint8_t sy)
 Set text 'magnification' size. Each increase in s makes 1 pixel that much bigger.
 
void setFont (const GFXfont *f=NULL)
 Set the font to display when print()ing, either custom or default.
 
void setCursor (int16_t x, int16_t y)
 Set text cursor location.
 
void setTextColor (uint16_t c)
 Set text font color with transparant background.
 
void setTextColor (uint16_t c, uint16_t bg)
 Set text font color with custom background color.
 
void setTextWrap (bool w)
 Set whether text that is too long for the screen width should automatically wrap around to the next line (else clip right).
 
void cp437 (bool x=true)
 Enable (or disable) Code Page 437-compatible charset. There was an error in glcdfont.c for the longest time – one character (#176, the 'light shade' block) was missing – this threw off the index of every character that followed it. But a TON of code has been written with the erroneous character indices. By default, the library uses the original 'wrong' behavior and old sketches will still work. Pass 'true' to this function to use correct CP437 character values in your code.
 
virtual size_t write (uint8_t)
 Print one byte/character of data, used to support print()
 
virtual void write (uint8_t)
 
int16_t width (void) const
 Get width of the display, accounting for current rotation.
 
int16_t height (void) const
 Get height of the display, accounting for current rotation.
 
uint8_t getRotation (void) const
 Get rotation setting for display.
 
int16_t getCursorX (void) const
 Get text cursor X location.
 
int16_t getCursorY (void) const
 Get text cursor Y location.
 

Protected Member Functions

void SPI_MOSI_HIGH (void)
 Set the software (bitbang) SPI MOSI line HIGH.
 
void SPI_MOSI_LOW (void)
 Set the software (bitbang) SPI MOSI line LOW.
 
void SPI_SCK_HIGH (void)
 Set the software (bitbang) SPI SCK line HIGH.
 
void SPI_SCK_LOW (void)
 Set the software (bitbang) SPI SCK line LOW.
 
bool SPI_MISO_READ (void)
 Read the state of the software (bitbang) SPI MISO line.
 
void SPI_BEGIN_TRANSACTION (void)
 Start an SPI transaction if using the hardware SPI interface to the display. If using an earlier version of the Arduino platform (before the addition of SPI transactions), this instead attempts to set up the SPI clock and mode. No action is taken if the connection is not hardware SPI-based. This does NOT include a chip-select operation – see startWrite() for a function that encapsulated both actions.
 
void SPI_END_TRANSACTION (void)
 End an SPI transaction if using the hardware SPI interface to the display. No action is taken if the connection is not hardware SPI-based or if using an earlier version of the Arduino platform (before the addition of SPI transactions). This does NOT include a chip-deselect operation – see endWrite() for a function that encapsulated both actions.
 
void TFT_WR_STROBE (void)
 Set the WR line LOW, then HIGH. Used for parallel-connected interfaces when writing data.
 
void TFT_RD_HIGH (void)
 Set the RD line HIGH. Used for parallel-connected interfaces when reading data.
 
void TFT_RD_LOW (void)
 Set the RD line LOW. Used for parallel-connected interfaces when reading data.
 
- Protected Member Functions inherited from Adafruit_GFX
void charBounds (unsigned char c, int16_t *x, int16_t *y, int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy)
 Helper to determine size of a character with current font/size. Broke this out as it's used by both the PROGMEM- and RAM-resident getTextBounds() functions.
 

Protected Attributes

PORTreg_t csPortSet
 PORT register for chip select SET.
 
PORTreg_t csPortClr
 PORT register for chip select CLEAR.
 
PORTreg_t dcPortSet
 PORT register for data/command SET.
 
PORTreg_t dcPortClr
 PORT register for data/command CLEAR.
 
PORTreg_t csPort
 PORT register for chip select.
 
PORTreg_t dcPort
 PORT register for data/command.
 
union { 
 
   struct { 
 
      SPIClass *   _spi 
 SPI class pointer. More...
 
      SPISettings   settings 
 SPI transaction settings. More...
 
      uint32_t   _freq 
 SPI bitrate (if no SPI transactions) More...
 
      uint32_t   _mode 
 SPI data mode (transactions or no) More...
 
   }   hwspi 
 Hardware SPI values. More...
 
   struct { 
 
      PORTreg_t   misoPort 
 PORT (PIN) register for MISO. More...
 
      PORTreg_t   mosiPortSet 
 PORT register for MOSI SET. More...
 
      PORTreg_t   mosiPortClr 
 PORT register for MOSI CLEAR. More...
 
      PORTreg_t   sckPortSet 
 PORT register for SCK SET. More...
 
      PORTreg_t   sckPortClr 
 PORT register for SCK CLEAR. More...
 
      ADAGFX_PORT_t   mosiPinMask 
 Bitmask for MOSI. More...
 
      ADAGFX_PORT_t   sckPinMask 
 Bitmask for SCK. More...
 
      PORTreg_t   mosiPort 
 PORT register for MOSI. More...
 
      PORTreg_t   sckPort 
 PORT register for SCK. More...
 
      ADAGFX_PORT_t   mosiPinMaskSet 
 Bitmask for MOSI SET (OR) More...
 
      ADAGFX_PORT_t   mosiPinMaskClr 
 Bitmask for MOSI CLEAR (AND) More...
 
      ADAGFX_PORT_t   sckPinMaskSet 
 Bitmask for SCK SET (OR bitmask) More...
 
      ADAGFX_PORT_t   sckPinMaskClr 
 Bitmask for SCK CLEAR (AND) More...
 
      ADAGFX_PORT_t   misoPinMask 
 Bitmask for MISO. More...
 
      int8_t   _mosi 
 MOSI pin #. More...
 
      int8_t   _miso 
 MISO pin #. More...
 
      int8_t   _sck 
 SCK pin #. More...
 
   }   swspi 
 Software SPI values. More...
 
   struct { 
 
      volatile uint32_t *   writePort 
 PORT register for DATA WRITE. More...
 
      volatile uint32_t *   readPort 
 PORT (PIN) register for DATA READ. More...
 
      volatile uint8_t *   writePort 
 PORT register for DATA WRITE. More...
 
      volatile uint8_t *   readPort 
 PORT (PIN) register for DATA READ. More...
 
      volatile uint32_t *   dirSet 
 PORT byte data direction SET. More...
 
      volatile uint32_t *   dirClr 
 PORT byte data direction CLEAR. More...
 
      volatile uint8_t *   dirSet 
 PORT byte data direction SET. More...
 
      volatile uint8_t *   dirClr 
 PORT byte data direction CLEAR. More...
 
      PORTreg_t   wrPortSet 
 PORT register for write strobe SET. More...
 
      PORTreg_t   wrPortClr 
 PORT register for write strobe CLEAR. More...
 
      PORTreg_t   rdPortSet 
 PORT register for read strobe SET. More...
 
      PORTreg_t   rdPortClr 
 PORT register for read strobe CLEAR. More...
 
      ADAGFX_PORT_t   wrPinMask 
 Bitmask for write strobe. More...
 
      ADAGFX_PORT_t   rdPinMask 
 Bitmask for read strobe. More...
 
      volatile uint8_t *   portDir 
 PORT direction register. More...
 
      PORTreg_t   wrPort 
 PORT register for write strobe. More...
 
      PORTreg_t   rdPort 
 PORT register for read strobe. More...
 
      ADAGFX_PORT_t   wrPinMaskSet 
 Bitmask for write strobe SET (OR) More...
 
      ADAGFX_PORT_t   wrPinMaskClr 
 Bitmask for write strobe CLEAR (AND) More...
 
      ADAGFX_PORT_t   rdPinMaskSet 
 Bitmask for read strobe SET (OR) More...
 
      ADAGFX_PORT_t   rdPinMaskClr 
 Bitmask for read strobe CLEAR (AND) More...
 
      int8_t   _d0 
 Data pin 0 #. More...
 
      int8_t   _wr 
 Write strobe pin #. More...
 
      int8_t   _rd 
 Read strobe pin # (or -1) More...
 
      bool   wide = 0 
 If true, is 16-bit interface. More...
 
   }   tft8 
 Parallel interface settings. More...
 
};  
 Only one interface is active.
 
Adafruit_ZeroDMA dma
 DMA instance.
 
DmacDescriptor * dptr = NULL
 1st descriptor
 
DmacDescriptor * descriptor = NULL
 Allocated descriptor list.
 
uint16_t * pixelBuf [2]
 Working buffers.
 
uint16_t maxFillLen
 Max pixels per DMA xfer.
 
uint16_t lastFillColor = 0
 Last color used w/fill.
 
uint32_t lastFillLen = 0
 
uint8_t onePixelBuf
 For hi==lo fill.
 
ADAGFX_PORT_t csPinMask
 Bitmask for chip select.
 
ADAGFX_PORT_t dcPinMask
 Bitmask for data/command.
 
ADAGFX_PORT_t csPinMaskSet
 Bitmask for chip select SET (OR)
 
ADAGFX_PORT_t csPinMaskClr
 Bitmask for chip select CLEAR (AND)
 
ADAGFX_PORT_t dcPinMaskSet
 Bitmask for data/command SET (OR)
 
ADAGFX_PORT_t dcPinMaskClr
 Bitmask for data/command CLEAR (AND)
 
uint8_t connection
 TFT_HARD_SPI, TFT_SOFT_SPI, etc.
 
int8_t _rst
 Reset pin # (or -1)
 
int8_t _cs
 Chip select pin # (or -1)
 
int8_t _dc
 Data/command pin #.
 
int16_t _xstart = 0
 Internal framebuffer X offset.
 
int16_t _ystart = 0
 Internal framebuffer Y offset.
 
uint8_t invertOnCommand = 0
 Command to enable invert mode.
 
uint8_t invertOffCommand = 0
 Command to disable invert mode.
 
- Protected Attributes inherited from Adafruit_GFX
int16_t WIDTH
 This is the 'raw' display width - never changes.
 
int16_t HEIGHT
 This is the 'raw' display height - never changes.
 
int16_t _width
 Display width as modified by current rotation.
 
int16_t _height
 Display height as modified by current rotation.
 
int16_t cursor_x
 x location to start print()ing text
 
int16_t cursor_y
 y location to start print()ing text
 
uint16_t textcolor
 16-bit background color for print()
 
uint16_t textbgcolor
 16-bit text color for print()
 
uint8_t textsize_x
 Desired magnification in X-axis of text to print()
 
uint8_t textsize_y
 Desired magnification in Y-axis of text to print()
 
uint8_t rotation
 Display rotation (0 thru 3)
 
bool wrap
 If set, 'wrap' text at right edge of display.
 
bool _cp437
 If set, use correct CP437 charset (default is off)
 
GFXfontgfxFont
 Pointer to special font.
 

Detailed Description

Adafruit_SPITFT is an intermediary class between Adafruit_GFX and various hardware-specific subclasses for different displays. It handles certain operations that are common to a range of displays (address window, area fills, etc.). Originally these were all color TFT displays interfaced via SPI, but it's since expanded to include color OLEDs and parallel-interfaced TFTs. THE NAME HAS BEEN KEPT TO AVOID BREAKING A LOT OF SUBCLASSES AND EXAMPLE CODE. Many of the class member functions similarly live on with names that don't necessarily accurately describe what they're doing, again to avoid breaking a lot of other code. If in doubt, read the comments.

Constructor & Destructor Documentation

◆ Adafruit_SPITFT() [1/4]

Adafruit_SPITFT::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.

Parameters
wDisplay width in pixels at default rotation setting (0).
hDisplay height in pixels at default rotation setting (0).
csArduino pin # for chip-select (-1 if unused, tie CS low).
dcArduino pin # for data/command select (required).
mosiArduino pin # for bitbang SPI MOSI signal (required).
sckArduino pin # for bitbang SPI SCK signal (required).
rstArduino pin # for display reset (optional, display reset can be tied to MCU reset, default of -1 means unused).
misoArduino pin # for bitbang SPI MISO signal (optional, -1 default, many displays don't support SPI read).
Note
Output pins are not initialized; application typically will need to call subclass' begin() function, which in turn calls this library's initSPI() function to initialize pins.

◆ Adafruit_SPITFT() [2/4]

Adafruit_SPITFT::Adafruit_SPITFT ( uint16_t w,
uint16_t h,
int8_t cs,
int8_t dc,
int8_t rst = -1 )

Adafruit_SPITFT constructor for hardware SPI using the board's default SPI peripheral.

Parameters
wDisplay width in pixels at default rotation setting (0).
hDisplay height in pixels at default rotation setting (0).
csArduino pin # for chip-select (-1 if unused, tie CS low).
dcArduino pin # for data/command select (required).
rstArduino pin # for display reset (optional, display reset can be tied to MCU reset, default of -1 means unused).
Note
Output pins are not initialized; application typically will need to call subclass' begin() function, which in turn calls this library's initSPI() function to initialize pins.

◆ Adafruit_SPITFT() [3/4]

Adafruit_SPITFT::Adafruit_SPITFT ( uint16_t w,
uint16_t h,
SPIClass * spiClass,
int8_t cs,
int8_t dc,
int8_t rst = -1 )

Adafruit_SPITFT constructor for hardware SPI using a specific SPI peripheral.

Parameters
wDisplay width in pixels at default rotation (0).
hDisplay height in pixels at default rotation (0).
spiClassPointer to SPIClass type (e.g. &SPI or &SPI1).
csArduino pin # for chip-select (-1 if unused, tie CS low).
dcArduino pin # for data/command select (required).
rstArduino pin # for display reset (optional, display reset can be tied to MCU reset, default of -1 means unused).
Note
Output pins are not initialized in constructor; application typically will need to call subclass' begin() function, which in turn calls this library's initSPI() function to initialize pins. EXCEPT...if you have built your own SERCOM SPI peripheral (calling the SPIClass constructor) rather than one of the built-in SPI devices (e.g. &SPI, &SPI1 and so forth), you will need to call the begin() function for your object as well as pinPeripheral() for the MOSI, MISO and SCK pins to configure GPIO manually. Do this BEFORE calling the display-specific begin or init function. Unfortunate but unavoidable.

◆ Adafruit_SPITFT() [4/4]

Adafruit_SPITFT::Adafruit_SPITFT ( uint16_t w,
uint16_t h,
tftBusWidth busWidth,
int8_t d0,
int8_t wr,
int8_t dc,
int8_t cs = -1,
int8_t rst = -1,
int8_t rd = -1 )

Adafruit_SPITFT constructor for parallel display connection.

Parameters
wDisplay width in pixels at default rotation (0).
hDisplay height in pixels at default rotation (0).
busWidthIf tft16 (enumeration in header file), is a 16-bit parallel connection, else 8-bit. 16-bit isn't fully implemented or tested yet so applications should pass "tft8bitbus" for now...needed to stick a required enum argument in there to disambiguate this constructor from the soft-SPI case. Argument is ignored on 8-bit architectures (no 'wide' support there since PORTs are 8 bits anyway).
d0Arduino pin # for data bit 0 (1+ are extrapolated). The 8 (or 16) data bits MUST be contiguous and byte- aligned (or word-aligned for wide interface) within the same PORT register (might not correspond to Arduino pin sequence).
wrArduino pin # for write strobe (required).
dcArduino pin # for data/command select (required).
csArduino pin # for chip-select (optional, -1 if unused, tie CS low).
rstArduino pin # for display reset (optional, display reset can be tied to MCU reset, default of -1 means unused).
rdArduino pin # for read strobe (optional, -1 if unused).
Note
Output pins are not initialized; application typically will need to call subclass' begin() function, which in turn calls this library's initSPI() function to initialize pins. Yes, the name is a misnomer...this library originally handled only SPI displays, parallel being a recent addition (but not wanting to break existing code).

◆ ~Adafruit_SPITFT()

Adafruit_SPITFT::~Adafruit_SPITFT ( )
inline

Member Function Documentation

◆ begin()

virtual void Adafruit_SPITFT::begin ( uint32_t freq)
pure virtual

Display-specific initialization function.

Parameters
freqSPI frequency, in hz (or 0 for default or unused).

◆ color565()

uint16_t Adafruit_SPITFT::color565 ( uint8_t red,
uint8_t green,
uint8_t blue )

Given 8-bit red, green and blue values, return a 'packed' 16-bit color value in '565' RGB format (5 bits red, 6 bits green, 5 bits blue). This is just a mathematical operation, no hardware is touched.

Parameters
red8-bit red brightnesss (0 = off, 255 = max).
green8-bit green brightnesss (0 = off, 255 = max).
blue8-bit blue brightnesss (0 = off, 255 = max).
Returns
'Packed' 16-bit color value (565 format).

◆ dmaWait()

void Adafruit_SPITFT::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).

◆ drawFastHLine()

void Adafruit_SPITFT::drawFastHLine ( int16_t x,
int16_t y,
int16_t w,
uint16_t color )
virtual

Draw a horizontal line on the display. Self-contained and provides its own transaction as needed (see writeFastHLine() for a lower-level variant). Edge clipping and rejection is performed here.

Parameters
xHorizontal position of first point.
yVertical position of first point.
wLine width in pixels (positive = right of first point, negative = point of first corner).
color16-bit line color in '565' RGB format.
Note
This repeats the writeFastHLine() function almost in its entirety, with the addition of a transaction start/end. It's done this way (rather than starting the transaction and calling writeFastHLine() to handle clipping and so forth) so that the transaction isn't performed at all if the line is rejected.

Reimplemented from Adafruit_GFX.

◆ drawFastVLine()

void Adafruit_SPITFT::drawFastVLine ( int16_t x,
int16_t y,
int16_t h,
uint16_t color )
virtual

Draw a vertical line on the display. Self-contained and provides its own transaction as needed (see writeFastHLine() for a lower- level variant). Edge clipping and rejection is performed here.

Parameters
xHorizontal position of first point.
yVertical position of first point.
hLine height in pixels (positive = below first point, negative = above first point).
color16-bit line color in '565' RGB format.
Note
This repeats the writeFastVLine() function almost in its entirety, with the addition of a transaction start/end. It's done this way (rather than starting the transaction and calling writeFastVLine() to handle clipping and so forth) so that the transaction isn't performed at all if the line is rejected.

Reimplemented from Adafruit_GFX.

◆ drawPixel()

void Adafruit_SPITFT::drawPixel ( int16_t x,
int16_t y,
uint16_t color )
virtual

Draw a single pixel to the display at requested coordinates. Self-contained and provides its own transaction as needed (see writePixel(x,y,color) for a lower-level variant). Edge clipping is performed here.

Parameters
xHorizontal position (0 = left).
yVertical position (0 = top).
color16-bit pixel color in '565' RGB format.

Implements Adafruit_GFX.

◆ drawRGBBitmap() [1/4]

void Adafruit_GFX::drawRGBBitmap ( int16_t x,
int16_t y,
const uint16_t bitmap[],
const uint8_t mask[],
int16_t w,
int16_t h )

Draw a PROGMEM-resident 16-bit image (RGB 5/6/5) with a 1-bit mask (set bits = opaque, unset bits = clear) at the specified (x,y) position. BOTH buffers (color and mask) must be PROGMEM-resident. For 16-bit display devices; no color reduction performed.

Parameters
xTop left corner x coordinate
yTop left corner y coordinate
bitmapbyte array with 16-bit color bitmap
maskbyte array with monochrome mask bitmap
wWidth of bitmap in pixels
hHeight of bitmap in pixels

◆ drawRGBBitmap() [2/4]

void Adafruit_GFX::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 devices; no color reduction performed.

Parameters
xTop left corner x coordinate
yTop left corner y coordinate
bitmapbyte array with 16-bit color bitmap
wWidth of bitmap in pixels
hHeight of bitmap in pixels

◆ drawRGBBitmap() [3/4]

void Adafruit_GFX::drawRGBBitmap ( int16_t x,
int16_t y,
uint16_t * bitmap,
uint8_t * mask,
int16_t w,
int16_t h )

Draw a RAM-resident 16-bit image (RGB 5/6/5) with a 1-bit mask (set bits = opaque, unset bits = clear) at the specified (x,y) position. BOTH buffers (color and mask) must be RAM-resident. For 16-bit display devices; no color reduction performed.

Parameters
xTop left corner x coordinate
yTop left corner y coordinate
bitmapbyte array with 16-bit color bitmap
maskbyte array with monochrome mask bitmap
wWidth of bitmap in pixels
hHeight of bitmap in pixels

◆ drawRGBBitmap() [4/4]

void Adafruit_SPITFT::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 reduction performed. Adapted from https://github.com/PaulStoffregen/ILI9341_t3 by Marc MERLIN. See examples/pictureEmbed to use this. 5/6/2017: function name and arguments have changed for compatibility with current GFX library and to avoid naming problems in prior implementation. Formerly drawBitmap() with arguments in different order. Handles its own transaction and edge clipping/rejection.

Parameters
xTop left corner horizontal coordinate.
yTop left corner vertical coordinate.
pcolorsPointer to 16-bit array of pixel values.
wWidth of bitmap in pixels.
hHeight of bitmap in pixels.

◆ endWrite()

void Adafruit_SPITFT::endWrite ( void )
virtual

Call after issuing command(s) or data to display. Performs chip-deselect (if required) and ends an SPI transaction (if using hardware SPI and transactions are supported). Required for all display types; not an SPI-specific function.

Reimplemented from Adafruit_GFX.

◆ fillRect()

void Adafruit_SPITFT::fillRect ( int16_t x,
int16_t y,
int16_t w,
int16_t h,
uint16_t color )
virtual

Draw a filled rectangle to the display. Self-contained and provides its own transaction as needed (see writeFillRect() or writeFillRectPreclipped() for lower-level variants). Edge clipping and rejection is performed here.

Parameters
xHorizontal position of first corner.
yVertical position of first corner.
wRectangle width in pixels (positive = right of first corner, negative = left of first corner).
hRectangle height in pixels (positive = below first corner, negative = above first corner).
color16-bit fill color in '565' RGB format.
Note
This repeats the writeFillRect() function almost in its entirety, with the addition of a transaction start/end. It's done this way (rather than starting the transaction and calling writeFillRect() to handle clipping and so forth) so that the transaction isn't performed at all if the rectangle is rejected. It's really not that much code.

Reimplemented from Adafruit_GFX.

◆ initSPI()

void Adafruit_SPITFT::initSPI ( uint32_t freq = 0,
uint8_t spiMode = SPI_MODE0 )

Configure microcontroller pins for TFT interfacing. Typically called by a subclass' begin() function.

Parameters
freqSPI frequency when using hardware SPI. If default (0) is passed, will fall back on a device-specific value. Value is ignored when using software SPI or parallel connection.
spiModeSPI mode when using hardware SPI. MUST be one of the values SPI_MODE0, SPI_MODE1, SPI_MODE2 or SPI_MODE3 defined in SPI.h. Do NOT attempt to pass '0' for SPI_MODE0 and so forth...the values are NOT the same! Use ONLY the defines! (Pity it's not an enum.)
Note
Another anachronistically-named function; this is called even when the display connection is parallel (not SPI). Also, this could probably be made private...quite a few class functions were generously put in the public section.

◆ invertDisplay()

void Adafruit_SPITFT::invertDisplay ( bool i)
virtual

Invert the colors of the display (if supported by hardware). Self-contained, no transaction setup required.

Parameters
itrue = inverted display, false = normal display.

Reimplemented from Adafruit_GFX.

◆ pushColor()

void Adafruit_SPITFT::pushColor ( uint16_t color)

Essentially writePixel() with a transaction around it. I don't think this is in use by any of our code anymore (believe it was for some older BMP-reading examples), but is kept here in case any user code relies on it. Consider it DEPRECATED.

Parameters
color16-bit pixel color in '565' RGB format.

◆ read16()

uint16_t Adafruit_SPITFT::read16 ( void )

Read a single 16-bit value from the display. Chip-select and transaction must have been previously set – this ONLY reads the byte. This operates ONLY on 'wide' (16-bit) parallel displays!

Returns
Unsigned 16-bit value read (always zero if USE_FAST_PINIO is not supported by the MCU architecture).

◆ readcommand16()

uint16_t Adafruit_SPITFT::readcommand16 ( uint16_t addr)

Read 16 bits of data from display register. For 16-bit parallel displays only.

Parameters
addrCommand/register to access.
Returns
Unsigned 16-bit data.

◆ readcommand8()

uint8_t Adafruit_SPITFT::readcommand8 ( uint8_t commandByte,
uint8_t index = 0 )

Read 8 bits of data from display configuration memory (not RAM). This is highly undocumented/supported and should be avoided, function is only included because some of the examples use it.

Parameters
commandByteThe command register to read data from.
indexThe byte index into the command to read from.
Returns
Unsigned 8-bit data read from display register.

◆ sendCommand() [1/2]

void Adafruit_SPITFT::sendCommand ( uint8_t commandByte,
const uint8_t * dataBytes = NULL,
uint8_t numDataBytes = 0 )

Adafruit_SPITFT Send Command handles complete sending of commands and data.

Parameters
commandByteThe Command Byte
dataBytesA pointer to the Data bytes to send
numDataBytesThe number of bytes we should send

◆ sendCommand() [2/2]

void Adafruit_SPITFT::sendCommand ( uint8_t commandByte,
uint8_t * dataBytes,
uint8_t numDataBytes )

Adafruit_SPITFT Send Command handles complete sending of commands and data.

Parameters
commandByteThe Command Byte
dataBytesA pointer to the Data bytes to send
numDataBytesThe number of bytes we should send

◆ sendCommand16()

void Adafruit_SPITFT::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 displays. Currently somewhat rigged for the NT35510, which has the odd behavior of wanting commands 16-bit, but subsequent data as 8-bit values, despite the 16-bit bus (high byte is always 0). Also seems to require issuing and incrementing address with each transfer.

Parameters
commandWordThe command word (16 bits)
dataBytesA pointer to the data bytes to send
numDataBytesThe number of bytes we should send

◆ setAddrWindow()

virtual void Adafruit_SPITFT::setAddrWindow ( uint16_t x,
uint16_t y,
uint16_t w,
uint16_t h )
pure virtual

Set up the specific display hardware's "address window" for subsequent pixel-pushing operations.

Parameters
xLeftmost pixel of area to be drawn (MUST be within display bounds at current rotation setting).
yTopmost pixel of area to be drawn (MUST be within display bounds at current rotation setting).
wWidth of area to be drawn, in pixels (MUST be >0 and, added to x, within display bounds at current rotation).
hHeight of area to be drawn, in pixels (MUST be >0 and, added to x, within display bounds at current rotation).

◆ setSPISpeed()

void Adafruit_SPITFT::setSPISpeed ( uint32_t freq)

Allow changing the SPI clock speed after initialization.

Parameters
freqDesired frequency of SPI clock, may not be the end frequency you get based on what the chip can do!

◆ SPI_BEGIN_TRANSACTION()

void Adafruit_SPITFT::SPI_BEGIN_TRANSACTION ( void )
inlineprotected

Start an SPI transaction if using the hardware SPI interface to the display. If using an earlier version of the Arduino platform (before the addition of SPI transactions), this instead attempts to set up the SPI clock and mode. No action is taken if the connection is not hardware SPI-based. This does NOT include a chip-select operation – see startWrite() for a function that encapsulated both actions.

◆ SPI_CS_HIGH()

void Adafruit_SPITFT::SPI_CS_HIGH ( void )
inline

Set the chip-select line HIGH. Does NOT check whether CS pin is set (>=0), that should be handled in calling function. Despite function name, this is used even if the display connection is parallel.

◆ SPI_CS_LOW()

void Adafruit_SPITFT::SPI_CS_LOW ( void )
inline

Set the chip-select line LOW. Does NOT check whether CS pin is set (>=0), that should be handled in calling function. Despite function name, this is used even if the display connection is parallel.

◆ SPI_DC_HIGH()

void Adafruit_SPITFT::SPI_DC_HIGH ( void )
inline

Set the data/command line HIGH (data mode).

◆ SPI_DC_LOW()

void Adafruit_SPITFT::SPI_DC_LOW ( void )
inline

Set the data/command line LOW (command mode).

◆ SPI_END_TRANSACTION()

void Adafruit_SPITFT::SPI_END_TRANSACTION ( void )
inlineprotected

End an SPI transaction if using the hardware SPI interface to the display. No action is taken if the connection is not hardware SPI-based or if using an earlier version of the Arduino platform (before the addition of SPI transactions). This does NOT include a chip-deselect operation – see endWrite() for a function that encapsulated both actions.

◆ SPI_MISO_READ()

bool Adafruit_SPITFT::SPI_MISO_READ ( void )
inlineprotected

Read the state of the software (bitbang) SPI MISO line.

Returns
true if HIGH, false if LOW.

◆ SPI_MOSI_HIGH()

void Adafruit_SPITFT::SPI_MOSI_HIGH ( void )
inlineprotected

Set the software (bitbang) SPI MOSI line HIGH.

◆ SPI_MOSI_LOW()

void Adafruit_SPITFT::SPI_MOSI_LOW ( void )
inlineprotected

Set the software (bitbang) SPI MOSI line LOW.

◆ SPI_SCK_HIGH()

void Adafruit_SPITFT::SPI_SCK_HIGH ( void )
inlineprotected

Set the software (bitbang) SPI SCK line HIGH.

◆ SPI_SCK_LOW()

void Adafruit_SPITFT::SPI_SCK_LOW ( void )
inlineprotected

Set the software (bitbang) SPI SCK line LOW.

◆ SPI_WRITE16()

void Adafruit_SPITFT::SPI_WRITE16 ( uint16_t w)

Issue a single 16-bit value to the display. Chip-select, transaction and data/command selection must have been previously set – this ONLY issues the word. Despite the name, this function is used even if display connection is parallel; name was maintaned for backward compatibility. Naming is also not consistent with the 8-bit version, spiWrite(). Sorry about that. Again, staying compatible with outside code.

Parameters
w16-bit value to write.

◆ SPI_WRITE32()

void Adafruit_SPITFT::SPI_WRITE32 ( uint32_t l)

Issue a single 32-bit value to the display. Chip-select, transaction and data/command selection must have been previously set – this ONLY issues the longword. Despite the name, this function is used even if display connection is parallel; name was maintaned for backward compatibility. Naming is also not consistent with the 8-bit version, spiWrite(). Sorry about that. Again, staying compatible with outside code.

Parameters
l32-bit value to write.

◆ spiRead()

uint8_t Adafruit_SPITFT::spiRead ( void )

Read a single 8-bit value from the display. Chip-select and transaction must have been previously set – this ONLY reads the byte. This is another of those functions in the library with a now-not-accurate name that's being maintained for compatibility with outside code. This function is used even if display connection is parallel.

Returns
Unsigned 8-bit value read (always zero if USE_FAST_PINIO is not supported by the MCU architecture).

◆ spiWrite()

void Adafruit_SPITFT::spiWrite ( uint8_t b)

Issue a single 8-bit value to the display. Chip-select, transaction and data/command selection must have been previously set – this ONLY issues the byte. This is another of those functions in the library with a now-not-accurate name that's being maintained for compatibility with outside code. This function is used even if display connection is parallel.

Parameters
b8-bit value to write.

◆ startWrite()

void Adafruit_SPITFT::startWrite ( void )
virtual

Call before issuing command(s) or data to display. Performs chip-select (if required) and starts an SPI transaction (if using hardware SPI and transactions are supported). Required for all display types; not an SPI-specific function.

Reimplemented from Adafruit_GFX.

◆ swapBytes()

void Adafruit_SPITFT::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() below in some situations, but may also be helpful for user code occasionally.

Parameters
srcSource address of 16-bit pixels buffer.
lenNumber of pixels to byte-swap.
destOptional destination address if different than src – otherwise, if NULL (default) or same address is passed, pixel buffer is overwritten in-place.

◆ TFT_RD_HIGH()

void Adafruit_SPITFT::TFT_RD_HIGH ( void )
inlineprotected

Set the RD line HIGH. Used for parallel-connected interfaces when reading data.

◆ TFT_RD_LOW()

void Adafruit_SPITFT::TFT_RD_LOW ( void )
inlineprotected

Set the RD line LOW. Used for parallel-connected interfaces when reading data.

◆ TFT_WR_STROBE()

void Adafruit_SPITFT::TFT_WR_STROBE ( void )
inlineprotected

Set the WR line LOW, then HIGH. Used for parallel-connected interfaces when writing data.

◆ write16()

void Adafruit_SPITFT::write16 ( uint16_t w)

Issue a single 16-bit value to the display. Chip-select, transaction and data/command selection must have been previously set – this ONLY issues the word. Thus operates ONLY on 'wide' (16-bit) parallel displays!

Parameters
w16-bit value to write.

◆ writeColor()

void Adafruit_SPITFT::writeColor ( uint16_t color,
uint32_t len )

Issue a series of pixels, all the same color. Not self- contained; should follow startWrite() and setAddrWindow() calls.

Parameters
color16-bit pixel color in '565' RGB format.
lenNumber of pixels to draw.

◆ writeCommand()

void Adafruit_SPITFT::writeCommand ( uint8_t cmd)

Write a single command byte to the display. Chip-select and transaction must have been previously set – this ONLY sets the device to COMMAND mode, issues the byte and then restores DATA mode. There is no corresponding explicit writeData() function – just use spiWrite().

Parameters
cmd8-bit command to write.

◆ writeCommand16()

void Adafruit_SPITFT::writeCommand16 ( uint16_t cmd)

Write a single command word to the display. Chip-select and transaction must have been previously set – this ONLY sets the device to COMMAND mode, issues the byte and then restores DATA mode. This operates ONLY on 'wide' (16-bit) parallel displays!

Parameters
cmd16-bit command to write.

◆ writeFastHLine()

void Adafruit_SPITFT::writeFastHLine ( int16_t x,
int16_t y,
int16_t w,
uint16_t color )
inlinevirtual

Draw a horizontal line on the display. Performs edge clipping and rejection. Not self-contained; should follow startWrite(). Typically used by higher-level graphics primitives; user code shouldn't need to call this and is likely to use the self- contained drawFastHLine() instead.

Parameters
xHorizontal position of first point.
yVertical position of first point.
wLine width in pixels (positive = right of first point, negative = point of first corner).
color16-bit line color in '565' RGB format.

Reimplemented from Adafruit_GFX.

◆ writeFastVLine()

void Adafruit_SPITFT::writeFastVLine ( int16_t x,
int16_t y,
int16_t h,
uint16_t color )
inlinevirtual

Draw a vertical line on the display. Performs edge clipping and rejection. Not self-contained; should follow startWrite(). Typically used by higher-level graphics primitives; user code shouldn't need to call this and is likely to use the self- contained drawFastVLine() instead.

Parameters
xHorizontal position of first point.
yVertical position of first point.
hLine height in pixels (positive = below first point, negative = above first point).
color16-bit line color in '565' RGB format.

Reimplemented from Adafruit_GFX.

◆ writeFillRect()

void Adafruit_SPITFT::writeFillRect ( int16_t x,
int16_t y,
int16_t w,
int16_t h,
uint16_t color )
virtual

Draw a filled rectangle to the display. Not self-contained; should follow startWrite(). Typically used by higher-level graphics primitives; user code shouldn'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 'raw' implementation.

Parameters
xHorizontal position of first corner.
yVertical position of first corner.
wRectangle width in pixels (positive = right of first corner, negative = left of first corner).
hRectangle height in pixels (positive = below first corner, negative = above first corner).
color16-bit fill color in '565' RGB format.
Note
Written in this deep-nested way because C by definition will optimize for the 'if' case, not the 'else' – avoids branches and rejects clipped rectangles at the least-work possibility.

Reimplemented from Adafruit_GFX.

◆ writeFillRectPreclipped()

void Adafruit_SPITFT::writeFillRectPreclipped ( int16_t x,
int16_t y,
int16_t w,
int16_t h,
uint16_t color )
inline

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.

Parameters
xHorizontal position of first corner. MUST BE WITHIN SCREEN BOUNDS.
yVertical position of first corner. MUST BE WITHIN SCREEN BOUNDS.
wRectangle width in pixels. MUST BE POSITIVE AND NOT EXTEND OFF SCREEN.
hRectangle height in pixels. MUST BE POSITIVE AND NOT EXTEND OFF SCREEN.
color16-bit fill color in '565' RGB format.
Note
This is a new function, no graphics primitives besides rects and horizontal/vertical lines are written to best use this yet.

◆ writePixel()

void Adafruit_SPITFT::writePixel ( int16_t x,
int16_t y,
uint16_t color )
virtual

Draw a single pixel to the display at requested coordinates. Not self-contained; should follow a startWrite() call.

Parameters
xHorizontal position (0 = left).
yVertical position (0 = top).
color16-bit pixel color in '565' RGB format.

Reimplemented from Adafruit_GFX.

◆ writePixels()

void Adafruit_SPITFT::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() and setAddrWindow() calls.

Parameters
colorsPointer to array of 16-bit pixel values in '565' RGB format.
lenNumber of elements in 'colors' array.
blockIf true (default case if unspecified), function blocks until DMA transfer is complete. This is simply IGNORED if DMA is not enabled. If false, the function returns immediately after the last DMA transfer is started, and one should use the dmaWait() function before doing ANY other display-related activities (or even any SPI-related activities, if using an SPI display that shares the bus with other devices).
bigEndianIf true, bitmap in memory is in big-endian order (most significant byte first). By default this is false, as most microcontrollers seem to be little-endian and 16-bit pixel values must be byte-swapped before issuing to the display (which tend toward big-endian when using SPI or 8-bit parallel). If an application can optimize around this – for example, a bitmap in a uint16_t array having the byte values already ordered big-endian, this can save time here, ESPECIALLY if using this function's non-blocking DMA mode.

Member Data Documentation

◆ [union]

union { ... } Adafruit_SPITFT

Only one interface is active.

◆ _cs

int8_t Adafruit_SPITFT::_cs
protected

Chip select pin # (or -1)

◆ _d0

int8_t Adafruit_SPITFT::_d0

Data pin 0 #.

◆ _dc

int8_t Adafruit_SPITFT::_dc
protected

Data/command pin #.

◆ _freq

uint32_t Adafruit_SPITFT::_freq = 0

SPI bitrate (if no SPI transactions)

Dummy var to keep subclasses happy.

◆ _miso

int8_t Adafruit_SPITFT::_miso

MISO pin #.

◆ _mode

uint32_t Adafruit_SPITFT::_mode

SPI data mode (transactions or no)

◆ _mosi

int8_t Adafruit_SPITFT::_mosi

MOSI pin #.

◆ _rd

int8_t Adafruit_SPITFT::_rd

Read strobe pin # (or -1)

◆ _rst

int8_t Adafruit_SPITFT::_rst
protected

Reset pin # (or -1)

◆ _sck

int8_t Adafruit_SPITFT::_sck

SCK pin #.

◆ _spi

SPIClass* Adafruit_SPITFT::_spi

SPI class pointer.

◆ _wr

int8_t Adafruit_SPITFT::_wr

Write strobe pin #.

◆ _xstart

int16_t Adafruit_SPITFT::_xstart = 0
protected

Internal framebuffer X offset.

◆ _ystart

int16_t Adafruit_SPITFT::_ystart = 0
protected

Internal framebuffer Y offset.

◆ connection

uint8_t Adafruit_SPITFT::connection
protected

TFT_HARD_SPI, TFT_SOFT_SPI, etc.

◆ csPinMask

ADAGFX_PORT_t Adafruit_SPITFT::csPinMask
protected

Bitmask for chip select.

◆ csPinMaskClr

ADAGFX_PORT_t Adafruit_SPITFT::csPinMaskClr
protected

Bitmask for chip select CLEAR (AND)

◆ csPinMaskSet

ADAGFX_PORT_t Adafruit_SPITFT::csPinMaskSet
protected

Bitmask for chip select SET (OR)

◆ csPort

PORTreg_t Adafruit_SPITFT::csPort
protected

PORT register for chip select.

◆ csPortClr

PORTreg_t Adafruit_SPITFT::csPortClr
protected

PORT register for chip select CLEAR.

◆ csPortSet

PORTreg_t Adafruit_SPITFT::csPortSet
protected

PORT register for chip select SET.

◆ dcPinMask

ADAGFX_PORT_t Adafruit_SPITFT::dcPinMask
protected

Bitmask for data/command.

◆ dcPinMaskClr

ADAGFX_PORT_t Adafruit_SPITFT::dcPinMaskClr
protected

Bitmask for data/command CLEAR (AND)

◆ dcPinMaskSet

ADAGFX_PORT_t Adafruit_SPITFT::dcPinMaskSet
protected

Bitmask for data/command SET (OR)

◆ dcPort

PORTreg_t Adafruit_SPITFT::dcPort
protected

PORT register for data/command.

◆ dcPortClr

PORTreg_t Adafruit_SPITFT::dcPortClr
protected

PORT register for data/command CLEAR.

◆ dcPortSet

PORTreg_t Adafruit_SPITFT::dcPortSet
protected

PORT register for data/command SET.

◆ descriptor

DmacDescriptor* Adafruit_SPITFT::descriptor = NULL
protected

Allocated descriptor list.

◆ dirClr [1/2]

volatile uint32_t* Adafruit_SPITFT::dirClr

PORT byte data direction CLEAR.

◆ dirClr [2/2]

volatile uint8_t* Adafruit_SPITFT::dirClr

PORT byte data direction CLEAR.

◆ dirSet [1/2]

volatile uint32_t* Adafruit_SPITFT::dirSet

PORT byte data direction SET.

◆ dirSet [2/2]

volatile uint8_t* Adafruit_SPITFT::dirSet

PORT byte data direction SET.

◆ dma

Adafruit_ZeroDMA Adafruit_SPITFT::dma
protected

DMA instance.

◆ dptr

DmacDescriptor* Adafruit_SPITFT::dptr = NULL
protected

1st descriptor

◆ [struct]

struct { ... } Adafruit_SPITFT::hwspi

Hardware SPI values.

◆ invertOffCommand

uint8_t Adafruit_SPITFT::invertOffCommand = 0
protected

Command to disable invert mode.

◆ invertOnCommand

uint8_t Adafruit_SPITFT::invertOnCommand = 0
protected

Command to enable invert mode.

◆ lastFillColor

uint16_t Adafruit_SPITFT::lastFillColor = 0
protected

Last color used w/fill.

◆ lastFillLen

uint32_t Adafruit_SPITFT::lastFillLen = 0
protected

of pixels w/last fill

◆ maxFillLen

uint16_t Adafruit_SPITFT::maxFillLen
protected

Max pixels per DMA xfer.

◆ misoPinMask

ADAGFX_PORT_t Adafruit_SPITFT::misoPinMask

Bitmask for MISO.

◆ misoPort

PORTreg_t Adafruit_SPITFT::misoPort

PORT (PIN) register for MISO.

◆ mosiPinMask

ADAGFX_PORT_t Adafruit_SPITFT::mosiPinMask

Bitmask for MOSI.

◆ mosiPinMaskClr

ADAGFX_PORT_t Adafruit_SPITFT::mosiPinMaskClr

Bitmask for MOSI CLEAR (AND)

◆ mosiPinMaskSet

ADAGFX_PORT_t Adafruit_SPITFT::mosiPinMaskSet

Bitmask for MOSI SET (OR)

◆ mosiPort

PORTreg_t Adafruit_SPITFT::mosiPort

PORT register for MOSI.

◆ mosiPortClr

PORTreg_t Adafruit_SPITFT::mosiPortClr

PORT register for MOSI CLEAR.

◆ mosiPortSet

PORTreg_t Adafruit_SPITFT::mosiPortSet

PORT register for MOSI SET.

◆ onePixelBuf

uint8_t Adafruit_SPITFT::onePixelBuf
protected

For hi==lo fill.

◆ pixelBuf

uint16_t* Adafruit_SPITFT::pixelBuf[2]
protected

Working buffers.

◆ portDir

volatile uint8_t* Adafruit_SPITFT::portDir

PORT direction register.

◆ rdPinMask

ADAGFX_PORT_t Adafruit_SPITFT::rdPinMask

Bitmask for read strobe.

◆ rdPinMaskClr

ADAGFX_PORT_t Adafruit_SPITFT::rdPinMaskClr

Bitmask for read strobe CLEAR (AND)

◆ rdPinMaskSet

ADAGFX_PORT_t Adafruit_SPITFT::rdPinMaskSet

Bitmask for read strobe SET (OR)

◆ rdPort

PORTreg_t Adafruit_SPITFT::rdPort

PORT register for read strobe.

◆ rdPortClr

PORTreg_t Adafruit_SPITFT::rdPortClr

PORT register for read strobe CLEAR.

◆ rdPortSet

PORTreg_t Adafruit_SPITFT::rdPortSet

PORT register for read strobe SET.

◆ readPort [1/2]

volatile uint32_t* Adafruit_SPITFT::readPort

PORT (PIN) register for DATA READ.

◆ readPort [2/2]

volatile uint8_t* Adafruit_SPITFT::readPort

PORT (PIN) register for DATA READ.

◆ sckPinMask

ADAGFX_PORT_t Adafruit_SPITFT::sckPinMask

Bitmask for SCK.

◆ sckPinMaskClr

ADAGFX_PORT_t Adafruit_SPITFT::sckPinMaskClr

Bitmask for SCK CLEAR (AND)

◆ sckPinMaskSet

ADAGFX_PORT_t Adafruit_SPITFT::sckPinMaskSet

Bitmask for SCK SET (OR bitmask)

◆ sckPort

PORTreg_t Adafruit_SPITFT::sckPort

PORT register for SCK.

◆ sckPortClr

PORTreg_t Adafruit_SPITFT::sckPortClr

PORT register for SCK CLEAR.

◆ sckPortSet

PORTreg_t Adafruit_SPITFT::sckPortSet

PORT register for SCK SET.

◆ settings

SPISettings Adafruit_SPITFT::settings

SPI transaction settings.

◆ [struct]

struct { ... } Adafruit_SPITFT::swspi

Software SPI values.

◆ [struct]

struct { ... } Adafruit_SPITFT::tft8

Parallel interface settings.

◆ wide

bool Adafruit_SPITFT::wide = 0

If true, is 16-bit interface.

◆ writePort [1/2]

volatile uint32_t* Adafruit_SPITFT::writePort

PORT register for DATA WRITE.

◆ writePort [2/2]

volatile uint8_t* Adafruit_SPITFT::writePort

PORT register for DATA WRITE.

◆ wrPinMask

ADAGFX_PORT_t Adafruit_SPITFT::wrPinMask

Bitmask for write strobe.

◆ wrPinMaskClr

ADAGFX_PORT_t Adafruit_SPITFT::wrPinMaskClr

Bitmask for write strobe CLEAR (AND)

◆ wrPinMaskSet

ADAGFX_PORT_t Adafruit_SPITFT::wrPinMaskSet

Bitmask for write strobe SET (OR)

◆ wrPort

PORTreg_t Adafruit_SPITFT::wrPort

PORT register for write strobe.

◆ wrPortClr

PORTreg_t Adafruit_SPITFT::wrPortClr

PORT register for write strobe CLEAR.

◆ wrPortSet

PORTreg_t Adafruit_SPITFT::wrPortSet

PORT register for write strobe SET.


The documentation for this class was generated from the following files: