Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more color functions #3515

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions TFT_eSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2929,6 +2929,36 @@ void TFT_eSPI::setTextColor(uint16_t c, uint16_t b, bool bgfill)
_fillbg = bgfill;
}

/***************************************************************************************
** Function name: getTextColor
** Description: get the font foreground colour
***************************************************************************************/
uint16_t TFT_eSPI::getTextColor()
{
return textcolor;
}

/***************************************************************************************
** Function name: getTextBgColor
** Description: get the font background colour
***************************************************************************************/
uint16_t TFT_eSPI::getTextBgColor()
{
return textbgcolor;
}

/***************************************************************************************
** Function name: invertColors
** Description: Changes foreground and background colors
***************************************************************************************/
void TFT_eSPI::invertColors()
{
uint16_t cor = textcolor;

textcolor = textbgcolor;
textbgcolor = cor;

}

/***************************************************************************************
** Function name: setPivot
Expand Down
4 changes: 4 additions & 0 deletions TFT_eSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
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 invertColors(); //invert textcolor and textbgcolor
uint16_t getTextColor(); //get the textcolor
uint16_t getTextBgColor(); //get the textbgcolor

void setTextWrap(bool wrapX, bool wrapY = false); // Turn on/off wrapping of text in TFT width and/or height

Expand Down