aromring / MAX30102_by_RF

Arduino C code for MAX30102 pulse oximetry sensor (MAXIM Integrated, Inc.)
166 stars 73 forks source link

perf: Only use Red & IR arrays from function param #37

Closed 0xMihir closed 2 years ago

0xMihir commented 2 years ago

This will close #36. Before, the rf_heart_rate_and_oxygen_saturation method allocates an_x and an_y on every call. With the default settings, this will allocate 800 bytes of RAM, reducing the number of other libraries that can be used. This is especially noticeable on the Arduino Uno, which only has 2KB of memory

I changed this to perform calculations (and modify) on two float arrays passed in the parameter. Although this goes against general programming paradigms, I believe this tradeoff is worth making to reduce memory usage.