Sensirion / arduino-gas-index-algorithm

Arduino Library for Sensirion's Gas Index Algorithm, providing a VOC and NOx Index output signal calculated from the SGP40/41 raw signals
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

Sample period in examples will be (slightly) longer than 1 second #6

Closed nickion closed 7 months ago

nickion commented 7 months ago

While delay(1000) should block for around 1 second, the example doesn't take into account the use of delay() elsewhere. It would be more accurate to note the time of the last sample in loop(), and trigger a new sample when more than 1000ms have elapsed; while examples should be kept simple, this, along with a comment for why it is preferable to blindly using delay(), could be educational for the reader who is unfamiliar with that approach. The advice in the readme to change the default period in the algorithm from 1 second is also ill advised because this could be overwritten in an update, and the code could usefully mention the constructor variant that takes a sample period. Arguably better still, only have a constructor that takes a sample period, though this would now break existing code.

LeonieFierz commented 7 months ago

Thank you for your inputs.