xcoder123 / MAX30100

Driver for MAX30100 using arduino
MIT License
105 stars 32 forks source link

fixed mean diff and enhanced moving average #4

Open aedalzotto opened 5 years ago

aedalzotto commented 5 years ago

Hello,

The mean diff values array are not initialized, so it can get garbage values from memory and make the balance intensities crazy. It is fixed by memsetting at the constructor.

The moving average was enhanced by first checking if the last pulse ocurred long ago (example: the finger was removed and then put back again in the sensor) to reset the moving average array. Then, it is checked if the values of the BPM are out of bounds (50 <= BPM <= 220), so they can be ignored and not added to the moving average. Finally, the moving average sum was enhanced to avoid unnecessary calculations.