Unbalanced TFT_RD_LOW() / TFT_RD_HIGH() due to conditional assembly
Hello,
since sporadically, I have some problems with my SPI communication on an esp8266 device, I was looking into the code to see if there are some unbalanced calls to TFT_RD_HIGH(), TFT_RD_LOW(), SPI_CS_LOW() and _HIGH(), and so on. You get the idea.
While I do not think this is related to my problem, from looking at the code, I believe that the TFT_RD_HIGH() here: https://github.com/adafruit/Adafruit-GFX-Library/blob/f542ec270f264e2aff9a4553172a730b07e559df/Adafruit_SPITFT.cpp#L2178 is not correctly balanced with its corresponding TFT_RD_LOW().
Why? The TFT_RD_LOW is on line 2151, (https://github.com/adafruit/Adafruit-GFX-Library/blob/f542ec270f264e2aff9a4553172a730b07e559df/Adafruit_SPITFT.cpp#L2151), before an #if defined(AVR). The TFT_RD_HIGH in line 2178 is inside the #else block of that #if. Thus, if AVR is defined, the TFT_RD_HIGH is not executed.
Unfortunately, I do not have an AVR with a corresponding TFT, so I cannot do some tests on my own.
My recommendation is to exchanges lines 2178 (https://github.com/adafruit/Adafruit-GFX-Library/blob/f542ec270f264e2aff9a4553172a730b07e559df/Adafruit_SPITFT.cpp#L2178) and 2179 (https://github.com/adafruit/Adafruit-GFX-Library/blob/f542ec270f264e2aff9a4553172a730b07e559df/Adafruit_SPITFT.cpp#L2179), so the TFT_RD_HIGH() is outside if that #if / #else / #endif block.
Do you agree on this?
EDIT: If you agree on this, I can send a PR.