Skip to content

Commit

Permalink
chore : sync TFT_eSPI to 2.5.43
Browse files Browse the repository at this point in the history
  • Loading branch information
Julio MATARRANZ committed Aug 22, 2024
1 parent 2043b09 commit 651283e
Show file tree
Hide file tree
Showing 196 changed files with 3,219 additions and 866 deletions.
26 changes: 13 additions & 13 deletions lib/TFT_eSPI/Extensions/Smooth_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void TFT_eSPI::loadFont(String fontName, bool flash)
6. Descent in pixels from baseline to bottom of "p"
Next are gCount sets of values for each glyph, each set comprises 7 int32t parameters (28 bytes):
1. Glyph Unicode stored as a 32 bit value
1. Glyph Unicode stored as a 32-bit value
2. Height of bitmap bounding box
3. Width of bitmap bounding box
4. gxAdvance for cursor (setWidth in Processing)
Expand All @@ -57,7 +57,7 @@ void TFT_eSPI::loadFont(String fontName, bool flash)
7. padding value, typically 0
The bitmaps start next at 24 + (28 * gCount) bytes from the start of the file.
Each pixel is 1 byte, an 8 bit Alpha value which represents the transparency from
Each pixel is 1 byte, an 8-bit Alpha value which represents the transparency from
0xFF foreground colour, 0x00 background. The library uses a linear interpolation
between the foreground and background RGB component colours. e.g.
pixelRed = ((fgRed * alpha) + (bgRed * (255 - alpha))/255
Expand Down Expand Up @@ -158,7 +158,7 @@ void TFT_eSPI::loadMetrics(void)
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
if ( psramFound() )
{
gUnicode = (uint16_t*)ps_malloc( gFont.gCount * 2); // Unicode 16 bit Basic Multilingual Plane (0-FFFF)
gUnicode = (uint16_t*)ps_malloc( gFont.gCount * 2); // Unicode 16-bit Basic Multilingual Plane (0-FFFF)
gHeight = (uint8_t*)ps_malloc( gFont.gCount ); // Height of glyph
gWidth = (uint8_t*)ps_malloc( gFont.gCount ); // Width of glyph
gxAdvance = (uint8_t*)ps_malloc( gFont.gCount ); // xAdvance - to move x cursor
Expand All @@ -169,7 +169,7 @@ void TFT_eSPI::loadMetrics(void)
else
#endif
{
gUnicode = (uint16_t*)malloc( gFont.gCount * 2); // Unicode 16 bit Basic Multilingual Plane (0-FFFF)
gUnicode = (uint16_t*)malloc( gFont.gCount * 2); // Unicode 16-bit Basic Multilingual Plane (0-FFFF)
gHeight = (uint8_t*)malloc( gFont.gCount ); // Height of glyph
gWidth = (uint8_t*)malloc( gFont.gCount ); // Width of glyph
gxAdvance = (uint8_t*)malloc( gFont.gCount ); // xAdvance - to move x cursor
Expand Down Expand Up @@ -308,26 +308,26 @@ void TFT_eSPI::unloadFont( void )

/***************************************************************************************
** Function name: readInt32
** Description: Get a 32 bit integer from the font file
** Description: Get a 32-bit integer from the font file
*************************************************************************************x*/
uint32_t TFT_eSPI::readInt32(void)
{
uint32_t val = 0;

#ifdef FONT_FS_AVAILABLE
if (fs_font) {
val = fontFile.read() << 24;
val |= fontFile.read() << 16;
val |= fontFile.read() << 8;
val |= fontFile.read();
val = (uint32_t)fontFile.read() << 24;
val |= (uint32_t)fontFile.read() << 16;
val |= (uint32_t)fontFile.read() << 8;
val |= (uint32_t)fontFile.read();
}
else
#endif
{
val = pgm_read_byte(fontPtr++) << 24;
val |= pgm_read_byte(fontPtr++) << 16;
val |= pgm_read_byte(fontPtr++) << 8;
val |= pgm_read_byte(fontPtr++);
val = (uint32_t)pgm_read_byte(fontPtr++) << 24;
val |= (uint32_t)pgm_read_byte(fontPtr++) << 16;
val |= (uint32_t)pgm_read_byte(fontPtr++) << 8;
val |= (uint32_t)pgm_read_byte(fontPtr++);
}

return val;
Expand Down
29 changes: 16 additions & 13 deletions lib/TFT_eSPI/Extensions/Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TFT_eSprite::TFT_eSprite(TFT_eSPI *tft)
** Function name: createSprite
** Description: Create a sprite (bitmap) of defined width and height
***************************************************************************************/
// cast returned value to (uint8_t*) for 8 bit or (uint16_t*) for 16 bit colours
// cast returned value to (uint8_t*) for 8-bit or (uint16_t*) for 16-bit colours
void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames)
{

Expand Down Expand Up @@ -88,8 +88,6 @@ void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames)
_img8_2 = _img8 + (w * h + 1);
}

if ( (_bpp == 4) && (_colorMap == nullptr)) createPalette(default_4bit_palette);

// This is to make it clear what pointer size is expected to be used
// but casting in the user sketch is needed due to the use of void*
if ( (_bpp == 1) && (frames > 1) )
Expand All @@ -101,6 +99,8 @@ void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames)
if (_img8)
{
_created = true;
if ( (_bpp == 4) && (_colorMap == nullptr)) createPalette(default_4bit_palette);

rotation = 0;
setViewport(0, 0, _dwidth, _dheight);
setPivot(_iwidth/2, _iheight/2);
Expand Down Expand Up @@ -776,7 +776,7 @@ bool TFT_eSprite::pushToSprite(TFT_eSprite *dspr, int32_t x, int32_t y, uint16_t

if (transp == rp) {
if (pixel_count) {
dspr->pushImage(ox, y, pixel_count, 1, sline_buffer, _bpp);
dspr->pushImage(ox, y, pixel_count, 1, sline_buffer);
ox += pixel_count;
pixel_count = 0;
}
Expand Down Expand Up @@ -1104,7 +1104,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_
}
else if (_bpp == 4)
{
// The image is assumed to be 4 bit, where each byte corresponds to two pixels.
// The image is assumed to be 4-bit, where each byte corresponds to two pixels.
// much faster when aligned to a byte boundary, because the alternative is slower, requiring
// tedious bit operations.

Expand Down Expand Up @@ -1355,10 +1355,10 @@ void TFT_eSprite::writeColor(uint16_t color)
{
if (!_created ) return;

// Write 16 bit RGB 565 encoded colour to RAM
// Write 16-bit RGB 565 encoded colour to RAM
if (_bpp == 16) _img [_xptr + _yptr * _iwidth] = color;

// Write 8 bit RGB 332 encoded colour to RAM
// Write 8-bit RGB 332 encoded colour to RAM
else if (_bpp == 8) _img8[_xptr + _yptr * _iwidth] = (uint8_t) color;

else if (_bpp == 4)
Expand Down Expand Up @@ -1985,10 +1985,6 @@ void TFT_eSprite::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uin
{
if ( _vpOoB || !_created ) return;

if ((x >= _vpW - _xDatum) || // Clip right
(y >= _vpH - _yDatum)) // Clip bottom
return;

if (c < 32) return;
#ifdef LOAD_GLCD
//>>>>>>>>>>>>>>>>>>
Expand All @@ -1997,10 +1993,17 @@ void TFT_eSprite::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uin
#endif
//>>>>>>>>>>>>>>>>>>

if ((x >= _vpW - _xDatum) || // Clip right
(y >= _vpH - _yDatum)) // Clip bottom
return;

if (((x + 6 * size - 1) < (_vpX - _xDatum)) || // Clip left
((y + 8 * size - 1) < (_vpY - _yDatum))) // Clip top
return;

if (c > 255) return;
if (!_cp437 && c > 175) c++;

bool fillbg = (bg != color);

if ((size==1) && fillbg)
Expand Down Expand Up @@ -2135,7 +2138,7 @@ void TFT_eSprite::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uin

/***************************************************************************************
** Function name: drawChar
** Description: draw a unicode glyph into the sprite
** Description: draw a Unicode glyph into the sprite
***************************************************************************************/
// TODO: Rationalise with TFT_eSPI
// Any UTF-8 decoding must be done before calling drawChar()
Expand Down Expand Up @@ -2287,7 +2290,7 @@ int16_t TFT_eSprite::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t fo

uint8_t tnp = 0; // Temporary copy of np for while loop
uint8_t ts = textsize - 1; // Temporary copy of textsize
// 16 bit pixel count so maximum font size is equivalent to 180x180 pixels in area
// 16-bit pixel count so maximum font size is equivalent to 180x180 pixels in area
// w is total number of pixels to plot to fill character block
while (pc < w) {
line = pgm_read_byte((uint8_t *)flash_address);
Expand Down
24 changes: 12 additions & 12 deletions lib/TFT_eSPI/Extensions/Sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class TFT_eSprite : public TFT_eSPI {
~TFT_eSprite(void);

// Create a sprite of width x height pixels, return a pointer to the RAM area
// Sketch can cast returned value to (uint16_t*) for 16 bit depth if needed
// Sketch can cast returned value to (uint16_t*) for 16-bit depth if needed
// RAM required is:
// - 1 bit per pixel for 1 bit colour depth
// - 1 nibble per pixel for 4 bit colour (with palette table)
// - 1 byte per pixel for 8 bit colour (332 RGB format)
// - 2 bytes per pixel for 16 bit color depth (565 RGB format)
// - 1 nibble per pixel for 4-bit colour (with palette table)
// - 1 byte per pixel for 8-bit colour (332 RGB format)
// - 2 bytes per pixel for 16-bit color depth (565 RGB format)
void* createSprite(int16_t width, int16_t height, uint8_t frames = 1);

// Returns a pointer to the sprite or nullptr if not created, user must cast to pointer type
Expand All @@ -39,7 +39,7 @@ class TFT_eSprite : public TFT_eSPI {
void* setColorDepth(int8_t b);
int8_t getColorDepth(void);

// Set the palette for a 4 bit depth sprite. Only the first 16 colours in the map are used.
// Set the palette for a 4-bit depth sprite. Only the first 16 colours in the map are used.
void createPalette(uint16_t *palette = nullptr, uint8_t colors = 16); // Palette in RAM
void createPalette(const uint16_t *palette = nullptr, uint8_t colors = 16); // Palette in FLASH

Expand All @@ -61,14 +61,14 @@ class TFT_eSprite : public TFT_eSPI {
// Fill Sprite with a colour
fillSprite(uint32_t color),

// Define a window to push 16 bit colour pixels into in a raster order
// Define a window to push 16-bit colour pixels into in a raster order
// Colours are converted to the set Sprite colour bit depth
setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1),
// Push a color (aka singe pixel) to the sprite's set window area
pushColor(uint16_t color),
// Push len colors (pixels) to the sprite's set window area
pushColor(uint16_t color, uint32_t len),
// Push a pixel pre-formatted as a 1, 4, 8 or 16 bit colour (avoids conversion overhead)
// Push a pixel pre-formatted as a 1, 4, 8 or 16-bit colour (avoids conversion overhead)
writeColor(uint16_t color),

// Set the scroll zone, top left corner at x,y with defined width and height
Expand Down Expand Up @@ -139,7 +139,7 @@ class TFT_eSprite : public TFT_eSPI {
height(void);

// Functions associated with anti-aliased fonts
// Draw a single unicode character using the loaded font
// Draw a single Unicode character using the loaded font
void drawGlyph(uint16_t code);
// Print string to sprite using loaded font at cursor position
void printToSprite(String string);
Expand All @@ -162,13 +162,13 @@ class TFT_eSprite : public TFT_eSPI {
protected:

uint8_t _bpp; // bits per pixel (1, 4, 8 or 16)
uint16_t *_img; // pointer to 16 bit sprite
uint8_t *_img8; // pointer to 1 and 8 bit sprite frame 1 or frame 2
uint8_t *_img4; // pointer to 4 bit sprite (uses color map)
uint16_t *_img; // pointer to 16-bit sprite
uint8_t *_img8; // pointer to 1 and 8-bit sprite frame 1 or frame 2
uint8_t *_img4; // pointer to 4-bit sprite (uses color map)
uint8_t *_img8_1; // pointer to frame 1
uint8_t *_img8_2; // pointer to frame 2

uint16_t *_colorMap; // color map pointer: 16 entries, used with 4 bit color map.
uint16_t *_colorMap; // color map pointer: 16 entries, used with 4-bit color map.

int32_t _sinra; // Sine of rotation angle in fixed point
int32_t _cosra; // Cosine of rotation angle in fixed point
Expand Down
5 changes: 4 additions & 1 deletion lib/TFT_eSPI/Extensions/Touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
// Get the screen touch coordinates, returns true if screen has been touched
// if the touch coordinates are off screen then x and y are not updated
// The returned value can be treated as a bool type, false or 0 means touch not detected
// In future the function may return an 8 "quality" (jitter) value.
// In future the function may return an 8-bit "quality" (jitter) value.
// The threshold value is optional, this must be higher than the bias level for z (pressure)
// reported by Test_Touch_Controller when the screen is NOT touched. When touched the z value
// must be higher than the threshold for a touch to be detected.
uint8_t getTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600);

// Run screen calibration and test, report calibration values to the serial port
Expand Down
2 changes: 1 addition & 1 deletion lib/TFT_eSPI/Fonts/Font32rle.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Font 4
//
// This font has been 8 bit Run Length Encoded to save FLASH space
// This font has been 8-bit Run Length Encoded to save FLASH space
//
// This font contains 96 ASCII characters

Expand Down
2 changes: 1 addition & 1 deletion lib/TFT_eSPI/Fonts/Font64rle.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Font 6 is intended to display numbers and time
//
// This font has been 8 bit Run Length Encoded to save FLASH space
// This font has been 8-bit Run Length Encoded to save FLASH space
//
// This font only contains characters [space] 0 1 2 3 4 5 6 7 8 9 : - . a p m
// The Pipe character | is a narrow space to aid formatting
Expand Down
2 changes: 1 addition & 1 deletion lib/TFT_eSPI/Fonts/Font72rle.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Font 8
//
// This font has been 8 bit Run Length Encoded to save FLASH space
// This font has been 8-bit Run Length Encoded to save FLASH space
//
// It is a Arial 75 pixel height font intended to display large numbers
// This font only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : - .
Expand Down
2 changes: 1 addition & 1 deletion lib/TFT_eSPI/Fonts/Font72x53rle.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Font 8
//
// This font has been 8 bit Run Length Encoded to save FLASH space
// This font has been 8-bit Run Length Encoded to save FLASH space
//
// It is a Arial 75 pixel height font intended to display large numbers
// Width for numerals reduced from 55 to 53 (to fit in 160 pixel screens)
Expand Down
2 changes: 1 addition & 1 deletion lib/TFT_eSPI/Fonts/Font7srle.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Font 7
//
// This font has been 8 bit Run Length Encoded to save FLASH space
// This font has been 8-bit Run Length Encoded to save FLASH space
//
// This is a 7 segment font intended to display numbers and time
// This font only contains characters [space] 0 1 2 3 4 5 6 7 8 9 : . -
Expand Down
5 changes: 3 additions & 2 deletions lib/TFT_eSPI/Fonts/glcdfont.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ static const unsigned char font[] PROGMEM = {
0x00, 0x00, 0x7B, 0x00, 0x00,
0x08, 0x14, 0x2A, 0x14, 0x22,
0x22, 0x14, 0x2A, 0x14, 0x08,
0xAA, 0x00, 0x55, 0x00, 0xAA,
0xAA, 0x55, 0xAA, 0x55, 0xAA,
0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code
0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block
0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block
0x00, 0x00, 0x00, 0xFF, 0x00,
0x10, 0x10, 0x10, 0xFF, 0x00,
0x14, 0x14, 0x14, 0xFF, 0x00,
Expand Down
2 changes: 1 addition & 1 deletion lib/TFT_eSPI/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ menu "TFT_eSPI"
config TFT_SPI
bool "SPI"
config TFT_PARALLEL_8_BIT
bool "Parallel (8 bit)"
bool "Parallel (8-bit)"
endchoice

menu "Display Data pins"
Expand Down
10 changes: 5 additions & 5 deletions lib/TFT_eSPI/Processors/TFT_eSPI_ESP32.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void TFT_eSPI::end_SDA_Read(void)

/***************************************************************************************
** Function name: read byte - supports class functions
** Description: Read a byte from ESP32 8 bit data port
** Description: Read a byte from ESP32 8-bit data port
***************************************************************************************/
// Parallel bus MUST be set to input before calling this function!
uint8_t TFT_eSPI::readByte(void)
Expand Down Expand Up @@ -415,7 +415,7 @@ void TFT_eSPI::pushPixels(const void* data_in, uint32_t len){
}

////////////////////////////////////////////////////////////////////////////////////////
#elif defined (SPI_18BIT_DRIVER) // SPI 18 bit colour
#elif defined (SPI_18BIT_DRIVER) // SPI 18-bit colour
////////////////////////////////////////////////////////////////////////////////////////

/***************************************************************************************
Expand All @@ -428,7 +428,7 @@ void TFT_eSPI::pushBlock(uint16_t color, uint32_t len)
uint32_t r = (color & 0xF800)>>8;
uint32_t g = (color & 0x07E0)<<5;
uint32_t b = (color & 0x001F)<<19;
// Concatenate 4 pixels into three 32 bit blocks
// Concatenate 4 pixels into three 32-bit blocks
uint32_t r0 = r<<24 | b | g | r;
uint32_t r1 = r0>>8 | g<<16;
uint32_t r2 = r1>>8 | b<<8;
Expand Down Expand Up @@ -512,7 +512,7 @@ void TFT_eSPI::pushSwapBytePixels(const void* data_in, uint32_t len){
}

////////////////////////////////////////////////////////////////////////////////////////
#elif defined (TFT_PARALLEL_8_BIT) // Now the code for ESP32 8 bit parallel
#elif defined (TFT_PARALLEL_8_BIT) // Now the code for ESP32 8-bit parallel
////////////////////////////////////////////////////////////////////////////////////////

/***************************************************************************************
Expand Down Expand Up @@ -793,7 +793,7 @@ bool TFT_eSPI::initDMA(bool ctrl_cs)
.sclk_io_num = TFT_SCLK,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
#ifdef CONFIG_IDF_TARGET_ESP32S2
#ifdef xCONFIG_IDF_TARGET_ESP32S2
.data4_io_num = -1,
.data5_io_num = -1,
.data6_io_num = -1,
Expand Down
Loading

0 comments on commit 651283e

Please sign in to comment.