Add setFS function. ( Support for file systems other than SPIFFS. )
This commit is contained in:
parent
652383b694
commit
7541cb37f0
|
|
@ -77,12 +77,12 @@ void TFT_eSPI::loadFont(String fontName)
|
||||||
unloadFont();
|
unloadFont();
|
||||||
|
|
||||||
// Avoid a crash on the ESP32 if the file does not exist
|
// Avoid a crash on the ESP32 if the file does not exist
|
||||||
if (SPIFFS.exists("/" + fontName + ".vlw") == false) {
|
if ((_pFS ? *_pFS : SPIFFS).exists("/" + fontName + ".vlw") == false) {
|
||||||
Serial.println("Font file " + fontName + " not found!");
|
Serial.println("Font file " + fontName + " not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fontFile = SPIFFS.open( "/" + fontName + ".vlw", "r");
|
fontFile = (_pFS ? *_pFS : SPIFFS).open( "/" + fontName + ".vlw", "r");
|
||||||
|
|
||||||
if(!fontFile) return;
|
if(!fontFile) return;
|
||||||
|
|
||||||
|
|
@ -452,11 +452,10 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||||
int16_t cy = cursor_y + gFont.maxAscent - gdY[gNum];
|
int16_t cy = cursor_y + gFont.maxAscent - gdY[gNum];
|
||||||
int16_t cx = cursor_x + gdX[gNum];
|
int16_t cx = cursor_x + gdX[gNum];
|
||||||
|
|
||||||
startWrite(); // Avoid slow ESP32 transaction overhead for every pixel
|
|
||||||
|
|
||||||
for (int y = 0; y < gHeight[gNum]; y++)
|
for (int y = 0; y < gHeight[gNum]; y++)
|
||||||
{
|
{
|
||||||
fontFile.read(pbuffer, gWidth[gNum]); //<//
|
fontFile.read(pbuffer, gWidth[gNum]); //<//
|
||||||
|
startWrite(); // Avoid slow ESP32 transaction overhead for every pixel
|
||||||
for (int x = 0; x < gWidth[gNum]; x++)
|
for (int x = 0; x < gWidth[gNum]; x++)
|
||||||
{
|
{
|
||||||
uint8_t pixel = pbuffer[x]; //<//
|
uint8_t pixel = pbuffer[x]; //<//
|
||||||
|
|
@ -483,6 +482,7 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dl) { drawFastHLine( xs, y + cy, dl, fg); dl = 0; }
|
if (dl) { drawFastHLine( xs, y + cy, dl, fg); dl = 0; }
|
||||||
|
endWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor_x += gxAdvance[gNum];
|
cursor_x += gxAdvance[gNum];
|
||||||
|
|
@ -493,8 +493,6 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||||
drawRect(cursor_x, cursor_y + gFont.maxAscent - gFont.ascent, gFont.spaceWidth, gFont.ascent, fg);
|
drawRect(cursor_x, cursor_y + gFont.maxAscent - gFont.ascent, gFont.spaceWidth, gFont.ascent, fg);
|
||||||
cursor_x += gFont.spaceWidth + 1;
|
cursor_x += gFont.spaceWidth + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
endWrite();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,8 @@ fontMetrics gFont = { 0, 0, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
bool fontLoaded = false; // Flags when a anti-aliased font is loaded
|
bool fontLoaded = false; // Flags when a anti-aliased font is loaded
|
||||||
|
|
||||||
|
void setFS(fs::FS& fs) { _pFS = &fs; }
|
||||||
private:
|
private:
|
||||||
|
fs::FS* _pFS = NULL;
|
||||||
void loadMetrics(uint16_t gCount);
|
void loadMetrics(uint16_t gCount);
|
||||||
uint32_t readInt32(void);
|
uint32_t readInt32(void);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue