Bodmer TFT_ILI9341 conflict with STMPE610 Adafruit Touch driver

Hello all !

I have a 2.8 TFT Touch Shield from Adafuit, using ILI9341 display and STMPE610 touch driver (SPI):

All examples work with the adafruit libraries:


I would like to display to be faster, so I replaced the ADAFRUIT_ILI9341 and ADAFRUIT-GFX_Library with Bodmer’s TFT_ILI9341 library:

Now Bodmer’s library works, and it works a lot faster. However, there seems to be a conflict between the Bodmer library and the STMPE610. The code I use:

#include <TFT_ILI9341.h> // Graphics and font library for ILI9341 driver chip
#include <SPI.h>
#include "adafruit_touch.h"

#define TFT_GREY 0x5AEB // New colour

TFT_ILI9341 tft = TFT_ILI9341();  // Invoke library
Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);

void setup(void)

  if (!ts.begin()) {
    Serial.println("Unable to start touchscreen.");
  else {
    Serial.println("Touchscreen started.");
  tft.setCursor(0, 0);
  tft.println("PROGRAM RUNNING");

// using the touch library
  TS_Point p = ts.getPoint();

// these lines do not hget executed well
  tft.println("PRINT ANOTHER LINE");

void loop()

So, I initialize the touchscreen firstly (otherwise the display doesn’t do anything at all), it initializes. I initialize the screen, it gets a grey background and prints PROGRAM RUNNING. Then I execute a function from the touchscreen, the display doesn’t respond well. All it does is output some garble in the area the final letter G has been printed.

I delved into all libraries but have no clue what could cause this… I’m hoping someone came across this and got it to work, or knows how to tackle this.

With kind regards,

Captain Jack

Try enabling transaction support in the TFT library by removing the // in the setup.h file to read:


Report back if this does or does not work.

It works! :slight_smile: Thank you so much.

Am I correct that these transactions basically mean that all SPI settings are stored, the library sets its own settings, performs SPI operations and finally restores the original settings?

Kind regards,


You store a Setting for each device. And use that setting whenever you use the device.

It works well.

Then what I don't understand:

the STMPE610 library uses these transactions afaik, it's enabled in the code

So regardless of whether the TFT library uses them as well, it should not be the TFT library that fails - I would expect the STMPE library to restore SPI to whatever it should was according to the TFT library.

I must be missing something here.

There are two approaches:

  1. Dominant device e.g. TFT sets SPI at start and just assumes all transactions are "in its flavour"
    Other devices e.g. Touch reset the SPI to how they found it.

  2. Each device assumes sets SPI before each transaction.

Method (1) is the fastest. The TFT has millions of SPI transactions. The Touch has hundreds.
Method (2) is not unreasonable.



thank you for your reply, before asking any more questions I will have a good look at the code of both libraries.