zackphillips / TLC5955

Arduino library for the TI TLC5955 LED controller
MIT License
21 stars 11 forks source link

Fix management of SPI settings #8

Closed clarebcook closed 3 years ago

clarebcook commented 3 years ago

This addresses some problems with creating the SPI settings, which were leading to serial timeout errors when loading the files onto our LED boards.

In a previous version, beginTransaction() was always called with the class's mSettings object. However, mSettings was never properly created as a local object, so a default SPISettings object was created every time beginTransaction was called. In that version, we did not actually have any control over the SPI settings, including the baud rate. In the current version prior to this pull request, the problem was addressed by explicitly creating a new SPISettings object whenever beginTransaction was called. This object was created with the correct baud rate. However, creating the SPISettings object with non-default attributes takes longer than creating the default object, which led to serial timeout errors.

This request fixes that error by correctly creating the SPISettings object mSettings only when the class is first initialized, and whenever the baud rate is changed. This prevents the timeout errors while ensuring we have control over the SPI settings being used.

zackphillips commented 3 years ago

Thank you Claire - nice sleuthing. Happy new year!