Measuring plethysmogram with BH1792GLC (Rohm Semiconductor) and calculating pulse rate

Dependencies:   USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
t_tatsuoka
Date:
Mon Feb 05 21:28:19 2018 +0000
Parent:
0:18d735a66926
Commit message:
Ver. 1.0.1 ???beep?????????????????????????

Changed in this revision

Bh1792glcCtrl.cpp Show annotated file Show diff for this revision Revisions of this file
Bh1792glcCtrl.h Show annotated file Show diff for this revision Revisions of this file
PulseRate.cpp Show annotated file Show diff for this revision Revisions of this file
PulseRate.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 18d735a66926 -r 90f70c146a26 Bh1792glcCtrl.cpp
--- a/Bh1792glcCtrl.cpp	Mon Feb 05 20:22:14 2018 +0000
+++ b/Bh1792glcCtrl.cpp	Mon Feb 05 21:28:19 2018 +0000
@@ -1,8 +1,8 @@
 /**
  *  @file       Bh1792glcCtrl.cpp
  *  @brief      Control BH1792GLC (Plethysmogram sensor by Rohm Semiconductor)
- *  @date       2018.02.03
- *  @version    1.0.0
+ *  @date       2018.02.06
+ *  @version    1.0.1
  */
 #include "Bh1792glcCtrl.h"
 
@@ -74,13 +74,6 @@
     wait(0.1);
 
     ret = send_default_params();
-    if (ret) {
-        // Default param settings error
-        return ret;
-    }
-
-    //_bh_int.fall(&this, Bh1792glcCtrl::data_ready);
-
     return ret;
 }
 
@@ -119,8 +112,3 @@
     ret = _i2c.write((_sad | 0), (char *)reg, 2);
     return ret;
 }
-
-// /** BH1792GLC interrupt service routine
-//  */
-// void Bh1792glcCtrl::data_ready() {
-// }
diff -r 18d735a66926 -r 90f70c146a26 Bh1792glcCtrl.h
--- a/Bh1792glcCtrl.h	Mon Feb 05 20:22:14 2018 +0000
+++ b/Bh1792glcCtrl.h	Mon Feb 05 21:28:19 2018 +0000
@@ -1,8 +1,8 @@
 /**
  *  @file       Bh1792glcCtrl.h
  *  @brief      Header file for Bh1792glcCtrl.cpp
- *  @date       2018.02.03
- *  @version    1.0.0
+ *  @date       2018.02.06
+ *  @version    1.0.1
  */
 #ifndef _INC_Bh1792glcCtrl
 #define _INC_Bh1792glcCtrl
@@ -35,14 +35,12 @@
 private:
     I2C         _i2c;
     DigitalIn   _bh_int;            /* Interrupt from BH1792GLC */
-//    InterruptIn _bh_int;            /* Interrupt from BH1792GLC */
 
     int _sad;
 
     int init();
     int send_default_params();
     int start_measure();
-//    void data_ready();
 
 };
 #endif    /* INC_Bh1792glcCtrl */
diff -r 18d735a66926 -r 90f70c146a26 PulseRate.cpp
--- a/PulseRate.cpp	Mon Feb 05 20:22:14 2018 +0000
+++ b/PulseRate.cpp	Mon Feb 05 21:28:19 2018 +0000
@@ -1,8 +1,8 @@
 /**
  *  @file       PulseRate.cpp
  *  @brief      Measuring plethysmogram and calc pulse rate
- *  @date       2018.02.03
- *  @version    1.1.0
+ *  @date       2018.02.06
+ *  @version    1.1.1
  */
 #include "PulseRate.h"
 
@@ -40,6 +40,7 @@
     _val = 0;
     _wave_flag = false;
     _pr_flag = false;
+    _sync_flag = false;
     _sampling_num = 0;
     _mv_idx = 0;
     _beep.period(1.0/BEEP_FREQ);
@@ -112,7 +113,8 @@
     }
 
     /* Control LED and Beep */
-    if(_pr_flag) {
+    if(_sync_flag) {
+        _sync_flag = false;
         _sync_led = LED_ON;
         _beep.write(BEEP_LOUD);
     } else {
@@ -216,4 +218,5 @@
 
     /* Set pulse rate flag */
     _pr_flag = true;
+    _sync_flag = true;
 }
diff -r 18d735a66926 -r 90f70c146a26 PulseRate.h
--- a/PulseRate.h	Mon Feb 05 20:22:14 2018 +0000
+++ b/PulseRate.h	Mon Feb 05 21:28:19 2018 +0000
@@ -1,8 +1,8 @@
 /**
  *  @file       PulseRate.h
  *  @brief      Header file for PulseRate.cpp
- *  @date       2018.02.03
- *  @version    1.1.0
+ *  @date       2018.02.06
+ *  @version    1.1.1
  */
 #ifndef _INC_PulseRate
 #define _INC_PulseRate
@@ -33,7 +33,12 @@
 
 #define MV_LENGTH (5)           /* Number of moving averaging for pulse detection */
 #define TH_COEF (0.993)         /* Coefficient for pulse threshold (exponential decline) */
+
+#ifdef _OP_MODE_INT_AD
 #define PEAK_MIN (127)          /* Ignore waveform as pulse under this value */
+#elif defined _OP_MODE_BH1792GLC
+#define PEAK_MIN (63)           /* Ignore waveform as pulse under this value */
+#endif
 
 #define PR_LENGTH (5)           /* Number of average for pulse rate */
 #define PR_1MIN_SPL (6000)      /* Number of sampling for 1 minute (60*100) */
@@ -92,6 +97,7 @@
 
     int32_t     _pr;                /* Pulse rate value */
     bool        _pr_flag;           /* Pulse rate set flag */
+    bool        _sync_flag;         /* Pulse sync sign flag */
 
     /* Member functions */
     void init();
diff -r 18d735a66926 -r 90f70c146a26 main.cpp
--- a/main.cpp	Mon Feb 05 20:22:14 2018 +0000
+++ b/main.cpp	Mon Feb 05 21:28:19 2018 +0000
@@ -1,8 +1,8 @@
 /**
  *  @file       main.cpp
  *  @brief      Measuring plethysmogram and pulse rate with BH1792GLC
- *  @date       2018.02.03
- *  @version    1.0.0
+ *  @date       2018.02.06
+ *  @version    1.0.1
  */
 #include "mbed.h"
 #include "USBSerial.h"