Nkawu / TFT_22_ILI9225

Arduino library for 2.2" TFT display modules with ILI9225 driver
GNU General Public License v3.0
82 stars 43 forks source link

Hardware SPI on ESP32 #61

Open dl9rdz opened 5 years ago

dl9rdz commented 5 years ago

ESP32 supports hardware SPI on arbitrary GPIO pins.

Could you add a feature that allows using hardware SPI instead of software SPI in the code?(instead of activating software SPI for non-standard pins, the pin numbers need to be passed to _spi.begin(...) as arguments)

A quick&dirty hack solution (for ESP32 only, tested and functional) is to replace

// Hardware SPI
SPI_BEGIN();

with

// Hardware SPI
if(_clk < 0) { SPI_BEGIN();  } 
else {
    SPI_OBJECT.begin(_clk, -1, _sdi, _cs);
    _clk = -1;  // force use of hardware SPI in remaining code parts
}

But this is not elegant, and of course should be made conditional only for ESP32

MrEliptik commented 3 years ago

Hi @dl9rdz , I'm also using an ESP32 and I'd like to use the hardware SPI. While there's no real implementation, I'd like to use your method, but I can't figure out how. I've replace SPI_BEGIN(); with your code, and I'm still initializing the TFT_22_ILI8225 object with the SDI and CLK pin, as I understand we specify those pins in the else statement. But using that, the display stays white, like there's no communication. I'm using TFT_RST=4, TFT_RS=19, TFT_CS= 5, TFT_SDI=23,#define TFT_CLK=18 (VSPI pins). Object declaration TFT_22_ILI9225 tft = TFT_22_ILI9225(TFT_RST, TFT_RS, TFT_CS, TFT_SDI, TFT_CLK, TFT_LED);