EX-Display
EX-Display
Loading...
Searching...
No Matches
/home/runner/work/EX-Display/EX-Display/TFT_eSPIDisplay.h
Go to the documentation of this file.
1/*
2 * © 2024 Peter Cole
3 *
4 * This is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * It is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this code. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef TFT_ESPIDISPLAY_H
19#define TFT_ESPIDISPLAY_H
20
21// Do not load when testing, TFT_eSPI library is incompatible and will cause failures.
22#ifndef PIO_UNIT_TESTING
23
24#include "Defines.h"
25#include "DisplayInterface.h"
26#include <SPI.h>
27#include <TFT_eSPI.h>
28
29// Define the standard fonts available for this display type
30#define FONT_TFT_ESPI_SMALL &FreeMono9pt7b
31#define FONT_TFT_ESPI_MEDIUM &FreeMono12pt7b
32#define FONT_TFT_ESPI_LARGE &FreeMono18pt7b
33#define FONT_TFT_ESPI_XLARGE &FreeMono24pt7b
34#define FONT_TFT_ESPI_SMALL_SANS &FreeSans9pt7b
35#define FONT_TFT_ESPI_MEDIUM_SANS &FreeSans12pt7b
36#define FONT_TFT_ESPI_LARGE_SANS &FreeSans18pt7b
37#define FONT_TFT_ESPI_XLARGE_SANS &FreeSans24pt7b
38#define FONT_TFT_ESPI_MEDIUM_BOLD &FreeMonoBold12pt7b
39#define FONT_TFT_ESPI_SERIF_BOLD_ITALIC &FreeSerifBoldItalic12pt7b
40
41// If not overridden by myConfig.h, set the font
42#ifndef TEXT_FONT
43#define TEXT_FONT FONT_TFT_ESPI_MEDIUM_BOLD
44#endif
45
46// #define LOCAL_FONT FONT_TFT
49public:
55 TFT_eSPIDisplay(uint8_t rotation, const GFXfont *textFont, uint16_t textColour, uint16_t backgroundColour);
56
63 TFT_eSPIDisplay(uint8_t rotation, const GFXfont *textFont, uint16_t textColour, uint16_t backgroundColour, int csPin);
64
66 void begin() override;
67
69 void clearScreen() override;
70
73 void displayScreen(Screen *screen) override;
74
77 void clearRow(uint8_t row);
78
81 void displayStartupInfo(const char *version) override;
82
89 virtual void displayFormattedRow(uint8_t row, uint8_t column, RowAttributes attributes, const char *text,
90 bool append) override;
91
94 TFT_eSPI *getTFT_eSPIInstance();
95
98 bool tftInitialised();
99
106 static TFT_eSPIDisplay *create(uint8_t rotation, const GFXfont *textFont, uint16_t textColour,
107 uint16_t backgroundColour);
108
116 static TFT_eSPIDisplay *create(uint8_t rotation, const GFXfont *textFont, uint16_t textColour,
117 uint16_t backgroundColour, int csPin);
118
120 ~TFT_eSPIDisplay() override;
121
122private:
123 static TFT_eSPI *_tft;
124 const GFXfont *_gfxFont;
125 static bool _tftInitialised;
126
132 void _getRowPosition(uint8_t row, uint8_t column, int32_t &x, int32_t &y);
133};
134
135#endif // PIO_UNIT_TESTING
136
137#endif // TFT_ESPIDISPLAY_H
Class to abstract away all physical display implementation to enable multiple display types.
Definition DisplayInterface.h:36
Class for each screen as received from the EXRAIL SCREEN() command Each Screen instance contains a li...
Definition Screen.h:27
Display class for TFT_eSPI based displays.
Definition TFT_eSPIDisplay.h:48
void clearRow(uint8_t row)
Clear the specified row.
Definition TFT_eSPIDisplay.cpp:96
static TFT_eSPIDisplay * create(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.
Definition TFT_eSPIDisplay.cpp:174
static TFT_eSPI * _tft
Definition TFT_eSPIDisplay.h:123
const GFXfont * _gfxFont
Definition TFT_eSPIDisplay.h:124
void displayStartupInfo(const char *version) override
Display the startup screen with software version.
Definition TFT_eSPIDisplay.cpp:105
~TFT_eSPIDisplay() override
Destructor for the TFT_eSPIDisplay.
Definition TFT_eSPIDisplay.cpp:186
TFT_eSPI * getTFT_eSPIInstance()
Get the TFT_eSPI instance created by this instance - needed for the touch interface.
Definition TFT_eSPIDisplay.cpp:167
void begin() override
Perform any initial once off setup or configuration here and call only once.
Definition TFT_eSPIDisplay.cpp:51
void displayScreen(Screen *screen) override
Display the specified Screen on this display.
Definition TFT_eSPIDisplay.cpp:80
bool tftInitialised()
Test if the TFT_eSPI instance has been initialised - needed for the touch interface.
Definition TFT_eSPIDisplay.cpp:172
static bool _tftInitialised
Definition TFT_eSPIDisplay.h:125
virtual void displayFormattedRow(uint8_t row, uint8_t column, RowAttributes attributes, const char *text, bool append) override
Display a row using formatting modifiers.
Definition TFT_eSPIDisplay.cpp:128
void clearScreen() override
Clear the entire screen.
Definition TFT_eSPIDisplay.cpp:75
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.
Definition TFT_eSPIDisplay.cpp:191
Structure for row attributes.
Definition DisplayInterface.h:26