Adafruit GFX Library
|
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>
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. More... | |
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. More... | |
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. More... | |
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. More... | |
virtual void | begin (uint32_t freq)=0 |
Display-specific initialization function. More... | |
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. More... | |
void | initSPI (uint32_t freq=0, uint8_t spiMode=SPI_MODE0) |
Configure microcontroller pins for TFT interfacing. Typically called by a subclass' begin() function. More... | |
void | setSPISpeed (uint32_t freq) |
Allow changing the SPI clock speed after initialization. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
uint16_t | readcommand16 (uint16_t addr) |
Read 16 bits of data from display register. For 16-bit parallel displays only. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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). | |
bool | dmaBusy (void) const |
Check if DMA transfer is active. Always returts false if DMA is not enabled. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | invertDisplay (bool i) |
Invert the colors of the display (if supported by hardware). Self-contained, no transaction setup required. More... | |
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. More... | |
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. More... | |
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(). More... | |
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. More... | |
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! More... | |
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! More... | |
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! More... | |
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. More... | |
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. More... | |
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). | |
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. More... | |
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. More... | |
virtual void | setRotation (uint8_t r) |
Set rotation setting for display. More... | |
virtual void | fillScreen (uint16_t color) |
Fill the screen completely with one color. Update in subclasses if desired! More... | |
virtual void | drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color) |
Draw a line. More... | |
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. More... | |
void | drawCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color) |
Draw a circle outline. More... | |
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. More... | |
void | fillCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color) |
Draw a circle with filled color. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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). More... | |
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. More... | |
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). More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | drawChar (int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size) |
Draw a single character. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | setTextSize (uint8_t s) |
Set text 'magnification' size. Each increase in s makes 1 pixel that much bigger. More... | |
void | setTextSize (uint8_t sx, uint8_t sy) |
Set text 'magnification' size. Each increase in s makes 1 pixel that much bigger. More... | |
void | setFont (const GFXfont *f=NULL) |
Set the font to display when print()ing, either custom or default. More... | |
void | setCursor (int16_t x, int16_t y) |
Set text cursor location. More... | |
void | setTextColor (uint16_t c) |
Set text font color with transparant background. More... | |
void | setTextColor (uint16_t c, uint16_t bg) |
Set text font color with custom background color. More... | |
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). More... | |
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. More... | |
virtual void | write (uint8_t) |
Print one byte/character of data, used to support print() More... | |
int16_t | width (void) const |
Get width of the display, accounting for current rotation. More... | |
int16_t | height (void) const |
Get height of the display, accounting for current rotation. More... | |
uint8_t | getRotation (void) const |
Get rotation setting for display. More... | |
int16_t | getCursorX (void) const |
Get text cursor X location. More... | |
int16_t | getCursorY (void) const |
Get text cursor Y location. More... | |
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. More... | |
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. More... | |
Protected Attributes | |
struct { | |
SPIClass * _spi | |
SPI class pointer. | |
uint32_t _freq | |
SPI bitrate (if no SPI transactions) | |
uint32_t _mode | |
SPI data mode (transactions or no) | |
} | hwspi |
Hardware SPI values. | |
struct { | |
int8_t _mosi | |
MOSI pin #. | |
int8_t _miso | |
MISO pin #. | |
int8_t _sck | |
SCK pin #. | |
} | swspi |
Software SPI values. | |
struct { | |
int8_t _d0 | |
Data pin 0 #. | |
int8_t _wr | |
Write strobe pin #. | |
int8_t _rd | |
Read strobe pin # (or -1) | |
bool wide = 0 | |
If true, is 16-bit interface. | |
} | tft8 |
Parallel interface settings. | |
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) | |
GFXfont * | gfxFont |
Pointer to special font. | |
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.
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.
w | Display width in pixels at default rotation setting (0). |
h | Display height in pixels at default rotation setting (0). |
cs | Arduino pin # for chip-select (-1 if unused, tie CS low). |
dc | Arduino pin # for data/command select (required). |
mosi | Arduino pin # for bitbang SPI MOSI signal (required). |
sck | Arduino pin # for bitbang SPI SCK signal (required). |
rst | Arduino pin # for display reset (optional, display reset can be tied to MCU reset, default of -1 means unused). |
miso | Arduino pin # for bitbang SPI MISO signal (optional, -1 default, many displays don't support SPI read). |
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.
w | Display width in pixels at default rotation setting (0). |
h | Display height in pixels at default rotation setting (0). |
cs | Arduino pin # for chip-select (-1 if unused, tie CS low). |
dc | Arduino pin # for data/command select (required). |
rst | Arduino pin # for display reset (optional, display reset can be tied to MCU reset, default of -1 means unused). |
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.
w | Display width in pixels at default rotation (0). |
h | Display height in pixels at default rotation (0). |
spiClass | Pointer to SPIClass type (e.g. &SPI or &SPI1). |
cs | Arduino pin # for chip-select (-1 if unused, tie CS low). |
dc | Arduino pin # for data/command select (required). |
rst | Arduino pin # for display reset (optional, display reset can be tied to MCU reset, default of -1 means unused). |
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.
w | Display width in pixels at default rotation (0). |
h | Display height in pixels at default rotation (0). |
busWidth | If 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). |
d0 | Arduino 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). |
wr | Arduino pin # for write strobe (required). |
dc | Arduino pin # for data/command select (required). |
cs | Arduino pin # for chip-select (optional, -1 if unused, tie CS low). |
rst | Arduino pin # for display reset (optional, display reset can be tied to MCU reset, default of -1 means unused). |
rd | Arduino pin # for read strobe (optional, -1 if unused). |
|
pure virtual |
Display-specific initialization function.
freq | SPI frequency, in hz (or 0 for default or unused). |
|
pure virtual |
Set up the specific display hardware's "address window" for subsequent pixel-pushing operations.
x | Leftmost pixel of area to be drawn (MUST be within display bounds at current rotation setting). |
y | Topmost pixel of area to be drawn (MUST be within display bounds at current rotation setting). |
w | Width of area to be drawn, in pixels (MUST be >0 and, added to x, within display bounds at current rotation). |
h | Height of area to be drawn, in pixels (MUST be >0 and, added to x, within display bounds at current rotation). |
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.
freq | SPI 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. |
spiMode | SPI 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.) |
void Adafruit_SPITFT::setSPISpeed | ( | uint32_t | freq | ) |
Allow changing the SPI clock speed after initialization.
freq | Desired frequency of SPI clock, may not be the end frequency you get based on what the chip can do! |
void Adafruit_SPITFT::sendCommand | ( | uint8_t | commandByte, |
uint8_t * | dataBytes, | ||
uint8_t | numDataBytes | ||
) |
Adafruit_SPITFT Send Command handles complete sending of commands and data.
commandByte | The Command Byte |
dataBytes | A pointer to the Data bytes to send |
numDataBytes | The number of bytes we should send |
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.
commandByte | The Command Byte |
dataBytes | A pointer to the Data bytes to send |
numDataBytes | The number of bytes we should send |
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.
commandWord | The command word (16 bits) |
dataBytes | A pointer to the data bytes to send |
numDataBytes | The number of bytes we should send |
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.
commandByte | The command register to read data from. |
index | The byte index into the command to read from. |
uint16_t Adafruit_SPITFT::readcommand16 | ( | uint16_t | addr | ) |
Read 16 bits of data from display register. For 16-bit parallel displays only.
addr | Command/register to access. |
|
virtual |
Draw a single pixel to the display at requested coordinates. Not self-contained; should follow a startWrite() call.
x | Horizontal position (0 = left). |
y | Vertical position (0 = top). |
color | 16-bit pixel color in '565' RGB format. |
Reimplemented from Adafruit_GFX.
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.
colors | Pointer to array of 16-bit pixel values in '565' RGB format. |
len | Number of elements in 'colors' array. |
block | If 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). |
bigEndian | If 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. |
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.
color | 16-bit pixel color in '565' RGB format. |
len | Number of pixels to draw. |
|
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.
x | Horizontal position of first corner. |
y | Vertical position of first corner. |
w | Rectangle width in pixels (positive = right of first corner, negative = left of first corner). |
h | Rectangle height in pixels (positive = below first corner, negative = above first corner). |
color | 16-bit fill color in '565' RGB format. |
Reimplemented from Adafruit_GFX.
|
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.
x | Horizontal position of first point. |
y | Vertical position of first point. |
w | Line width in pixels (positive = right of first point, negative = point of first corner). |
color | 16-bit line color in '565' RGB format. |
Reimplemented from Adafruit_GFX.
|
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.
x | Horizontal position of first point. |
y | Vertical position of first point. |
h | Line height in pixels (positive = below first point, negative = above first point). |
color | 16-bit line color in '565' RGB format. |
Reimplemented from Adafruit_GFX.
|
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.
x | Horizontal position of first corner. MUST BE WITHIN SCREEN BOUNDS. |
y | Vertical position of first corner. MUST BE WITHIN SCREEN BOUNDS. |
w | Rectangle width in pixels. MUST BE POSITIVE AND NOT EXTEND OFF SCREEN. |
h | Rectangle height in pixels. MUST BE POSITIVE AND NOT EXTEND OFF SCREEN. |
color | 16-bit fill color in '565' RGB format. |
bool Adafruit_SPITFT::dmaBusy | ( | void | ) | const |
Check if DMA transfer is active. Always returts false if DMA is not enabled.
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.
src | Source address of 16-bit pixels buffer. |
len | Number of pixels to byte-swap. |
dest | Optional destination address if different than src – otherwise, if NULL (default) or same address is passed, pixel buffer is overwritten in-place. |
|
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.
x | Horizontal position (0 = left). |
y | Vertical position (0 = top). |
color | 16-bit pixel color in '565' RGB format. |
Implements Adafruit_GFX.
|
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.
x | Horizontal position of first corner. |
y | Vertical position of first corner. |
w | Rectangle width in pixels (positive = right of first corner, negative = left of first corner). |
h | Rectangle height in pixels (positive = below first corner, negative = above first corner). |
color | 16-bit fill color in '565' RGB format. |
Reimplemented from Adafruit_GFX.
|
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.
x | Horizontal position of first point. |
y | Vertical position of first point. |
w | Line width in pixels (positive = right of first point, negative = point of first corner). |
color | 16-bit line color in '565' RGB format. |
Reimplemented from Adafruit_GFX.
|
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.
x | Horizontal position of first point. |
y | Vertical position of first point. |
h | Line height in pixels (positive = below first point, negative = above first point). |
color | 16-bit line color in '565' RGB format. |
Reimplemented from Adafruit_GFX.
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.
color | 16-bit pixel color in '565' RGB format. |
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.
x | Top left corner horizontal coordinate. |
y | Top left corner vertical coordinate. |
pcolors | Pointer to 16-bit array of pixel values. |
w | Width of bitmap in pixels. |
h | Height of bitmap in pixels. |
|
virtual |
Invert the colors of the display (if supported by hardware). Self-contained, no transaction setup required.
i | true = inverted display, false = normal display. |
Reimplemented from Adafruit_GFX.
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.
red | 8-bit red brightnesss (0 = off, 255 = max). |
green | 8-bit green brightnesss (0 = off, 255 = max). |
blue | 8-bit blue brightnesss (0 = off, 255 = max). |
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.
b | 8-bit value to write. |
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().
cmd | 8-bit command to write. |
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.
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!
w | 16-bit value to write. |
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!
cmd | 16-bit command to write. |
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!
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.
w | 16-bit value to write. |
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.
l | 32-bit value to write. |
|
inlineprotected |
Read the state of the software (bitbang) SPI MISO line.
uint32_t Adafruit_SPITFT::_freq = 0 |
SPI bitrate (if no SPI transactions)
Dummy var to keep subclasses happy.