forked from Bodmer/TFT_eSPI
Removed a lot of useless shit
This commit is contained in:
980
TFT_eSPI.cpp
980
TFT_eSPI.cpp
File diff suppressed because it is too large
Load Diff
157
TFT_eSPI.h
157
TFT_eSPI.h
@@ -269,31 +269,31 @@ constexpr uint16_t color565(uint8_t red, uint8_t green, uint8_t blue) noexcept
|
||||
** Section 6: Colour enumeration
|
||||
***************************************************************************************/
|
||||
// Default color definitions
|
||||
constexpr uint16_t TFT_BLACK = 0x0000; /* 0, 0, 0 */
|
||||
constexpr uint16_t TFT_NAVY = 0x000F; /* 0, 0, 128 */
|
||||
constexpr uint16_t TFT_DARKGREEN = 0x03E0; /* 0, 128, 0 */
|
||||
constexpr uint16_t TFT_DARKCYAN = 0x03EF; /* 0, 128, 128 */
|
||||
constexpr uint16_t TFT_MAROON = 0x7800; /* 128, 0, 0 */
|
||||
constexpr uint16_t TFT_PURPLE = 0x780F; /* 128, 0, 128 */
|
||||
constexpr uint16_t TFT_OLIVE = 0x7BE0; /* 128, 128, 0 */
|
||||
constexpr uint16_t TFT_LIGHTGREY = 0xD69A; /* 211, 211, 211 */
|
||||
constexpr uint16_t TFT_DARKGREY = 0x7BEF; /* 128, 128, 128 */
|
||||
constexpr uint16_t TFT_BLUE = 0x001F; /* 0, 0, 255 */
|
||||
constexpr uint16_t TFT_GREEN = 0x07E0; /* 0, 255, 0 */
|
||||
constexpr uint16_t TFT_CYAN = 0x07FF; /* 0, 255, 255 */
|
||||
constexpr uint16_t TFT_RED = 0xF800; /* 255, 0, 0 */
|
||||
constexpr uint16_t TFT_MAGENTA = 0xF81F; /* 255, 0, 255 */
|
||||
constexpr uint16_t TFT_YELLOW = 0xFFE0; /* 255, 255, 0 */
|
||||
constexpr uint16_t TFT_WHITE = 0xFFFF; /* 255, 255, 255 */
|
||||
constexpr uint16_t TFT_BLACK = color565( 0, 0, 0);
|
||||
constexpr uint16_t TFT_NAVY = color565( 0, 0, 128);
|
||||
constexpr uint16_t TFT_DARKGREEN = color565( 0, 128, 0);
|
||||
constexpr uint16_t TFT_DARKCYAN = color565( 0, 128, 128);
|
||||
constexpr uint16_t TFT_MAROON = color565(128, 0, 0);
|
||||
constexpr uint16_t TFT_PURPLE = color565(128, 0, 128);
|
||||
constexpr uint16_t TFT_OLIVE = color565(128, 128, 0);
|
||||
constexpr uint16_t TFT_LIGHTGREY = color565(211, 211, 211);
|
||||
constexpr uint16_t TFT_DARKGREY = color565(128, 128, 128);
|
||||
constexpr uint16_t TFT_BLUE = color565( 0, 0, 255);
|
||||
constexpr uint16_t TFT_GREEN = color565( 0, 255, 0);
|
||||
constexpr uint16_t TFT_CYAN = color565( 0, 255, 255);
|
||||
constexpr uint16_t TFT_RED = color565(255, 0, 0);
|
||||
constexpr uint16_t TFT_MAGENTA = color565(255, 0, 255);
|
||||
constexpr uint16_t TFT_YELLOW = color565(255, 255, 0);
|
||||
constexpr uint16_t TFT_WHITE = color565(255, 255, 255);
|
||||
constexpr uint16_t TFT_GREY = 0x5AEB;
|
||||
constexpr uint16_t TFT_ORANGE = 0xFDA0; /* 255, 180, 0 */
|
||||
constexpr uint16_t TFT_GREENYELLOW = 0xB7E0; /* 180, 255, 0 */
|
||||
constexpr uint16_t TFT_PINK = 0xFE19; /* 255, 192, 203 */ //Lighter pink, was 0xFC9F
|
||||
constexpr uint16_t TFT_BROWN = 0x9A60; /* 150, 75, 0 */
|
||||
constexpr uint16_t TFT_GOLD = 0xFEA0; /* 255, 215, 0 */
|
||||
constexpr uint16_t TFT_SILVER = 0xC618; /* 192, 192, 192 */
|
||||
constexpr uint16_t TFT_SKYBLUE = 0x867D; /* 135, 206, 235 */
|
||||
constexpr uint16_t TFT_VIOLET = 0x915C; /* 180, 46, 226 */
|
||||
constexpr uint16_t TFT_ORANGE = color565(255, 180, 0);
|
||||
constexpr uint16_t TFT_GREENYELLOW = color565(180, 255, 0);
|
||||
constexpr uint16_t TFT_PINK = color565(255, 192, 203); //Lighter pink, was 0xFC9F
|
||||
constexpr uint16_t TFT_BROWN = color565(150, 75, 0);
|
||||
constexpr uint16_t TFT_GOLD = color565(255, 215, 0);
|
||||
constexpr uint16_t TFT_SILVER = color565(192, 192, 192);
|
||||
constexpr uint16_t TFT_SKYBLUE = color565(135, 206, 235);
|
||||
constexpr uint16_t TFT_VIOLET = color565(180, 46, 226);
|
||||
constexpr uint16_t TFT_NICEBLUE = color565(59, 163, 255);
|
||||
|
||||
// Next is a special 16 bit colour value that encodes to 8 bits
|
||||
@@ -394,7 +394,7 @@ swap_coord(T& a, T& b) { T t = a; a = b; b = t; }
|
||||
typedef uint16_t (*getColorCallback)(uint16_t x, uint16_t y);
|
||||
|
||||
// Class functions and variables
|
||||
class TFT_eSPI { friend class TFT_eSprite; // Sprite class has access to protected members
|
||||
class TFT_eSPI {
|
||||
|
||||
//--------------------------------------- public ------------------------------------//
|
||||
public:
|
||||
@@ -405,18 +405,16 @@ class TFT_eSPI { friend class TFT_eSprite; // Sprite class has access to protect
|
||||
// Sketch defined tab colour option is for ST7735 displays only
|
||||
void init(uint8_t tc = TAB_COLOUR), begin(uint8_t tc = TAB_COLOUR);
|
||||
|
||||
// These are virtual so the TFT_eSprite class can override them with sprite specific functions
|
||||
virtual void drawPixel(int32_t x, int32_t y, uint16_t color),
|
||||
drawChar(int32_t x, int32_t y, uint16_t c, uint16_t color, uint16_t bg, uint8_t size),
|
||||
drawLine(int32_t xs, int32_t ys, int32_t xe, int32_t ye, uint16_t color),
|
||||
drawFastVLine(int32_t x, int32_t y, int32_t h, uint16_t color),
|
||||
drawFastHLine(int32_t x, int32_t y, int32_t w, uint16_t color),
|
||||
fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t color);
|
||||
void drawPixel(int32_t x, int32_t y, uint16_t color);
|
||||
void drawChar(int32_t x, int32_t y, uint16_t c, uint16_t color, uint16_t bg, uint8_t size);
|
||||
void drawLine(int32_t xs, int32_t ys, int32_t xe, int32_t ye, uint16_t color);
|
||||
void drawFastVLine(int32_t x, int32_t y, int32_t h, uint16_t color);
|
||||
void drawFastHLine(int32_t x, int32_t y, int32_t w, uint16_t color);
|
||||
void fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t color);
|
||||
|
||||
virtual int16_t drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font),
|
||||
drawChar(uint16_t uniCode, int32_t x, int32_t y),
|
||||
height(void),
|
||||
width(void);
|
||||
int16_t drawChar(uint16_t uniCode, int32_t x, int32_t y, uint16_t color, uint16_t bgcolor, uint8_t font);
|
||||
int16_t height() const;
|
||||
int16_t width() const;
|
||||
|
||||
// Read the colour of a pixel at x,y and return value in 565 format
|
||||
virtual uint16_t readPixel(int32_t x, int32_t y);
|
||||
@@ -431,7 +429,7 @@ class TFT_eSPI { friend class TFT_eSprite; // Sprite class has access to protect
|
||||
virtual void end_nin_write();
|
||||
|
||||
void setRotation(uint8_t r); // Set the display image orientation to 0, 1, 2 or 3
|
||||
uint8_t getRotation(void); // Read the current rotation
|
||||
uint8_t getRotation(void) const; // Read the current rotation
|
||||
|
||||
void invertDisplay(bool i); // Tell TFT to invert all displayed colours
|
||||
|
||||
@@ -476,10 +474,10 @@ class TFT_eSPI { friend class TFT_eSprite; // Sprite class has access to protect
|
||||
#endif
|
||||
|
||||
// Graphics drawing
|
||||
void fillScreen(uint32_t color),
|
||||
drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color),
|
||||
drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color),
|
||||
fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color);
|
||||
void fillScreen(uint32_t color);
|
||||
void drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
|
||||
void drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color);
|
||||
void fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color);
|
||||
|
||||
void fillRectVGradient(int16_t x, int16_t y, int16_t w, int16_t h, uint32_t color1, uint32_t color2);
|
||||
void fillRectHGradient(int16_t x, int16_t y, int16_t w, int16_t h, uint32_t color1, uint32_t color2);
|
||||
@@ -509,17 +507,17 @@ class TFT_eSPI { friend class TFT_eSprite; // Sprite class has access to protect
|
||||
void drawSunkenRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color0, uint32_t color1, uint32_t color2);
|
||||
|
||||
|
||||
void drawCircle(int32_t x, int32_t y, int32_t r, uint32_t color),
|
||||
drawCircleHelper(int32_t x, int32_t y, int32_t r, uint8_t cornername, uint32_t color),
|
||||
fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color),
|
||||
fillCircleHelper(int32_t x, int32_t y, int32_t r, uint8_t cornername, int32_t delta, uint32_t color),
|
||||
void drawCircle(int32_t x, int32_t y, int32_t r, uint32_t color);
|
||||
void drawCircleHelper(int32_t x, int32_t y, int32_t r, uint8_t cornername, uint32_t color);
|
||||
void fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color);
|
||||
void fillCircleHelper(int32_t x, int32_t y, int32_t r, uint8_t cornername, int32_t delta, uint32_t color);
|
||||
|
||||
drawEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color),
|
||||
fillEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color),
|
||||
void drawEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color);
|
||||
void fillEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color);
|
||||
|
||||
// Corner 1 Corner 2 Corner 3
|
||||
drawTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color),
|
||||
fillTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color);
|
||||
void drawTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color);
|
||||
void fillTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color);
|
||||
|
||||
// Image rendering
|
||||
// Swap the byte order for pushImage() and pushPixels() - corrects endianness
|
||||
@@ -530,8 +528,7 @@ class TFT_eSPI { friend class TFT_eSprite; // Sprite class has access to protect
|
||||
void drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor),
|
||||
drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor),
|
||||
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor),
|
||||
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor),
|
||||
setBitmapColor(uint16_t fgcolor, uint16_t bgcolor); // Define the 2 colours for 1bpp sprites
|
||||
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor);
|
||||
|
||||
// Set TFT pivot point (use when rendering rotated sprites)
|
||||
void setPivot(int16_t x, int16_t y);
|
||||
@@ -545,20 +542,9 @@ class TFT_eSPI { friend class TFT_eSprite; // Sprite class has access to protect
|
||||
void pushRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data);
|
||||
|
||||
// These are used to render images or sprites stored in RAM arrays (used by Sprite class for 16bpp Sprites)
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data);
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data, uint16_t transparent);
|
||||
|
||||
// These are used to render images stored in FLASH (PROGMEM)
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data, uint16_t transparent);
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data);
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data, uint16_t transparent);
|
||||
|
||||
// These are used by Sprite class pushSprite() member function for 1, 4 and 8 bits per pixel (bpp) colours
|
||||
// They are not intended to be used with user sketches (but could be)
|
||||
// Set bpp8 true for 8bpp sprites, false otherwise. The cmap pointer must be specified for 4bpp
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *data, bool bpp8 = true, uint16_t *cmap = nullptr);
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *data, uint8_t transparent, bool bpp8 = true, uint16_t *cmap = nullptr);
|
||||
// FLASH version
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint8_t *data, bool bpp8, uint16_t *cmap = nullptr);
|
||||
// This next function has been used successfully to dump the TFT screen to a PC for documentation purposes
|
||||
// It reads a screen area and returns the 3 RGB 8 bit colour values of each pixel in the buffer
|
||||
// Set w and h to 1 to read 1 pixel's colour. The data buffer must be at least w * h * 3 bytes
|
||||
@@ -566,52 +552,32 @@ class TFT_eSPI { friend class TFT_eSprite; // Sprite class has access to protect
|
||||
|
||||
// Handle char arrays
|
||||
// Use with setTextDatum() to position string on TFT, and setTextPadding() to blank old displayed strings
|
||||
int16_t drawString(std::string_view string, int32_t x, int32_t y, uint8_t font), // Draw string using specifed font number
|
||||
drawString(std::string_view string, int32_t x, int32_t y), // Draw string using current font
|
||||
|
||||
drawCentreString(std::string_view string, int32_t x, int32_t y, uint8_t font), // Deprecated, use setTextDatum() and drawString()
|
||||
drawRightString(std::string_view string, int32_t x, int32_t y, uint8_t font); // Deprecated, use setTextDatum() and drawString()
|
||||
int16_t drawString(std::string_view string, int32_t x, int32_t y, uint16_t color, uint16_t bgcolor, uint8_t font); // Draw string using specifed font number
|
||||
int16_t drawCentreString(std::string_view string, int32_t x, int32_t y, uint16_t color, uint16_t bgcolor, uint8_t font); // Deprecated, use setTextDatum() and drawString()
|
||||
int16_t drawRightString(std::string_view string, int32_t x, int32_t y, uint16_t color, uint16_t bgcolor, uint8_t font); // Deprecated, use setTextDatum() and drawString()
|
||||
|
||||
// Text rendering and font handling support funtions
|
||||
void setCursor(int16_t x, int16_t y), // Set cursor for tft.print()
|
||||
setCursor(int16_t x, int16_t y, uint8_t font); // Set cursor and font number for tft.print()
|
||||
|
||||
int16_t getCursorX(void), // Read current cursor x position (moves with tft.print())
|
||||
getCursorY(void); // Read current cursor y position
|
||||
|
||||
void setTextColor(uint16_t color), // Set character (glyph) color only (background not over-written)
|
||||
setTextColor(uint16_t fgcolor, uint16_t bgcolor, bool bgfill = false), // Set character (glyph) foreground and background colour, optional background fill for smooth fonts
|
||||
setTextSize(uint8_t size); // Set character size multiplier (this increases pixel size)
|
||||
void setTextSize(uint8_t size); // Set character size multiplier (this increases pixel size)
|
||||
|
||||
void setTextWrap(bool wrapX, bool wrapY = false); // Turn on/off wrapping of text in TFT width and/or height
|
||||
|
||||
void setTextDatum(uint8_t datum); // Set text datum position (default is top left), see Section 6 above
|
||||
uint8_t getTextDatum(void);
|
||||
|
||||
void setTextPadding(uint16_t x_width); // Set text padding (background blanking/over-write) width in pixels
|
||||
uint16_t getTextPadding(void); // Get text padding
|
||||
|
||||
#ifdef LOAD_GFXFF
|
||||
void setFreeFont(const GFXfont *f = NULL), // Select the GFX Free Font
|
||||
setTextFont(uint8_t font); // Set the font number to use in future
|
||||
void setFreeFont(const GFXfont *f = NULL); // Select the GFX Free Font
|
||||
#else
|
||||
void setFreeFont(uint8_t font), // Not used, historical fix to prevent an error
|
||||
setTextFont(uint8_t font); // Set the font number to use in future
|
||||
#endif
|
||||
|
||||
int16_t textWidth(std::string_view string, uint8_t font), // Returns pixel width of string in specified font
|
||||
textWidth(std::string_view string), // Returns pixel width of string in current font
|
||||
fontHeight(int16_t font), // Returns pixel height of string in specified font
|
||||
fontHeight(void); // Returns pixel width of string in current font
|
||||
int16_t textWidth(std::string_view string, uint8_t font); // Returns pixel width of string in specified font
|
||||
int16_t fontHeight(int16_t font); // Returns pixel height of string in specified font
|
||||
|
||||
// Used by library and Smooth font class to extract Unicode point codes from a UTF8 encoded string
|
||||
uint16_t decodeUTF8(const uint8_t *buf, uint16_t *index, uint16_t remaining),
|
||||
decodeUTF8(uint8_t c);
|
||||
|
||||
// Support function to UTF8 decode and draw characters piped through print stream
|
||||
size_t write(uint8_t);
|
||||
// size_t write(const uint8_t *buf, size_t len);
|
||||
|
||||
// Used by Smooth font class to fetch a pixel colour for the anti-aliasing
|
||||
void setCallback(getColorCallback getCol);
|
||||
|
||||
@@ -728,12 +694,7 @@ class TFT_eSPI { friend class TFT_eSprite; // Sprite class has access to protect
|
||||
// Global variables
|
||||
static SPIClass& getSPIinstance(void); // Get SPI class handle
|
||||
|
||||
uint16_t textcolor, textbgcolor; // Text foreground and background colours
|
||||
|
||||
uint32_t bitmap_fg, bitmap_bg; // Bitmap foreground (bit=1) and background (bit=0) colours
|
||||
|
||||
uint8_t textfont, // Current selected font number
|
||||
textsize, // Current font size multiplier
|
||||
uint8_t textsize, // Current font size multiplier
|
||||
textdatum, // Text reference datum
|
||||
rotation; // Display rotation (0-3)
|
||||
|
||||
@@ -825,10 +786,6 @@ class TFT_eSPI { friend class TFT_eSprite; // Sprite class has access to protect
|
||||
bool _vpDatum;
|
||||
bool _vpOoB;
|
||||
|
||||
int32_t cursor_x, cursor_y, padX; // Text cursor x,y and padding setting
|
||||
int32_t bg_cursor_x; // Background fill cursor
|
||||
int32_t last_cursor_x; // Previous text cursor position when fill used
|
||||
|
||||
uint32_t fontsloaded; // Bit field of fonts loaded
|
||||
|
||||
uint8_t glyph_ab, // Smooth font glyph delta Y (height) above baseline
|
||||
|
Reference in New Issue
Block a user