Add setFS function. ( Support for file systems other than SPIFFS. )

This commit is contained in:
lovyan03 2019-03-13 21:21:22 +09:00
parent 652383b694
commit 7541cb37f0
2 changed files with 6 additions and 7 deletions

View File

@ -77,12 +77,12 @@ void TFT_eSPI::loadFont(String fontName)
unloadFont();
// 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!");
return;
}
fontFile = SPIFFS.open( "/" + fontName + ".vlw", "r");
fontFile = (_pFS ? *_pFS : SPIFFS).open( "/" + fontName + ".vlw", "r");
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 cx = cursor_x + gdX[gNum];
startWrite(); // Avoid slow ESP32 transaction overhead for every pixel
for (int y = 0; y < gHeight[gNum]; y++)
{
fontFile.read(pbuffer, gWidth[gNum]); //<//
startWrite(); // Avoid slow ESP32 transaction overhead for every pixel
for (int x = 0; x < gWidth[gNum]; 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; }
endWrite();
}
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);
cursor_x += gFont.spaceWidth + 1;
}
endWrite();
}
/***************************************************************************************

View File

@ -41,7 +41,8 @@ fontMetrics gFont = { 0, 0, 0, 0, 0, 0, 0 };
bool fontLoaded = false; // Flags when a anti-aliased font is loaded
void setFS(fs::FS& fs) { _pFS = &fs; }
private:
fs::FS* _pFS = NULL;
void loadMetrics(uint16_t gCount);
uint32_t readInt32(void);