Adafruit_SSD1306
Adafruit_SSD1306 copied to clipboard
Software SPI constructor fails on v1.2.2 Release
-
Arduino board: Uno, M0_Pro
-
Arduino IDE version: v1.8.1 (and v1.8.7)
-
Install Adafruit_SSD1306 via IDE Library Manager
The software SPI constructors work on a Uno when updating from v1.1.x to v1.2.0 or v1.2.1 v1.2.2 and above fail
As far as I can see, the only difference between 1.2.2 and 1.2.1 is to add (PortReg*)casts to the private xxxPort variables in the begin(method). The existing portOutputRegister(P) macros already have casts. It seems superfluous to add an extra cast but it should not make any difference.
Edit. On further examination it is the SPI_TRANSACTION macros that fail. Pre v1.2.2 the backslashes (line-continuation) caused the macro to be redefined from the #else block
When this was corrected, it made the macro call spi->beginTransaction(spiSettings) regardless of spi being NULL for Software SPI. One solution is:
#if defined(SPI_HAS_TRANSACTION) && !defined(ARDUINO_STM32_FEATHER)
#define SPI_TRANSACTION_START \
if (spi) spi->beginTransaction(spiSettings); \
SSD1306_SELECT
#define SPI_TRANSACTION_END \
SSD1306_DESELECT \
if (spi) spi->endTransaction();
#else
#define SPI_TRANSACTION_START SSD1306_SELECT
#define SPI_TRANSACTION_END SSD1306_DESELECT
#endif
I suspect the TRANSACTION code will fail completely on ARDUINO < 157
I don't have a FEATHER. But a tidier solution would be: if (wire != NULL) conditional WIRECLK else SELECT/DESELECT with conditional Transaction when (spi != NULL)
David.