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:

ADAFRUIT_ILI9341
ADAFRUIT-GFX-Library
ADAFRUIT_STMPE610

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

https://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjn3qvM5uvWAhUELFAKHcLXCe4QFggqMAA&url=https%3A%2F%2Fgithub.com%2FBodmer%2FTFT_ILI9341&usg=AOvVaw3SYsXZMZR2GIUisLTwH1yX

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)
{
  Serial.begin(9600);

  if (!ts.begin()) {
    Serial.println("Unable to start touchscreen.");
  }
  else {
    Serial.println("Touchscreen started.");
  }
    
  tft.init();
  tft.setRotation(0);
  
  tft.fillScreen(TFT_GREY);
  tft.setCursor(0, 0);
  tft.setTextFont(1);
  tft.setTextColor(TFT_WHITE,TFT_BLACK);
  tft.setTextSize(1);
  tft.println("START");
  tft.println("PROGRAM RUNNING");

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

// these lines do not hget executed well
  tft.fillScreen(TFT_BLUE);
  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:

#define SUPPORT_TRANSACTIONS

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,

Jack

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.

David.

David,

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

Cheers,

Jack