mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-08-04 13:14:46 +02:00
Update for GC9A01 display
Correct sprite rendering GC9A01 expects exact number of pixels to fill setWindow area.
This commit is contained in:
@@ -441,7 +441,7 @@ bool TFT_eSprite::pushRotated(int16_t angle, uint32_t transp)
|
|||||||
if (tpcolor == rp) {
|
if (tpcolor == rp) {
|
||||||
if (pixel_count) {
|
if (pixel_count) {
|
||||||
// TFT window is already clipped, so this is faster than pushImage()
|
// TFT window is already clipped, so this is faster than pushImage()
|
||||||
_tft->setWindow(x - pixel_count, y, x, y);
|
_tft->setWindow(x - pixel_count, y, x - 1, y);
|
||||||
_tft->pushPixels(sline_buffer, pixel_count);
|
_tft->pushPixels(sline_buffer, pixel_count);
|
||||||
pixel_count = 0;
|
pixel_count = 0;
|
||||||
}
|
}
|
||||||
@@ -452,7 +452,7 @@ bool TFT_eSprite::pushRotated(int16_t angle, uint32_t transp)
|
|||||||
} while (++x < max_x && (xs += _cosra) < xe && (ys += _sinra) < ye);
|
} while (++x < max_x && (xs += _cosra) < xe && (ys += _sinra) < ye);
|
||||||
if (pixel_count) {
|
if (pixel_count) {
|
||||||
// TFT window is already clipped, so this is faster than pushImage()
|
// TFT window is already clipped, so this is faster than pushImage()
|
||||||
_tft->setWindow(x - pixel_count, y, x, y);
|
_tft->setWindow(x - pixel_count, y, x - 1, y);
|
||||||
_tft->pushPixels(sline_buffer, pixel_count);
|
_tft->pushPixels(sline_buffer, pixel_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
51
TFT_eSPI.cpp
51
TFT_eSPI.cpp
@@ -1272,7 +1272,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *d
|
|||||||
{
|
{
|
||||||
int32_t len = dw;
|
int32_t len = dw;
|
||||||
uint16_t* ptr = data;
|
uint16_t* ptr = data;
|
||||||
int32_t px = x;
|
int32_t px = x, sx = x;
|
||||||
bool move = true;
|
bool move = true;
|
||||||
uint16_t np = 0;
|
uint16_t np = 0;
|
||||||
|
|
||||||
@@ -1280,7 +1280,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *d
|
|||||||
{
|
{
|
||||||
if (transp != *ptr)
|
if (transp != *ptr)
|
||||||
{
|
{
|
||||||
if (move) { move = false; setWindow(px, y, xe, ye); }
|
if (move) { move = false; sx = px; }
|
||||||
lineBuf[np] = *ptr;
|
lineBuf[np] = *ptr;
|
||||||
np++;
|
np++;
|
||||||
}
|
}
|
||||||
@@ -1289,14 +1289,15 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *d
|
|||||||
move = true;
|
move = true;
|
||||||
if (np)
|
if (np)
|
||||||
{
|
{
|
||||||
pushPixels((uint16_t*)lineBuf, np);
|
setWindow(sx, y, sx + np - 1, y);
|
||||||
np = 0;
|
pushPixels((uint16_t*)lineBuf, np);
|
||||||
|
np = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
px++;
|
px++;
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
if (np) pushPixels((uint16_t*)lineBuf, np);
|
if (np) { setWindow(sx, y, sx + np - 1, y); pushPixels((uint16_t*)lineBuf, np); }
|
||||||
|
|
||||||
y++;
|
y++;
|
||||||
data += w;
|
data += w;
|
||||||
@@ -1361,7 +1362,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint1
|
|||||||
while (dh--) {
|
while (dh--) {
|
||||||
int32_t len = dw;
|
int32_t len = dw;
|
||||||
uint16_t* ptr = (uint16_t*)data;
|
uint16_t* ptr = (uint16_t*)data;
|
||||||
int32_t px = x;
|
int32_t px = x, sx = x;
|
||||||
bool move = true;
|
bool move = true;
|
||||||
|
|
||||||
uint16_t np = 0;
|
uint16_t np = 0;
|
||||||
@@ -1369,21 +1370,22 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint1
|
|||||||
while (len--) {
|
while (len--) {
|
||||||
uint16_t color = pgm_read_word(ptr);
|
uint16_t color = pgm_read_word(ptr);
|
||||||
if (transp != color) {
|
if (transp != color) {
|
||||||
if (move) { move = false; setWindow(px, y, xe, ye); }
|
if (move) { move = false; sx = px; }
|
||||||
lineBuf[np] = color;
|
lineBuf[np] = color;
|
||||||
np++;
|
np++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
move = true;
|
move = true;
|
||||||
if (np) {
|
if (np) {
|
||||||
pushPixels(lineBuf, np);
|
setWindow(sx, y, sx + np - 1, y);
|
||||||
np = 0;
|
pushPixels(lineBuf, np);
|
||||||
|
np = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
px++;
|
px++;
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
if (np) pushPixels(lineBuf, np);
|
if (np) { setWindow(sx, y, sx + np - 1, y); pushPixels(lineBuf, np); }
|
||||||
|
|
||||||
y++;
|
y++;
|
||||||
data += w;
|
data += w;
|
||||||
@@ -1694,13 +1696,13 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *da
|
|||||||
uint8_t* ptr = data;
|
uint8_t* ptr = data;
|
||||||
uint8_t* linePtr = (uint8_t*)lineBuf;
|
uint8_t* linePtr = (uint8_t*)lineBuf;
|
||||||
|
|
||||||
int32_t px = x;
|
int32_t px = x, sx = x;
|
||||||
bool move = true;
|
bool move = true;
|
||||||
uint16_t np = 0;
|
uint16_t np = 0;
|
||||||
|
|
||||||
while (len--) {
|
while (len--) {
|
||||||
if (transp != *ptr) {
|
if (transp != *ptr) {
|
||||||
if (move) { move = false; setWindow(px, y, xe, ye);}
|
if (move) { move = false; sx = px; }
|
||||||
uint8_t color = *ptr;
|
uint8_t color = *ptr;
|
||||||
|
|
||||||
// Shifts are slow so check if colour has changed first
|
// Shifts are slow so check if colour has changed first
|
||||||
@@ -1718,6 +1720,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *da
|
|||||||
else {
|
else {
|
||||||
move = true;
|
move = true;
|
||||||
if (np) {
|
if (np) {
|
||||||
|
setWindow(sx, y, sx + np - 1, y);
|
||||||
pushPixels(lineBuf, np);
|
pushPixels(lineBuf, np);
|
||||||
linePtr = (uint8_t*)lineBuf;
|
linePtr = (uint8_t*)lineBuf;
|
||||||
np = 0;
|
np = 0;
|
||||||
@@ -1727,7 +1730,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *da
|
|||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (np) pushPixels(lineBuf, np);
|
if (np) { setWindow(sx, y, sx + np - 1, y); pushPixels(lineBuf, np); }
|
||||||
y++;
|
y++;
|
||||||
data += w;
|
data += w;
|
||||||
}
|
}
|
||||||
@@ -1749,7 +1752,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *da
|
|||||||
uint32_t len = dw;
|
uint32_t len = dw;
|
||||||
uint8_t * ptr = data;
|
uint8_t * ptr = data;
|
||||||
|
|
||||||
int32_t px = x;
|
int32_t px = x, sx = x;
|
||||||
bool move = true;
|
bool move = true;
|
||||||
uint16_t np = 0;
|
uint16_t np = 0;
|
||||||
|
|
||||||
@@ -1758,7 +1761,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *da
|
|||||||
if (splitFirst) {
|
if (splitFirst) {
|
||||||
index = (*ptr & 0x0F); // odd = bits 3 .. 0
|
index = (*ptr & 0x0F); // odd = bits 3 .. 0
|
||||||
if (index != transp) {
|
if (index != transp) {
|
||||||
move = false; setWindow(px, y, xe, ye);
|
move = false; sx = px;
|
||||||
lineBuf[np] = cmap[index];
|
lineBuf[np] = cmap[index];
|
||||||
np++;
|
np++;
|
||||||
}
|
}
|
||||||
@@ -1775,7 +1778,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *da
|
|||||||
uint16_t index = ((color & 0xF0) >> 4) & 0x0F; // high bits are the even numbers
|
uint16_t index = ((color & 0xF0) >> 4) & 0x0F; // high bits are the even numbers
|
||||||
if (index != transp) {
|
if (index != transp) {
|
||||||
if (move) {
|
if (move) {
|
||||||
move = false; setWindow(px, y, xe, ye);
|
move = false; sx = px;
|
||||||
}
|
}
|
||||||
lineBuf[np] = cmap[index];
|
lineBuf[np] = cmap[index];
|
||||||
np++; // added a pixel
|
np++; // added a pixel
|
||||||
@@ -1783,6 +1786,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *da
|
|||||||
else {
|
else {
|
||||||
move = true;
|
move = true;
|
||||||
if (np) {
|
if (np) {
|
||||||
|
setWindow(sx, y, sx + np - 1, y);
|
||||||
pushPixels(lineBuf, np);
|
pushPixels(lineBuf, np);
|
||||||
np = 0;
|
np = 0;
|
||||||
}
|
}
|
||||||
@@ -1794,7 +1798,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *da
|
|||||||
index = color & 0x0F; // the odd number is 3 .. 0
|
index = color & 0x0F; // the odd number is 3 .. 0
|
||||||
if (index != transp) {
|
if (index != transp) {
|
||||||
if (move) {
|
if (move) {
|
||||||
move = false; setWindow(px, y, xe, ye);
|
move = false; sx = px;
|
||||||
}
|
}
|
||||||
lineBuf[np] = cmap[index];
|
lineBuf[np] = cmap[index];
|
||||||
np++;
|
np++;
|
||||||
@@ -1802,6 +1806,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *da
|
|||||||
else {
|
else {
|
||||||
move = true;
|
move = true;
|
||||||
if (np) {
|
if (np) {
|
||||||
|
setWindow(sx, y, sx + np - 1, y);
|
||||||
pushPixels(lineBuf, np);
|
pushPixels(lineBuf, np);
|
||||||
np = 0;
|
np = 0;
|
||||||
}
|
}
|
||||||
@@ -1815,6 +1820,7 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *da
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (np) {
|
if (np) {
|
||||||
|
setWindow(sx, y, sx + np - 1, y);
|
||||||
pushPixels(lineBuf, np);
|
pushPixels(lineBuf, np);
|
||||||
np = 0;
|
np = 0;
|
||||||
}
|
}
|
||||||
@@ -1830,29 +1836,30 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *da
|
|||||||
|
|
||||||
for (int32_t yp = dy; yp < dy + dh; yp++)
|
for (int32_t yp = dy; yp < dy + dh; yp++)
|
||||||
{
|
{
|
||||||
int32_t px = x;
|
int32_t px = x, sx = x;
|
||||||
bool move = true;
|
bool move = true;
|
||||||
for (int32_t xp = dx; xp < dx + dw; xp++)
|
for (int32_t xp = dx; xp < dx + dw; xp++)
|
||||||
{
|
{
|
||||||
if (data[(xp>>3)] & (0x80 >> (xp & 0x7))) {
|
if (data[(xp>>3)] & (0x80 >> (xp & 0x7))) {
|
||||||
if (move) {
|
if (move) {
|
||||||
move = false;
|
move = false;
|
||||||
setWindow(px, y, xe, ye);
|
sx = px;
|
||||||
}
|
}
|
||||||
np++;
|
np++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
move = true;
|
||||||
if (np) {
|
if (np) {
|
||||||
|
setWindow(sx, y, sx + np - 1, y);
|
||||||
pushBlock(bitmap_fg, np);
|
pushBlock(bitmap_fg, np);
|
||||||
np = 0;
|
np = 0;
|
||||||
move = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
px++;
|
px++;
|
||||||
}
|
}
|
||||||
y++;
|
y++;
|
||||||
data += ww;
|
data += ww;
|
||||||
if (np) { pushBlock(bitmap_fg, np); np = 0; }
|
if (np) { setWindow(sx, y, sx + np - 1, y); pushBlock(bitmap_fg, np); np = 0; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_swapBytes = swap; // Restore old value
|
_swapBytes = swap; // Restore old value
|
||||||
@@ -2900,7 +2907,7 @@ void TFT_eSPI::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32
|
|||||||
uint8_t mask = 0x1;
|
uint8_t mask = 0x1;
|
||||||
begin_tft_write();
|
begin_tft_write();
|
||||||
|
|
||||||
setWindow(xd, yd, xd+5, yd+8);
|
setWindow(xd, yd, xd+5, yd+7);
|
||||||
|
|
||||||
for (int8_t i = 0; i < 5; i++ ) column[i] = pgm_read_byte(font + (c * 5) + i);
|
for (int8_t i = 0; i < 5; i++ ) column[i] = pgm_read_byte(font + (c * 5) + i);
|
||||||
column[5] = 0;
|
column[5] = 0;
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
#ifndef _TFT_eSPIH_
|
#ifndef _TFT_eSPIH_
|
||||||
#define _TFT_eSPIH_
|
#define _TFT_eSPIH_
|
||||||
|
|
||||||
#define TFT_ESPI_VERSION "2.3.82"
|
#define TFT_ESPI_VERSION "2.3.83"
|
||||||
|
|
||||||
// Bit level feature flags
|
// Bit level feature flags
|
||||||
// Bit 0 set: viewport capability
|
// Bit 0 set: viewport capability
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "TFT_eSPI",
|
"name": "TFT_eSPI",
|
||||||
"version": "2.3.82",
|
"version": "2.3.83",
|
||||||
"keywords": "Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, SSD1351, SSD1963, ILI9225, HX8357D",
|
"keywords": "Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, SSD1351, SSD1963, ILI9225, HX8357D",
|
||||||
"description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, ESP8266, ESP32 and STM32",
|
"description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, ESP8266, ESP32 and STM32",
|
||||||
"repository":
|
"repository":
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
name=TFT_eSPI
|
name=TFT_eSPI
|
||||||
version=2.3.82
|
version=2.3.83
|
||||||
author=Bodmer
|
author=Bodmer
|
||||||
maintainer=Bodmer
|
maintainer=Bodmer
|
||||||
sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32
|
sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32
|
||||||
|
Reference in New Issue
Block a user