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_PULSEOXIMETER_H
AVELARDEV 0:010b908e2187 17 #define MAX30100_PULSEOXIMETER_H
AVELARDEV 0:010b908e2187 18
AVELARDEV 0:010b908e2187 19 #define SAMPLING_FREQUENCY 100
AVELARDEV 0:010b908e2187 20 #define CURRENT_ADJUSTMENT_PERIOD_MS 500
AVELARDEV 0:010b908e2187 21 #define IR_LED_CURRENT MAX30100_LED_CURR_50MA
AVELARDEV 0:010b908e2187 22 #define RED_LED_CURRENT_START MAX30100_LED_CURR_27_1MA
AVELARDEV 0:010b908e2187 23 #define DC_REMOVER_ALPHA 0.95
AVELARDEV 0:010b908e2187 24
AVELARDEV 0:010b908e2187 25 #include <stdint.h>
AVELARDEV 0:010b908e2187 26 #include <vector>
AVELARDEV 0:010b908e2187 27
AVELARDEV 0:010b908e2187 28
AVELARDEV 0:010b908e2187 29 #include "MAX30100.h"
AVELARDEV 0:010b908e2187 30 #include "MAX30100_BeatDetector.h"
AVELARDEV 0:010b908e2187 31 #include "MAX30100_Filters.h"
AVELARDEV 0:010b908e2187 32 #include "MAX30100_SpO2Calculator.h"
AVELARDEV 0:010b908e2187 33
AVELARDEV 0:010b908e2187 34 typedef enum PulseOximeterState {
AVELARDEV 0:010b908e2187 35 PULSEOXIMETER_STATE_INIT,
AVELARDEV 0:010b908e2187 36 PULSEOXIMETER_STATE_IDLE,
AVELARDEV 0:010b908e2187 37 PULSEOXIMETER_STATE_DETECTING
AVELARDEV 0:010b908e2187 38 } PulseOximeterState;
AVELARDEV 0:010b908e2187 39
AVELARDEV 0:010b908e2187 40 typedef enum PulseOximeterDebuggingMode {
AVELARDEV 0:010b908e2187 41 PULSEOXIMETER_DEBUGGINGMODE_NONE,
AVELARDEV 0:010b908e2187 42 PULSEOXIMETER_DEBUGGINGMODE_RAW_VALUES,
AVELARDEV 0:010b908e2187 43 PULSEOXIMETER_DEBUGGINGMODE_AC_VALUES,
AVELARDEV 0:010b908e2187 44 PULSEOXIMETER_DEBUGGINGMODE_PULSEDETECT
AVELARDEV 0:010b908e2187 45 } PulseOximeterDebuggingMode;
AVELARDEV 0:010b908e2187 46
AVELARDEV 0:010b908e2187 47
AVELARDEV 0:010b908e2187 48 class PulseOximeter {
AVELARDEV 0:010b908e2187 49 public:
AVELARDEV 0:010b908e2187 50 PulseOximeter();
AVELARDEV 0:010b908e2187 51
AVELARDEV 0:010b908e2187 52 bool begin(PulseOximeterDebuggingMode debuggingMode_=PULSEOXIMETER_DEBUGGINGMODE_NONE);
AVELARDEV 0:010b908e2187 53 void update();
AVELARDEV 0:010b908e2187 54 float getHeartRate();
AVELARDEV 0:010b908e2187 55 uint8_t getSpO2();
AVELARDEV 0:010b908e2187 56 uint8_t getRedLedCurrentBias();
AVELARDEV 0:010b908e2187 57 void setOnBeatDetectedCallback(void (*cb)());
AVELARDEV 0:010b908e2187 58
AVELARDEV 0:010b908e2187 59 private:
AVELARDEV 0:010b908e2187 60 void checkSample();
AVELARDEV 0:010b908e2187 61 void checkCurrentBias();
AVELARDEV 0:010b908e2187 62
AVELARDEV 0:010b908e2187 63 PulseOximeterState state;
AVELARDEV 0:010b908e2187 64 PulseOximeterDebuggingMode debuggingMode;
AVELARDEV 0:010b908e2187 65 // uint32_t tsFirstBeatDetected;
AVELARDEV 0:010b908e2187 66 // uint32_t tsLastBeatDetected;
AVELARDEV 0:010b908e2187 67 // uint32_t tsLastSample;
AVELARDEV 0:010b908e2187 68 // uint32_t tsLastBiasCheck;
AVELARDEV 0:010b908e2187 69 // uint32_t tsLastCurrentAdjustment;
AVELARDEV 0:010b908e2187 70 BeatDetector beatDetector;
AVELARDEV 0:010b908e2187 71 DCRemover irDCRemover;
AVELARDEV 0:010b908e2187 72 DCRemover redDCRemover;
AVELARDEV 0:010b908e2187 73 FilterBuLp1 lpf;
AVELARDEV 0:010b908e2187 74 uint8_t redLedPower;
AVELARDEV 0:010b908e2187 75 SpO2Calculator spO2calculator;
AVELARDEV 0:010b908e2187 76
AVELARDEV 0:010b908e2187 77 MAX30100 hrm;
AVELARDEV 0:010b908e2187 78
AVELARDEV 0:010b908e2187 79 void (*onBeatDetected)();
AVELARDEV 0:010b908e2187 80 Timer t_Sample;
AVELARDEV 0:010b908e2187 81 Timer t_CurrentBias;
AVELARDEV 0:010b908e2187 82 };
AVELARDEV 0:010b908e2187 83 #endif