Commit 1edfe6c6 authored by Bodmer's avatar Bodmer

Fic #311

Pixel function used wrong width and height for bounds check.
Remove String variable in smooth font code (not used)
Correct ESP8266UncannyEyes example for new setAddrWindow parameters
parent 66a21cb7
...@@ -76,15 +76,13 @@ void TFT_eSPI::loadFont(String fontName) ...@@ -76,15 +76,13 @@ void TFT_eSPI::loadFont(String fontName)
unloadFont(); unloadFont();
_gFontFilename = "/" + fontName + ".vlw";
// 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(_gFontFilename) == false) { if (SPIFFS.exists("/" + fontName + ".vlw") == false) {
Serial.println("Font file " + fontName + " not found!"); Serial.println("Font file " + fontName + " not found!");
return; return;
} }
fontFile = SPIFFS.open( _gFontFilename, "r"); fontFile = SPIFFS.open( "/" + fontName + ".vlw", "r");
if(!fontFile) return; if(!fontFile) return;
......
...@@ -39,8 +39,6 @@ fontMetrics gFont = { 0, 0, 0, 0, 0, 0, 0 }; ...@@ -39,8 +39,6 @@ fontMetrics gFont = { 0, 0, 0, 0, 0, 0, 0 };
int8_t* gdX = NULL; //leftExtent int8_t* gdX = NULL; //leftExtent
uint32_t* gBitmap = NULL; //file pointer to greyscale bitmap uint32_t* gBitmap = NULL; //file pointer to greyscale bitmap
String _gFontFilename;
bool fontLoaded = false; // Flags when a anti-aliased font is loaded bool fontLoaded = false; // Flags when a anti-aliased font is loaded
private: private:
......
...@@ -1059,6 +1059,8 @@ int16_t TFT_eSprite::height(void) ...@@ -1059,6 +1059,8 @@ int16_t TFT_eSprite::height(void)
// Does nothing for 8 and 16 bpp sprites. TODO allow rotation of these sprites // Does nothing for 8 and 16 bpp sprites. TODO allow rotation of these sprites
void TFT_eSprite::setRotation(uint8_t rotation) void TFT_eSprite::setRotation(uint8_t rotation)
{ {
if (_bpp != 1) return;
_rotation = rotation; _rotation = rotation;
if (rotation == 0 && _iwidth > _iheight) swap_coord(_iwidth, _iheight); if (rotation == 0 && _iwidth > _iheight) swap_coord(_iwidth, _iheight);
if (rotation == 1 && _iwidth < _iheight) swap_coord(_iwidth, _iheight); if (rotation == 1 && _iwidth < _iheight) swap_coord(_iwidth, _iheight);
...@@ -1085,19 +1087,22 @@ uint8_t TFT_eSprite::getRotation(void) ...@@ -1085,19 +1087,22 @@ uint8_t TFT_eSprite::getRotation(void)
void TFT_eSprite::drawPixel(int32_t x, int32_t y, uint32_t color) void TFT_eSprite::drawPixel(int32_t x, int32_t y, uint32_t color)
{ {
// Range checking // Range checking
if ((x < 0) || (y < 0) ||(x >= _width) || (y >= _height) || !_created) return; if ((x < 0) || (y < 0) || !_created) return;
if (_bpp == 16) if (_bpp == 16)
{ {
if ((x >= _iwidth) || (y >= _iheight)) return;
color = (color >> 8) | (color << 8); color = (color >> 8) | (color << 8);
_img[x+y*_iwidth] = (uint16_t) color; _img[x+y*_iwidth] = (uint16_t) color;
} }
else if (_bpp == 8) else if (_bpp == 8)
{ {
if ((x >= _iwidth) || (y >= _iheight)) return;
_img8[x+y*_iwidth] = (uint8_t)((color & 0xE000)>>8 | (color & 0x0700)>>6 | (color & 0x0018)>>3); _img8[x+y*_iwidth] = (uint8_t)((color & 0xE000)>>8 | (color & 0x0700)>>6 | (color & 0x0018)>>3);
} }
else // 1 bpp else // 1 bpp
{ {
if ((x >= _dwidth) || (y >= _dheight)) return;
if (_rotation == 1) if (_rotation == 1)
{ {
uint16_t tx = x; uint16_t tx = x;
......
...@@ -141,7 +141,7 @@ void drawEye( // Renders one eye. Inputs must be pre-clipped & valid. ...@@ -141,7 +141,7 @@ void drawEye( // Renders one eye. Inputs must be pre-clipped & valid.
// reset on each frame here in case of an SPI glitch. // reset on each frame here in case of an SPI glitch.
//eye[e].tft.setAddrWindow(319-127, 0, 319, 127); //eye[e].tft.setAddrWindow(319-127, 0, 319, 127);
eye[e].tft.setAddrWindow(0, 0, 128, 128); eye[e].tft.setAddrWindow(0, 0, 127, 127);
//digitalWrite(eye[e].cs, LOW); // Chip select //digitalWrite(eye[e].cs, LOW); // Chip select
......
{ {
"name": "TFT_eSPI", "name": "TFT_eSPI",
"version": "1.4.6", "version": "1.4.7",
"keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789", "keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789",
"description": "A TFT and ePaper SPI graphics library for ESP8266 and ESP32", "description": "A TFT and ePaper SPI graphics library for ESP8266 and ESP32",
"repository": "repository":
......
name=TFT_eSPI name=TFT_eSPI
version=1.4.6 version=1.4.7
author=Bodmer author=Bodmer
maintainer=Bodmer maintainer=Bodmer
sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment