Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual SPI not working #8

Open
vidalperezbohoyo opened this issue Apr 19, 2024 · 3 comments
Open

Virtual SPI not working #8

vidalperezbohoyo opened this issue Apr 19, 2024 · 3 comments

Comments

@vidalperezbohoyo
Copy link

vidalperezbohoyo commented Apr 19, 2024

#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
Copy link
Author

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

@vidalperezbohoyo
Copy link
Author

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

@achillhasler
Copy link
Owner

Thanks for evaluating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants