Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Remove unneeded delay in hspiread32 #14
This reduces the time for a typical readCelcius call from over a
This delay was present between the lowering of the chip select line and
Similar delays exist for software SPI, which are probably also not
I am using an ESP8266 with this library (the Adafruit Feather Huzzah, product 2821) and am using the software SPI interface (didn't engage noggin early enough, pins now soldered up). I have been looking at the performance of this function too. My testing shows that a call to readInternal() then readCelsius() was taking approximately 0.2 seconds, and very occasionally up to 0.8 seconds.
I've made a small change to add a readTemperatures() function that only makes a single spiread32() call, which is where the delay is. However, I've also tested the software SPI calls by replacing the delay(1) entries with delayMicroseconds(25) so by adding the new function, and reducing the delay, I'm now getting a very consistent ~7600 microsecond processing time for the function, and the time taken to read and linearise is now roughly 0.01 seconds... a tremendous improvement.
I will submit a pull request with my changes, hopefully they are appealing. But suffice to say, I second @matthijskooijman's proposed change.