mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-08-03 04:34:43 +02:00
Fix #2302
ESP32 board packages complain about using -1 to define unused pins!
This commit is contained in:
54
TFT_eSPI.cpp
54
TFT_eSPI.cpp
@@ -533,25 +533,33 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
|
|||||||
void TFT_eSPI::initBus(void) {
|
void TFT_eSPI::initBus(void) {
|
||||||
|
|
||||||
#ifdef TFT_CS
|
#ifdef TFT_CS
|
||||||
pinMode(TFT_CS, OUTPUT);
|
if (TFT_CS >= 0) {
|
||||||
digitalWrite(TFT_CS, HIGH); // Chip select high (inactive)
|
pinMode(TFT_CS, OUTPUT);
|
||||||
|
digitalWrite(TFT_CS, HIGH); // Chip select high (inactive)
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Configure chip select for touchscreen controller if present
|
// Configure chip select for touchscreen controller if present
|
||||||
#ifdef TOUCH_CS
|
#ifdef TOUCH_CS
|
||||||
pinMode(TOUCH_CS, OUTPUT);
|
if (TOUCH_CS >= 0) {
|
||||||
digitalWrite(TOUCH_CS, HIGH); // Chip select high (inactive)
|
pinMode(TOUCH_CS, OUTPUT);
|
||||||
|
digitalWrite(TOUCH_CS, HIGH); // Chip select high (inactive)
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// In parallel mode and with the RP2040 processor, the TFT_WR line is handled in the PIO
|
// In parallel mode and with the RP2040 processor, the TFT_WR line is handled in the PIO
|
||||||
#if defined (TFT_WR) && !defined (ARDUINO_ARCH_RP2040) && !defined (ARDUINO_ARCH_MBED)
|
#if defined (TFT_WR) && !defined (ARDUINO_ARCH_RP2040) && !defined (ARDUINO_ARCH_MBED)
|
||||||
pinMode(TFT_WR, OUTPUT);
|
if (TFT_WR >= 0) {
|
||||||
digitalWrite(TFT_WR, HIGH); // Set write strobe high (inactive)
|
pinMode(TFT_WR, OUTPUT);
|
||||||
|
digitalWrite(TFT_WR, HIGH); // Set write strobe high (inactive)
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TFT_DC
|
#ifdef TFT_DC
|
||||||
pinMode(TFT_DC, OUTPUT);
|
if (TFT_DC >= 0) {
|
||||||
digitalWrite(TFT_DC, HIGH); // Data/Command high = data mode
|
pinMode(TFT_DC, OUTPUT);
|
||||||
|
digitalWrite(TFT_DC, HIGH); // Data/Command high = data mode
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TFT_RST
|
#ifdef TFT_RST
|
||||||
@@ -564,8 +572,10 @@ void TFT_eSPI::initBus(void) {
|
|||||||
#if defined (TFT_PARALLEL_8_BIT)
|
#if defined (TFT_PARALLEL_8_BIT)
|
||||||
|
|
||||||
// Make sure read is high before we set the bus to output
|
// Make sure read is high before we set the bus to output
|
||||||
pinMode(TFT_RD, OUTPUT);
|
if (TFT_RD >= 0) {
|
||||||
digitalWrite(TFT_RD, HIGH);
|
pinMode(TFT_RD, OUTPUT);
|
||||||
|
digitalWrite(TFT_RD, HIGH);
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined (ARDUINO_ARCH_RP2040) && !defined (ARDUINO_ARCH_MBED)// PIO manages pins
|
#if !defined (ARDUINO_ARCH_RP2040) && !defined (ARDUINO_ARCH_MBED)// PIO manages pins
|
||||||
// Set TFT data bus lines to output
|
// Set TFT data bus lines to output
|
||||||
@@ -649,8 +659,10 @@ void TFT_eSPI::init(uint8_t tc)
|
|||||||
|
|
||||||
#if defined (TFT_CS) && !defined(RP2040_PIO_INTERFACE)
|
#if defined (TFT_CS) && !defined(RP2040_PIO_INTERFACE)
|
||||||
// Set to output once again in case MISO is used for CS
|
// Set to output once again in case MISO is used for CS
|
||||||
pinMode(TFT_CS, OUTPUT);
|
if (TFT_CS >= 0) {
|
||||||
digitalWrite(TFT_CS, HIGH); // Chip select high (inactive)
|
pinMode(TFT_CS, OUTPUT);
|
||||||
|
digitalWrite(TFT_CS, HIGH); // Chip select high (inactive)
|
||||||
|
}
|
||||||
#elif defined (ARDUINO_ARCH_ESP8266) && !defined (TFT_PARALLEL_8_BIT) && !defined (RP2040_PIO_SPI)
|
#elif defined (ARDUINO_ARCH_ESP8266) && !defined (TFT_PARALLEL_8_BIT) && !defined (RP2040_PIO_SPI)
|
||||||
spi.setHwCs(1); // Use hardware SS toggling
|
spi.setHwCs(1); // Use hardware SS toggling
|
||||||
#endif
|
#endif
|
||||||
@@ -658,8 +670,10 @@ void TFT_eSPI::init(uint8_t tc)
|
|||||||
|
|
||||||
// Set to output once again in case MISO is used for DC
|
// Set to output once again in case MISO is used for DC
|
||||||
#if defined (TFT_DC) && !defined(RP2040_PIO_INTERFACE)
|
#if defined (TFT_DC) && !defined(RP2040_PIO_INTERFACE)
|
||||||
|
if (TFT_DC >= 0) {
|
||||||
pinMode(TFT_DC, OUTPUT);
|
pinMode(TFT_DC, OUTPUT);
|
||||||
digitalWrite(TFT_DC, HIGH); // Data/Command high = data mode
|
digitalWrite(TFT_DC, HIGH); // Data/Command high = data mode
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_booted = false;
|
_booted = false;
|
||||||
@@ -670,7 +684,9 @@ void TFT_eSPI::init(uint8_t tc)
|
|||||||
#ifdef TFT_RST
|
#ifdef TFT_RST
|
||||||
#if !defined(RP2040_PIO_INTERFACE)
|
#if !defined(RP2040_PIO_INTERFACE)
|
||||||
// Set to output once again in case MISO is used for TFT_RST
|
// Set to output once again in case MISO is used for TFT_RST
|
||||||
pinMode(TFT_RST, OUTPUT);
|
if (TFT_RST >= 0) {
|
||||||
|
pinMode(TFT_RST, OUTPUT);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (TFT_RST >= 0) {
|
if (TFT_RST >= 0) {
|
||||||
writecommand(0x00); // Put SPI bus in known state for TFT with CS tied low
|
writecommand(0x00); // Put SPI bus in known state for TFT with CS tied low
|
||||||
@@ -768,13 +784,17 @@ void TFT_eSPI::init(uint8_t tc)
|
|||||||
setRotation(rotation);
|
setRotation(rotation);
|
||||||
|
|
||||||
#if defined (TFT_BL) && defined (TFT_BACKLIGHT_ON)
|
#if defined (TFT_BL) && defined (TFT_BACKLIGHT_ON)
|
||||||
pinMode(TFT_BL, OUTPUT);
|
if (TFT_BL >= 0) {
|
||||||
digitalWrite(TFT_BL, TFT_BACKLIGHT_ON);
|
pinMode(TFT_BL, OUTPUT);
|
||||||
|
digitalWrite(TFT_BL, TFT_BACKLIGHT_ON);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#if defined (TFT_BL) && defined (M5STACK)
|
#if defined (TFT_BL) && defined (M5STACK)
|
||||||
// Turn on the back-light LED
|
// Turn on the back-light LED
|
||||||
pinMode(TFT_BL, OUTPUT);
|
if (TFT_BL >= 0) {
|
||||||
digitalWrite(TFT_BL, HIGH);
|
pinMode(TFT_BL, OUTPUT);
|
||||||
|
digitalWrite(TFT_BL, HIGH);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user