achillhasler / TFT_eTouch

generic touch support for resistive chips
32 stars 10 forks source link

Virtual SPI not working #8

Open vidalperezbohoyo opened 7 months ago

vidalperezbohoyo commented 7 months ago
#include <SPI.h>

#include <TFT_eSPI.h>       
#include <TFT_eTouch.h>      

// Its difficult to have two spi at the same time, i have to create virtual spi for touchscreen
// SPI of the LCD and the XPT2046 are not in the same bus
// ESP32-2432S028
// LCD is working fine

TFT_eSPI tft = TFT_eSPI();  // Invoke custom library

auto vspi = new SPIClass(VSPI);
TFT_eTouch<TFT_eSPI> touch(tft, 33, 36, *vspi);

void setup() {
  Serial.begin( 115200 );

  vspi->begin(25, 39, 32, 33);
  vspi->setFrequency( 60000000 );

  pinMode(vspi->pinSS(), OUTPUT);

  tft.init();
  touch.init();  

``
  //RIGHT COLORS
  tft.writecommand(TFT_MADCTL);
  tft.writedata(0x40);

  tft.fillScreen(TFT_BLACK);
  tft.drawRect(0, 0, tft.width(), tft.height(), TFT_GREEN);

  Serial.println("Config ended");
}

void loop() {

  int16_t x = 0;
  int16_t y = 0;
  // Never entry here 
  if (touch.getXY(x, y)) {
    Serial.print(x);
    Serial.print("   ");
    Serial.println(y);
  }
}

I have tried to create a VSPI bus but only screen is working.

vidalperezbohoyo commented 7 months ago

If i comment tft.init() the touch is working fine...

vidalperezbohoyo commented 7 months ago

Replacing VSPI by HSPI works both at the same time...

achillhasler commented 7 months ago

Thanks for evaluating