EX-Display
EX-Display
Loading...
Searching...
No Matches
TFT_eSPIDisplay Class Reference

Display class for TFT_eSPI based displays. More...

#include <TFT_eSPIDisplay.h>

Inheritance diagram for TFT_eSPIDisplay:
[legend]
Collaboration diagram for TFT_eSPIDisplay:
[legend]

Public Member Functions

 TFT_eSPIDisplay (uint8_t rotation, const GFXfont *textFont, uint16_t textColour, uint16_t backgroundColour)
 Constructor for a TFT_eSPIDisplay instance.
 
 TFT_eSPIDisplay (uint8_t rotation, const GFXfont *textFont, uint16_t textColour, uint16_t backgroundColour, int csPin)
 Alternate constructor for a TFT_eSPIDisplay instance to specify the CS pin to allow for two displays.
 
void begin () override
 Perform any initial once off setup or configuration here and call only once.
 
void clearScreen () override
 Clear the entire screen.
 
void displayScreen (Screen *screen) override
 Display the specified Screen on this display.
 
void clearRow (uint8_t row)
 Clear the specified row.
 
void displayStartupInfo (const char *version) override
 Display the startup screen with software version.
 
virtual void displayFormattedRow (uint8_t row, uint8_t column, RowAttributes attributes, const char *text, bool append) override
 Display a row using formatting modifiers.
 
TFT_eSPI * getTFT_eSPIInstance ()
 Get the TFT_eSPI instance created by this instance - needed for the touch interface.
 
bool tftInitialised ()
 Test if the TFT_eSPI instance has been initialised - needed for the touch interface.
 
 ~TFT_eSPIDisplay () override
 Destructor for the TFT_eSPIDisplay.
 
- Public Member Functions inherited from DisplayInterface
void setNext (DisplayInterface *display)
 Set the next DisplayInterface derived instance in the list.
 
DisplayInterfacegetNext ()
 Get the next DisplayInterface derived instance in the list.
 
void setLogger (Logger *logger)
 Set the logger instance to use for diagnostic logging.
 
void setId (uint8_t displayId)
 Set the ID for this display instance.
 
uint8_t getId ()
 Get the ID of this display instance.
 
void setScreenId (int screenId)
 Set the Screen ID this display is currently displaying.
 
int getScreenId ()
 Get the Screen ID this display is currently displaing.
 
int getCSPin ()
 Get the defined CS pin for this display to see if it needs manual SPI switching.
 
void setNeedsRedraw (bool redraw)
 Set the flag for whether this display needs redrawing or not - individual row updates are not affected.
 
bool needsRedraw ()
 Test if this display needs an entire redraw.
 
void formatRow (int row, const char *text)
 Static method to enable calling back to a derived class with a formatted row.
 
virtual ~DisplayInterface ()=default
 Destructor for a DisplayInterface.
 

Static Public Member Functions

static TFT_eSPIDisplaycreate (uint8_t rotation, const GFXfont *textFont, uint16_t textColour, uint16_t backgroundColour)
 Static method to enable the compiler to generate create commands from myDevices.h entries.
 
static TFT_eSPIDisplaycreate (uint8_t rotation, const GFXfont *textFont, uint16_t textColour, uint16_t backgroundColour, int csPin)
 Alternate static method to enable the compiler to generate create commands from myDevices.h entries.
 

Private Member Functions

void _getRowPosition (uint8_t row, uint8_t column, int32_t &x, int32_t &y)
 Get the X/Y coordinates to draw the specified row, starting at the specified column.
 

Private Attributes

const GFXfont * _gfxFont
 

Static Private Attributes

static TFT_eSPI * _tft = nullptr
 
static bool _tftInitialised = false
 

Additional Inherited Members

- Protected Member Functions inherited from DisplayInterface
RowAttributes _sanitiseAttributes (RowAttributes attributes)
 Sanitise the provided struct of RowAttributes.
 
