You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When sharing SPI with the touch sensor, display can show glitches/artefacts if touch used called immediately after. I noticed it the most while drawing strings with font 2.
; TFT driver configuration
-DUSER_SETUP_LOADED=1
-DST7796_DRIVER=1
-DTFT_WIDTH=320
-DTFT_HEIGHT=480
-DTFT_MISO=4
-DTFT_MOSI=3
-DTFT_SCLK=2
-DTFT_CS=5
-DTFT_DC=7
-DTFT_RST=6
;-DTFT_BL=-1 (hardware)
-DTOUCH_CS=8
-DLOAD_GLCD=1
-DLOAD_FONT2=1
-DLOAD_FONT4=1
-DLOAD_FONT6=1
-DLOAD_FONT7=1
-DLOAD_FONT8=1
-DLOAD_GFXFF=1
-DSMOOTH_FONT=1
-DSPI_FREQUENCY=80000000
; -DSPI_READ_FREQUENCY=20000000 ; same as default; -DSPI_TOUCH_FREQUENCY=2500000 ; same as default
Minimalistic code would be (approximately):
// ... #include's and tft objectvoidsetup() {
tft.init();
tft.setRotation(1);
// ... calibration (optional)
tft.fillScreen(TFT_BLACK);
tft.setTextFont(2); // most noticeable on this font
}
voidloop() {
tft.drawString("Hello! 123", 0, 0);
uint16_t x, y;
tft.getTouchRaw(&x, &y); // not even used, but it matters
}
On the photo below I used different code, but it all comes to the drawing. If necessary I might confirm the problem with the minimalistic code itself.
Result
String, the characters are drawn, but last character has weird, random blue/red/black dots artefacts.
Photo
Expected result
Normal operation without any glitches/artefacts.
Workarounds
Use tft.setTextColor(TFT_WHITE); - it makes rendering (font 2) characters using slower method, which cuts the glitch visibility.
OR, Use different font which uses flower drawing, again, cuts the glitch visibility.
OR, add some delay(2) before using touch related function (2 ms just from my testing on my setup).
OR, add spaces to the end of the text to make last character readable, glitch persists..
OR, maybe lowering display SPI speed could help (but it makes it slower to draw/update, so it's sad).
Other notes
I guess it's due to (shared) SPI speed changes: graphics operations are put to SPI buffer to be pushed out, but before it finishes the speed changes, which makes mess. I tried putting SPI_BUSY_CHECK in the beginning of TFT_eSPI::begin_touch_read_write but it didn't help.
Bug is most noticeable with font 2 due to Faster drawing of characters and background using block write in TFT_eSPI::drawChar. Making it slower by setting textcolor == textbgcolor by setTextColor(...) (which makes it use a lot of drawPixel calls), or using different font (which doesn't have fast drawing) makes it far less noticeable.
The text was updated successfully, but these errors were encountered:
AgainPsychoX
changed the title
Display can show glitches/artefacts if touch used called immediately after
When sharing SPI, display can show glitches/artefacts if touch used called immediately after
Mar 29, 2024
Problem
When sharing SPI with the touch sensor, display can show glitches/artefacts if touch used called immediately after. I noticed it the most while drawing strings with font 2.
My setup
Hardware
Microcontroller: Raspberry Pi Pico
Display: 4'' TFT SPI ST7796 480x320
Display driver: ST7796(S)
Touch chipset: XPT2046
Software
TFT_eSPI library version: 2.5.43
I use PlatformIO with
earlephilhower
Arduino Core:User setup done also via PlatformIO build flags:
Minimalistic code would be (approximately):
On the photo below I used different code, but it all comes to the drawing. If necessary I might confirm the problem with the minimalistic code itself.
Result
String, the characters are drawn, but last character has weird, random blue/red/black dots artefacts.
Photo
Expected result
Normal operation without any glitches/artefacts.
Workarounds
tft.setTextColor(TFT_WHITE);
- it makes rendering (font 2) characters using slower method, which cuts the glitch visibility.delay(2)
before using touch related function (2 ms just from my testing on my setup).OR, add spaces to the end of the text to make last character readable, glitch persists..Other notes
I guess it's due to (shared) SPI speed changes: graphics operations are put to SPI buffer to be pushed out, but before it finishes the speed changes, which makes mess. I tried putting
SPI_BUSY_CHECK
in the beginning ofTFT_eSPI::begin_touch_read_write
but it didn't help.Bug is most noticeable with font 2 due to
Faster drawing of characters and background using block write
inTFT_eSPI::drawChar
. Making it slower by settingtextcolor == textbgcolor
bysetTextColor(...)
(which makes it use a lot ofdrawPixel
calls), or using different font (which doesn't have fast drawing) makes it far less noticeable.The text was updated successfully, but these errors were encountered: