upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
pulsensor.hpp
1 /*
2  * Author: Andrei Vasiliu <andrei.vasiliu@intel.com>
3  * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
4  * Copyright (c) 2015 Intel Corporation.
5  *
6  * Credits to Adafruit.
7  * Based on Adafruit BMP085 library.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  */
28 #pragma once
29 
30 #include <string>
31 #include <math.h>
32 #include <mraa/pwm.hpp>
33 #include <mraa/aio.hpp>
34 #include <mraa/gpio.hpp>
35 #include <pthread.h>
36 
37 #define HIGH 1
38 #define LOW 0
39 
40 #define TRUE HIGH
41 #define FALSE LOW
42 
46 struct clbk_data {
48 };
49 
50 #include "Callback.hpp"
51 
52 namespace upm {
76 class Pulsensor {
77 
78 public:
79  Pulsensor(Callback *callback);
80 
81  void start_sampler();
82  void stop_sampler();
83 
84 private:
85  static void *do_sample(void *arg);
86  pthread_t sample_thread;
87  uint32_t sample_counter;
88  uint32_t last_beat_time;
89  int threshold;
90  int ibi_rate[10];
91  int ibi;
92  int trough;
93  int peak;
94  int bpm;
95  int apmlitude;
96  uint8_t qs;
97  uint8_t is_pulse;
98  uint8_t first_beat;
99  uint8_t second_beat;
100  uint8_t ret;
101  mraa::Aio pin_ctx;
103  Callback *obj_callback;
104  volatile uint16_t ctx_counter;
105 };
106 }
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
Definition: pulsensor.hpp:46
C++ API for the 3-Wire Pulse Sensor.
Definition: pulsensor.hpp:76
int is_heart_beat
Definition: pulsensor.hpp:47
Definition: max30100.hpp:35