Commit 89bf0ce6 authored by Bodmer's avatar Bodmer

Fix #581 plus

Update 4 bit Sprite code
Update Animate_Dial example to use italic font with minimised character set, add original jpeg graphic.
Raise to 2.1.8
parent 611ca4b2
...@@ -376,7 +376,7 @@ int16_t TFT_eSprite::getPivotY(void) ...@@ -376,7 +376,7 @@ int16_t TFT_eSprite::getPivotY(void)
#define FP_SCALE 10 #define FP_SCALE 10
bool TFT_eSprite::pushRotated(int16_t angle, int32_t transp) bool TFT_eSprite::pushRotated(int16_t angle, int32_t transp)
{ {
if ( !_created ) return false; if ( !_created || _bpp == 4) return false;
// Bounding box parameters // Bounding box parameters
int16_t min_x; int16_t min_x;
...@@ -444,8 +444,8 @@ bool TFT_eSprite::pushRotated(int16_t angle, int32_t transp) ...@@ -444,8 +444,8 @@ bool TFT_eSprite::pushRotated(int16_t angle, int32_t transp)
*************************************************************************************x*/ *************************************************************************************x*/
bool TFT_eSprite::pushRotated(TFT_eSprite *spr, int16_t angle, int32_t transp) bool TFT_eSprite::pushRotated(TFT_eSprite *spr, int16_t angle, int32_t transp)
{ {
if ( !_created ) return false; // Check this Sprite is created if ( !_created || _bpp == 4) return false; // Check this Sprite is created
if ( !spr->_created ) return false; // Ckeck destination Sprite is created if ( !spr->_created || spr->_bpp == 4) return false; // Ckeck destination Sprite is created
// Bounding box parameters // Bounding box parameters
int16_t min_x; int16_t min_x;
...@@ -688,9 +688,9 @@ uint8_t TFT_eSprite::readPixelValue(int32_t x, int32_t y) ...@@ -688,9 +688,9 @@ uint8_t TFT_eSprite::readPixelValue(int32_t x, int32_t y)
if (_bpp == 4) if (_bpp == 4)
{ {
if ((x & 0x01) == 0) if ((x & 0x01) == 0)
return ((_img4[((x+y*_iwidth)>>1)] & 0xF0) >> 4) & 0x0F; // even index = bits 7 .. 4 return _img4[((x+y*_iwidth)>>1)] >> 4; // even index = bits 7 .. 4
else else
return _img4[((x-1+y*_iwidth)>>1)] & 0x0F; // odd index = bits 3 .. 0. return _img4[((x+y*_iwidth)>>1)] & 0x0F; // odd index = bits 3 .. 0.
} }
return readPixel(x, y); return readPixel(x, y);
} }
...@@ -726,9 +726,9 @@ uint16_t TFT_eSprite::readPixel(int32_t x, int32_t y) ...@@ -726,9 +726,9 @@ uint16_t TFT_eSprite::readPixel(int32_t x, int32_t y)
{ {
uint16_t color; uint16_t color;
if ((x & 0x01) == 0) if ((x & 0x01) == 0)
color = _colorMap[((_img4[((x+y*_iwidth)>>1)] & 0xF0) >> 4) & 0x0F ]; // even index = bits 7 .. 4 color = _colorMap[_img4[((x+y*_iwidth)>>1)] >> 4]; // even index = bits 7 .. 4
else else
color = _colorMap[_img4[((x-1+y*_iwidth)>>1)] & 0x0F]; // odd index = bits 3 .. 0. color = _colorMap[_img4[((x+y*_iwidth)>>1)] & 0x0F]; // odd index = bits 3 .. 0.
return color; return color;
} }
...@@ -752,8 +752,8 @@ uint16_t TFT_eSprite::readPixel(int32_t x, int32_t y) ...@@ -752,8 +752,8 @@ uint16_t TFT_eSprite::readPixel(int32_t x, int32_t y)
uint16_t color = (_img8[(x + y * _bitwidth)>>3] << (x & 0x7)) & 0x80; uint16_t color = (_img8[(x + y * _bitwidth)>>3] << (x & 0x7)) & 0x80;
if (color >> 7) return _tft->bitmap_fg; if (color) return _tft->bitmap_fg;
else return _tft->bitmap_bg; else return _tft->bitmap_bg;
} }
...@@ -1038,10 +1038,10 @@ void TFT_eSprite::pushColor(uint32_t color) ...@@ -1038,10 +1038,10 @@ void TFT_eSprite::pushColor(uint32_t color)
{ {
uint8_t c = (uint8_t)color & 0x0F; uint8_t c = (uint8_t)color & 0x0F;
if ((_xptr & 0x01) == 0) { if ((_xptr & 0x01) == 0) {
_img4[(_xptr + _yptr * _iwidth)>>1] = ((c << 4) & 0xF0) | (_img4[(_xptr + _yptr * _iwidth)>>1] & 0x0F); // new color is in bits 7 .. 4 _img4[(_xptr + _yptr * _iwidth)>>1] = (c << 4) | (_img4[(_xptr + _yptr * _iwidth)>>1] & 0x0F); // new color is in bits 7 .. 4
} }
else { else {
_img4[(_xptr - 1 + _yptr * _iwidth)>>1] = (_img4[(_xptr - 1 + _yptr * _iwidth)>>1] & 0xF0) | c; // new color is the low bits _img4[(_xptr + _yptr * _iwidth)>>1] = (_img4[(_xptr + _yptr * _iwidth)>>1] & 0xF0) | c; // new color is the low bits
} }
} }
...@@ -1101,9 +1101,9 @@ void TFT_eSprite::writeColor(uint16_t color) ...@@ -1101,9 +1101,9 @@ void TFT_eSprite::writeColor(uint16_t color)
{ {
uint8_t c = (uint8_t)color & 0x0F; uint8_t c = (uint8_t)color & 0x0F;
if ((_xptr & 0x01) == 0) if ((_xptr & 0x01) == 0)
_img4[(_xptr + _yptr * _iwidth)>>1] = ((c << 4) & 0xF0) | (_img4[(_xptr + _yptr * _iwidth)>>1] & 0x0F); // new color is in bits 7 .. 4 _img4[(_xptr + _yptr * _iwidth)>>1] = (c << 4) | (_img4[(_xptr + _yptr * _iwidth)>>1] & 0x0F); // new color is in bits 7 .. 4
else else
_img4[(_xptr - 1 + _yptr * _iwidth)>>1] = (_img4[(_xptr - 1 + _yptr * _iwidth)>>1] & 0xF0) | c; // new color is the low bits (x is odd) _img4[(_xptr + _yptr * _iwidth)>>1] = (_img4[(_xptr + _yptr * _iwidth)>>1] & 0xF0) | c; // new color is the low bits (x is odd)
} }
else drawPixel(_xptr, _yptr, color); else drawPixel(_xptr, _yptr, color);
...@@ -1370,13 +1370,11 @@ void TFT_eSprite::drawPixel(int32_t x, int32_t y, uint32_t color) ...@@ -1370,13 +1370,11 @@ void TFT_eSprite::drawPixel(int32_t x, int32_t y, uint32_t color)
else if (_bpp == 4) else if (_bpp == 4)
{ {
uint8_t c = color & 0x0F; uint8_t c = color & 0x0F;
int index = 0; int index = (x+y*_iwidth)>>1;;
if ((x & 0x01) == 0) { if ((x & 0x01) == 0) {
index = (x+y*_iwidth)>>1; _img4[index] = (uint8_t)((c << 4) | (_img4[index] & 0x0F));
_img4[index] = (uint8_t)(((c << 4) & 0xF0) | (_img4[index] & 0x0F));
} }
else { else {
index = (x-1+y*_iwidth)>>1;
_img4[index] = (uint8_t)(c | (_img4[index] & 0xF0)); _img4[index] = (uint8_t)(c | (_img4[index] & 0xF0));
} }
} }
...@@ -1501,7 +1499,7 @@ void TFT_eSprite::drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color) ...@@ -1501,7 +1499,7 @@ void TFT_eSprite::drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color)
else { else {
uint8_t c = (uint8_t)color & 0xF; uint8_t c = (uint8_t)color & 0xF;
while (h--) { while (h--) {
_img4[(x - 1 + _iwidth * y)>>1] = (uint8_t) (c | (_img4[(x - 1 + _iwidth * y)>>1] & 0xF0)); // x is odd; new color goes into the low bits. _img4[(x + _iwidth * y)>>1] = (uint8_t) (c | (_img4[(x + _iwidth * y)>>1] & 0xF0)); // x is odd; new color goes into the low bits.
y++; y++;
} }
} }
......
This diff is collapsed.
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_ #ifndef _TFT_eSPIH_
#define _TFT_eSPIH_ #define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.1.7" #define TFT_ESPI_VERSION "2.1.8"
/*************************************************************************************** /***************************************************************************************
** Section 1: Load required header files ** Section 1: Load required header files
......
...@@ -82,7 +82,7 @@ void setup() { ...@@ -82,7 +82,7 @@ void setup() {
// Load the font and create the Sprite for reporting the value // Load the font and create the Sprite for reporting the value
spr.loadFont(AA_FONT_LARGE); spr.loadFont(AA_FONT_LARGE);
spr_width = spr.textWidth("188"); spr_width = spr.textWidth("277");
spr.createSprite(spr_width, spr.fontHeight()); spr.createSprite(spr_width, spr.fontHeight());
uint16_t bg_color = tft.readPixel(120, 120); // Get colour from dial centre uint16_t bg_color = tft.readPixel(120, 120); // Get colour from dial centre
spr.fillSprite(bg_color); spr.fillSprite(bg_color);
...@@ -163,10 +163,6 @@ void plotNeedle(int16_t angle, uint16_t ms_delay) ...@@ -163,10 +163,6 @@ void plotNeedle(int16_t angle, uint16_t ms_delay)
{ {
static int16_t old_angle = -120; // Starts at -120 degrees static int16_t old_angle = -120; // Starts at -120 degrees
// Trig values for the rotation
int32_t sinra;
int32_t cosra;
// Bounding box parameters // Bounding box parameters
static int16_t min_x; static int16_t min_x;
static int16_t min_y; static int16_t min_y;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
{ {
"name": "TFT_eSPI", "name": "TFT_eSPI",
"version": "2.1.7", "version": "2.1.8",
"keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140", "keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140",
"description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32", "description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32",
"repository": "repository":
......
name=TFT_eSPI name=TFT_eSPI
version=2.1.7 version=2.1.8
author=Bodmer author=Bodmer
maintainer=Bodmer maintainer=Bodmer
sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32 sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32
......
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