From 4fd8aa8bd43f1df96dbd856eff3307f6829944c8 Mon Sep 17 00:00:00 2001 From: Frogomeli Date: Fri, 4 Mar 2022 17:31:42 +0100 Subject: [PATCH 1/2] Allow generic driver to use a custom SPI port I have a SeeedStudio Wio Terminal. I'm using this lib in VS Code with PlatformIO but the lib don't use the `SPICOM` variable when it's a generic device. Steps to reproduce (using a Wio Terminal): * Create a project using PlatformIO * Add the TFT_eSPI lib to the project * Add in the build flags these lines ``` build_flags = -DUSER_SETUP_LOADED=1 -DILI9341_DRIVER=1 -DHASSPI=1 -DSPICOM=LCD_SPI -DTFT_CS=LCD_SS_PIN -DTFT_DC=LCD_DC -DTFT_RST=LCD_RESET -DTFT_BL=LCD_BACKLIGHT -DTFT_BACKLIGHT_ON=HIGH -DTFT_BACKLINGT_V=2000 ``` * Compile and transfer to the device => only backlight works --- Processors/TFT_eSPI_Generic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Processors/TFT_eSPI_Generic.c b/Processors/TFT_eSPI_Generic.c index 82c60276..a2464c41 100644 --- a/Processors/TFT_eSPI_Generic.c +++ b/Processors/TFT_eSPI_Generic.c @@ -7,7 +7,11 @@ //////////////////////////////////////////////////////////////////////////////////////// // Select the SPI port to use -SPIClass& spi = SPI; +#ifndef SPICOM + SPIClass& spi = SPI; +#else + SPIClass& spi = SPICOM; +#endif //////////////////////////////////////////////////////////////////////////////////////// #if defined (TFT_SDA_READ) && !defined (TFT_PARALLEL_8_BIT) From 6f4cf86834cec614f7d4b6cdea5aa9645783b289 Mon Sep 17 00:00:00 2001 From: Bodmer Date: Sat, 5 Mar 2022 00:22:32 +0000 Subject: [PATCH 2/2] Make compatible with existing port define --- Processors/TFT_eSPI_Generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Processors/TFT_eSPI_Generic.c b/Processors/TFT_eSPI_Generic.c index a2464c41..14eda108 100644 --- a/Processors/TFT_eSPI_Generic.c +++ b/Processors/TFT_eSPI_Generic.c @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////////////////// // Select the SPI port to use -#ifndef SPICOM - SPIClass& spi = SPI; +#ifdef TFT_SPI_PORT + SPIClass& spi = TFT_SPI_PORT; #else - SPIClass& spi = SPICOM; + SPIClass& spi = SPI; #endif ////////////////////////////////////////////////////////////////////////////////////////