port oxullo library Arduino
Embed:
(wiki syntax)
Show/hide line numbers
MAX30100_Filters.h
00001 /* 00002 Arduino-MAX30100 oximetry / heart rate integrated sensor library 00003 Copyright (C) 2016 OXullo Intersecans <x@brainrapers.org> 00004 This program is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation, either version 3 of the License, or 00007 (at your option) any later version. 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 You should have received a copy of the GNU General Public License 00013 along with this program. If not, see <http://www.gnu.org/licenses/>. 00014 */ 00015 00016 #ifndef MAX30100_FILTERS_H 00017 #define MAX30100_FILTERS_H 00018 00019 // http://www.schwietering.com/jayduino/filtuino/ 00020 // Low pass butterworth filter order=1 alpha1=0.1 00021 // Fs=100Hz, Fc=6Hz 00022 class FilterBuLp1 00023 { 00024 public: 00025 FilterBuLp1() 00026 { 00027 v[0]=0.0; 00028 } 00029 private: 00030 float v[2]; 00031 public: 00032 float step(float x) //class II 00033 { 00034 v[0] = v[1]; 00035 v[1] = (2.452372752527856026e-1 * x) 00036 + (0.50952544949442879485 * v[0]); 00037 return 00038 (v[0] + v[1]); 00039 } 00040 }; 00041 00042 // http://sam-koblenski.blogspot.de/2015/11/everyday-dsp-for-programmers-dc-and.html 00043 class DCRemover 00044 { 00045 public: 00046 DCRemover() : alpha(0), dcw(0) 00047 { 00048 } 00049 DCRemover(float alpha_) : alpha(alpha_), dcw(0) 00050 { 00051 } 00052 00053 float step(float x) 00054 { 00055 float olddcw = dcw; 00056 dcw = (float)x + alpha * dcw; 00057 00058 return dcw - olddcw; 00059 } 00060 00061 float getDCW() 00062 { 00063 return dcw; 00064 } 00065 00066 private: 00067 float alpha; 00068 float dcw; 00069 }; 00070 00071 #endif
Generated on Wed Jul 13 2022 10:11:08 by
1.7.2