bool _isModifier (char check)
 Validates the provided char is a valid modifier.
 
RowAttributes _setAttribute (RowAttributes attributes, char modifier, uint16_t colour=0xFFFF)
 Update the provided RowAttributes struct according to the provided modifier.
 
bool _isRGB (const char *colour)
 Check if the provided string constant translates to a valid RGB colour code.
 
uint16_t _convertRGBtoRGB565 (const char *colour)
 Convert the provided RGB colour code string constant to a uint16_t RGB565 colour.
 
- Protected Attributes inherited from DisplayInterface
DisplayInterface_next = nullptr
 Pointer to the next DisplayInterface derived instance in the list.
 
uint16_t _textColour
 Default text colour for the display.
 
uint16_t _backgroundColour
 Default background colour for the display.
 
Logger_logger = nullptr
 Pointer to the Logger instance for the DisplayInterface derived classes.
 
uint8_t _displayId = 0
 ID for this display instance.
 
int _screenId = -1
 ID of the screen this display is currently displaying, defaults to -1 to flag it is not a valid ID.
 
uint8_t _rotation = 0
 Orientation of this display, most displays require this setting otherwise ignore it.
 
uint8_t _textSize = 1
 Multiplier for text size, most displays require this setting otherwise ignore it.
 
uint8_t _maxRow = 0
 Maximum row number (not count) that will fit on this display (based on font height, not pixels)
 
uint8_t _maxColumn = 0
 Maximum column number (not count) that will fit on this display (based on font width, not pixels)
 
uint8_t _fontHeight = 0
 Calculated font height to determine row positioning.
 
uint8_t _fontWidth = 0
 Calculated font width to determine column positioning.
 
int _csPin = -1
 If there are more than one SPI displays that libraries don't officially support, the CS pin can be provided to switch between them (default -1 disables this)
 
bool _needsRedraw = true
 Flag that this display needs redrawing - needed for switching between screens.
 

Detailed Description

Display class for TFT_eSPI based displays.

Constructor & Destructor Documentation

◆ TFT_eSPIDisplay() [1/2]

TFT_eSPIDisplay::TFT_eSPIDisplay ( uint8_t  rotation,
const GFXfont *  textFont,
uint16_t  textColour,
uint16_t  backgroundColour 
)

Constructor for a TFT_eSPIDisplay instance.

Parameters
rotationRotation of the display, 0 - 3, refer to TFT_eSPI documentation for details
textFontThe identiy of the font for this display.
textColourDefault 16bit text colour, refer to TFT_eSPI documentation for details
backgroundColourDefault 16bit background colour, refer to TFT_eSPI documentation for details

◆ TFT_eSPIDisplay() [2/2]

TFT_eSPIDisplay::TFT_eSPIDisplay ( uint8_t  rotation,
const GFXfont *  textFont,
uint16_t  textColour,
uint16_t  backgroundColour,
int  csPin 
)

Alternate constructor for a TFT_eSPIDisplay instance to specify the CS pin to allow for two displays.

Parameters
rotationRotation of the display, 0 - 3, refer to TFT_eSPI documentation for details
textFontThe identiy of the font for this display.
textColourDefault 16bit text colour, refer to TFT_eSPI documentation for details
backgroundColourDefault 16bit background colour, refer to TFT_eSPI documentation for details
csPinPin this display's chip select (CS) pin is connected to to enable manual display switching

◆ ~TFT_eSPIDisplay()

TFT_eSPIDisplay::~TFT_eSPIDisplay ( )
override

Destructor for the TFT_eSPIDisplay.

Member Function Documentation

◆ _getRowPosition()

void TFT_eSPIDisplay::_getRowPosition ( uint8_t  row,
uint8_t  column,
int32_t &  x,
int32_t &  y 
)
private

Get the X/Y coordinates to draw the specified row, starting at the specified column.

Parameters
rowRow number
columnColumn to start drawing at
xVariable to update with the x position
yVariable to update with the y position
Here is the caller graph for this function:

