added the conversion from 24 bit hex colors saved as int or css hex color
This commit is contained in:
parent
53836b6f9d
commit
24167098ee
20
TFT_eSPI.cpp
20
TFT_eSPI.cpp
|
|
@ -2710,7 +2710,27 @@ uint16_t TFT_eSPI::color565(uint8_t r, uint8_t g, uint8_t b)
|
|||
{
|
||||
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
|
||||
}
|
||||
uint16_t TFT_eSPI::color565FromWebHex(const char* color){
|
||||
if (color[0] == '#') {
|
||||
//remove first char
|
||||
String c = String(color);
|
||||
c = c.substring(1);
|
||||
char l[9];
|
||||
for (int i = 0; i<9; i++)
|
||||
l[i] = '\0';
|
||||
c.toCharArray(l, 9);
|
||||
color = l;
|
||||
}
|
||||
|
||||
int colorInt = strtol(color, NULL, 16);
|
||||
return color565From888(colorInt);
|
||||
}
|
||||
uint16_t TFT_eSPI::color565From888(uint16_t color){
|
||||
int r = (color >> 16) & 255;
|
||||
int g = (color >> 8) & 255;
|
||||
int b = (color) & 255;
|
||||
return color565(r, g, b);
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: invertDisplay
|
||||
|
|
|
|||
|
|
@ -387,7 +387,8 @@ class TFT_eSPI : public Print {
|
|||
|
||||
uint16_t fontsLoaded(void),
|
||||
color565(uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
uint16_t color565From888(uint16_t color);
|
||||
uint16_t color565FromWebHex(const char* color);
|
||||
int16_t drawChar(unsigned int uniCode, int x, int y, int font),
|
||||
drawChar(unsigned int uniCode, int x, int y),
|
||||
drawNumber(long long_num,int poX, int poY, int font),
|
||||
|
|
|
|||
Loading…
Reference in New Issue