XarkLabs / PDQ_GFX_Libs

Optimized fork of Adafruit's GFX library (and drivers) for Arduino (AVR).
114 stars 37 forks source link

Fixed setting of SPI registers in spi_begin, restructured slightly to support changes #24

Closed Delph closed 3 years ago

Delph commented 3 years ago

Enabling ST7735_SAVE_SPCR breaks this library (resulting in a white screen). The SPI Status Register contains a flag for doubling the SPI speed which was not being written like it is by Arduino's SPI.beginTransaction.

spi_begin and spi_end now follow the same structure as their SPI library counterparts. spi_end no longer switches back to the old settings (I was still experiencing problems in this scenario, even with the display being the only device used on the bus). spi_begin instead copies the values into the registers instead of switching them. While switching them back in spi_end would be playing nice for other libraries, other libraries should be using SPI.beginTransaction with SPISettings or implementing their own system to set the settings before trying to use the SPI. https://github.com/arduino/ArduinoCore-avr/blob/master/libraries/SPI/src/SPI.h#L203

Finally, the #define for enabling this setting writing behaviour is renamed to ST7735_SAVE_SPI_SETTINGS, a compiler warning is emitted for the old one (ST7735_SAVE_SPCR) and sets ST7735_SAVE_SPI_SETTINGS for you. Turning this off is acceptable when there is no other other SPI device use and you want that extra little bit of speed.

Delph commented 3 years ago

I should add, this might affect other display drivers, but since I don't have anything other than ST7735 I can't test and I haven't checked.