◆ begin()

void TFT_eSPIDisplay::begin ( )
overridevirtual

Perform any initial once off setup or configuration here and call only once.

Implements DisplayInterface.

Here is the caller graph for this function:

◆ clearRow()

void TFT_eSPIDisplay::clearRow ( uint8_t  row)

Clear the specified row.

Parameters
rowRow number as specified in the SCREEN() command (not pixels)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearScreen()

void TFT_eSPIDisplay::clearScreen ( )
overridevirtual

Clear the entire screen.

Implements DisplayInterface.

Here is the caller graph for this function:

◆ create() [1/2]

TFT_eSPIDisplay * TFT_eSPIDisplay::create ( uint8_t  rotation,
const GFXfont *  textFont,
uint16_t  textColour,
uint16_t  backgroundColour 
)
static

Static method to enable the compiler to generate create commands from myDevices.h entries.

Parameters
rotationrotation Rotation of the display, 0 - 3, refer to TFT_eSPI documentation for details
textFontThe identiy of the font for this display.
textColourDefault 16bit text colour, refer to TFT_eSPI documentation for details
backgroundColourDefault 16bit background colour, refer to TFT_eSPI documentation for details
Returns
Pointer to a new TFT_eSPIDisplay instance

◆ create() [2/2]

TFT_eSPIDisplay * TFT_eSPIDisplay::create ( uint8_t  rotation,
const GFXfont *  textFont,
uint16_t  textColour,
uint16_t  backgroundColour,
int  csPin 
)
static

Alternate static method to enable the compiler to generate create commands from myDevices.h entries.

Parameters
rotationrotation Rotation of the display, 0 - 3, refer to TFT_eSPI documentation for details
textFontThe identiy of the font for this display.
textColourDefault 16bit text colour, refer to TFT_eSPI documentation for details
backgroundColourDefault 16bit background colour, refer to TFT_eSPI documentation for details
csPinPin this display's chip select (CS) pin is connected to to enable manual display switching
Returns
Pointer to a new TFT_eSPIDisplay instance

◆ displayFormattedRow()

void TFT_eSPIDisplay::displayFormattedRow ( uint8_t  row,
uint8_t  column,
RowAttributes  attributes,
const char *  text,
bool  append 
)
overridevirtual

Display a row using formatting modifiers.

Parameters
rowRow ID to display
columnColumn at which to display text (not pixels)
attributesRowAttributes structure containing modifier details
textText to display
appendFlag if this is appending to an existing row and should not clear the row first

Implements DisplayInterface.

Here is the call graph for this function:

◆ displayScreen()

void TFT_eSPIDisplay::displayScreen ( Screen screen)
overridevirtual

Display the specified Screen on this display.

Parameters
screenPointer to the Screen to display

Implements DisplayInterface.

Here is the call graph for this function:

◆ displayStartupInfo()

void TFT_eSPIDisplay::displayStartupInfo ( const char *  version)
overridevirtual

Display the startup screen with software version.

Parameters
versionEX-Display version

Implements DisplayInterface.

Here is the call graph for this function:

◆ getTFT_eSPIInstance()

TFT_eSPI * TFT_eSPIDisplay::getTFT_eSPIInstance ( )

Get the TFT_eSPI instance created by this instance - needed for the touch interface.

Returns
Pointer to the TFT_eSPI instance
Here is the caller graph for this function:

◆ tftInitialised()

bool TFT_eSPIDisplay::tftInitialised ( )

Test if the TFT_eSPI instance has been initialised - needed for the touch interface.

Returns
true|false
Here is the caller graph for this function:

Member Data Documentation

◆ _gfxFont

const GFXfont* TFT_eSPIDisplay::_gfxFont
private

◆ _tft

TFT_eSPI * TFT_eSPIDisplay::_tft = nullptr
staticprivate

◆ _tftInitialised

bool TFT_eSPIDisplay::_tftInitialised = false
staticprivate

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