5 pixels too wide? also cleaned up tft_espi further and readded comic font

This commit is contained in:
2026-01-10 11:09:11 +01:00
parent 1d053c5dd7
commit 6bd9d1a93b
11 changed files with 1042 additions and 118 deletions

View File

@@ -155,19 +155,6 @@ void TFT_eSPI::loadMetrics(void)
uint32_t headerPtr = 24;
uint32_t bitmapPtr = headerPtr + gFont.gCount * 28;
#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)
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
gdY = (int16_t*)ps_malloc( gFont.gCount * 2); // offset from bitmap top edge from lowest point in any character
gdX = (int8_t*)ps_malloc( gFont.gCount ); // offset for bitmap left edge relative to cursor X
gBitmap = (uint32_t*)ps_malloc( gFont.gCount * 4); // seek pointer to glyph bitmap in the file
}
else
#endif
{
gUnicode = (uint16_t*)malloc( gFont.gCount * 2); // Unicode 16-bit Basic Multilingual Plane (0-FFFF)
gHeight = (uint8_t*)malloc( gFont.gCount ); // Height of glyph

View File

@@ -35,8 +35,6 @@ TFT_eSprite::TFT_eSprite(TFT_eSPI *tft)
_yptr = 0;
_colorMap = nullptr;
_psram_enable = true;
// Ensure end_tft_write() does nothing in inherited functions.
lockTransaction = true;
@@ -162,14 +160,6 @@ void* TFT_eSprite::callocSprite(int16_t w, int16_t h, uint8_t frames)
if (_bpp == 16)
{
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
if ( psramFound() && _psram_enable && !_tft->DMA_Enabled)
{
ptr8 = ( uint8_t*) ps_calloc(frames * w * h + frames, sizeof(uint16_t));
//Serial.println("PSRAM");
}
else
#endif
{
ptr8 = ( uint8_t*) calloc(frames * w * h + frames, sizeof(uint16_t));
//Serial.println("Normal RAM");
@@ -178,10 +168,6 @@ void* TFT_eSprite::callocSprite(int16_t w, int16_t h, uint8_t frames)
else if (_bpp == 8)
{
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
if ( psramFound() && _psram_enable ) ptr8 = ( uint8_t*) ps_calloc(frames * w * h + frames, sizeof(uint8_t));
else
#endif
ptr8 = ( uint8_t*) calloc(frames * w * h + frames, sizeof(uint8_t));
}
@@ -189,10 +175,6 @@ void* TFT_eSprite::callocSprite(int16_t w, int16_t h, uint8_t frames)
{
w = (w+1) & 0xFFFE; // width needs to be multiple of 2, with an extra "off screen" pixel
_iwidth = w;
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
if ( psramFound() && _psram_enable ) ptr8 = ( uint8_t*) ps_calloc(((frames * w * h) >> 1) + frames, sizeof(uint8_t));
else
#endif
ptr8 = ( uint8_t*) calloc(((frames * w * h) >> 1) + frames, sizeof(uint8_t));
}
@@ -206,10 +188,6 @@ void* TFT_eSprite::callocSprite(int16_t w, int16_t h, uint8_t frames)
_iwidth = w; // _iwidth is rounded up to be multiple of 8, so might not be = _dwidth
_bitwidth = w; // _bitwidth will not be rotated whereas _iwidth may be
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
if ( psramFound() && _psram_enable ) ptr8 = ( uint8_t*) ps_calloc(frames * (w>>3) * h + frames, sizeof(uint8_t));
else
#endif
ptr8 = ( uint8_t*) calloc(frames * (w>>3) * h + frames, sizeof(uint8_t));
}

View File

@@ -478,8 +478,6 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
fs_font = true; // Smooth font filing system or array (fs_font = false) flag
#endif
_psram_enable = false;
addr_row = 0xFFFF; // drawPixel command length optimiser
addr_col = 0xFFFF; // drawPixel command length optimiser
@@ -4265,9 +4263,6 @@ void TFT_eSPI::setAttribute(uint8_t attr_id, uint8_t param) {
_utf8 = param;
decoderState = 0;
break;
case PSRAM_ENABLE:
_psram_enable = false;
break;
//case 4: // TBD future feature control
// _tbd = param;
// break;
@@ -4285,8 +4280,6 @@ uint8_t TFT_eSPI::getAttribute(uint8_t attr_id) {
return _cp437;
case UTF8_SWITCH: // ON/OFF control of UTF-8 decoding
return _utf8;
case PSRAM_ENABLE:
return _psram_enable;
//case 3: // TBD future feature control
// return _tbd;
// break;

View File

@@ -811,10 +811,8 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
// id = 0: reserved - may be used in future to reset all attributes to a default state
// id = 1: Turn on (a=true) or off (a=false) GLCD cp437 font character error correction
// id = 2: Turn on (a=true) or off (a=false) UTF8 decoding
// id = 3: Enable or disable use of ESP32 PSRAM (if available)
#define CP437_SWITCH 1
#define UTF8_SWITCH 2
#define PSRAM_ENABLE 3
void setAttribute(uint8_t id = 0, uint8_t a = 0); // Set attribute value
uint8_t getAttribute(uint8_t id = 0); // Get attribute value
@@ -945,7 +943,6 @@ uint8_t spi_write_speed; // SPI write speed
// User sketch manages these via set/getAttribute()
bool _cp437; // If set, use correct CP437 charset (default is OFF)
bool _utf8; // If set, use UTF-8 decoder in print stream 'write()' function (default ON)
bool _psram_enable; // Enable PSRAM use for library functions (TBD) and Sprites
uint32_t _lastColor; // Buffered value of last colour used