port oxullo library Arduino

Dependents:   MAX30100_oxullo

Committer:
AVELARDEV
Date:
Fri Nov 25 00:52:54 2016 +0000
Revision:
0:010b908e2187
max30100 example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AVELARDEV 0:010b908e2187 1 /*
AVELARDEV 0:010b908e2187 2 Arduino-MAX30100 oximetry / heart rate integrated sensor library
AVELARDEV 0:010b908e2187 3 Copyright (C) 2016 OXullo Intersecans <x@brainrapers.org>
AVELARDEV 0:010b908e2187 4 This program is free software: you can redistribute it and/or modify
AVELARDEV 0:010b908e2187 5 it under the terms of the GNU General Public License as published by
AVELARDEV 0:010b908e2187 6 the Free Software Foundation, either version 3 of the License, or
AVELARDEV 0:010b908e2187 7 (at your option) any later version.
AVELARDEV 0:010b908e2187 8 This program is distributed in the hope that it will be useful,
AVELARDEV 0:010b908e2187 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
AVELARDEV 0:010b908e2187 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
AVELARDEV 0:010b908e2187 11 GNU General Public License for more details.
AVELARDEV 0:010b908e2187 12 You should have received a copy of the GNU General Public License
AVELARDEV 0:010b908e2187 13 along with this program. If not, see <http://www.gnu.org/licenses/>.
AVELARDEV 0:010b908e2187 14 */
AVELARDEV 0:010b908e2187 15
AVELARDEV 0:010b908e2187 16 #ifndef MAX30100_FILTERS_H
AVELARDEV 0:010b908e2187 17 #define MAX30100_FILTERS_H
AVELARDEV 0:010b908e2187 18
AVELARDEV 0:010b908e2187 19 // http://www.schwietering.com/jayduino/filtuino/
AVELARDEV 0:010b908e2187 20 // Low pass butterworth filter order=1 alpha1=0.1
AVELARDEV 0:010b908e2187 21 // Fs=100Hz, Fc=6Hz
AVELARDEV 0:010b908e2187 22 class FilterBuLp1
AVELARDEV 0:010b908e2187 23 {
AVELARDEV 0:010b908e2187 24 public:
AVELARDEV 0:010b908e2187 25 FilterBuLp1()
AVELARDEV 0:010b908e2187 26 {
AVELARDEV 0:010b908e2187 27 v[0]=0.0;
AVELARDEV 0:010b908e2187 28 }
AVELARDEV 0:010b908e2187 29 private:
AVELARDEV 0:010b908e2187 30 float v[2];
AVELARDEV 0:010b908e2187 31 public:
AVELARDEV 0:010b908e2187 32 float step(float x) //class II
AVELARDEV 0:010b908e2187 33 {
AVELARDEV 0:010b908e2187 34 v[0] = v[1];
AVELARDEV 0:010b908e2187 35 v[1] = (2.452372752527856026e-1 * x)
AVELARDEV 0:010b908e2187 36 + (0.50952544949442879485 * v[0]);
AVELARDEV 0:010b908e2187 37 return
AVELARDEV 0:010b908e2187 38 (v[0] + v[1]);
AVELARDEV 0:010b908e2187 39 }
AVELARDEV 0:010b908e2187 40 };
AVELARDEV 0:010b908e2187 41
AVELARDEV 0:010b908e2187 42 // http://sam-koblenski.blogspot.de/2015/11/everyday-dsp-for-programmers-dc-and.html
AVELARDEV 0:010b908e2187 43 class DCRemover
AVELARDEV 0:010b908e2187 44 {
AVELARDEV 0:010b908e2187 45 public:
AVELARDEV 0:010b908e2187 46 DCRemover() : alpha(0), dcw(0)
AVELARDEV 0:010b908e2187 47 {
AVELARDEV 0:010b908e2187 48 }
AVELARDEV 0:010b908e2187 49 DCRemover(float alpha_) : alpha(alpha_), dcw(0)
AVELARDEV 0:010b908e2187 50 {
AVELARDEV 0:010b908e2187 51 }
AVELARDEV 0:010b908e2187 52
AVELARDEV 0:010b908e2187 53 float step(float x)
AVELARDEV 0:010b908e2187 54 {
AVELARDEV 0:010b908e2187 55 float olddcw = dcw;
AVELARDEV 0:010b908e2187 56 dcw = (float)x + alpha * dcw;
AVELARDEV 0:010b908e2187 57
AVELARDEV 0:010b908e2187 58 return dcw - olddcw;
AVELARDEV 0:010b908e2187 59 }
AVELARDEV 0:010b908e2187 60
AVELARDEV 0:010b908e2187 61 float getDCW()
AVELARDEV 0:010b908e2187 62 {
AVELARDEV 0:010b908e2187 63 return dcw;
AVELARDEV 0:010b908e2187 64 }
AVELARDEV 0:010b908e2187 65
AVELARDEV 0:010b908e2187 66 private:
AVELARDEV 0:010b908e2187 67 float alpha;
AVELARDEV 0:010b908e2187 68 float dcw;
AVELARDEV 0:010b908e2187 69 };
AVELARDEV 0:010b908e2187 70
AVELARDEV 0:010b908e2187 71 #endif