Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed OB1203_example_driver
Diff: main.cpp
- Revision:
- 16:0a113303c3ed
- Parent:
- 14:ae0be10b73cd
- Child:
- 17:81a9df351dcd
--- a/main.cpp Wed Jul 25 22:08:43 2018 +0000
+++ b/main.cpp Fri Sep 28 21:55:21 2018 +0000
@@ -17,9 +17,9 @@
//setting three 3 pins high to function as pullups for SDA, SCL and INTB
//Connect these pins to SDA, SCL and INTB by 2.7K resistors.
//5K resistors also work usually
-//DigitalOut sda_pullup(D10,1);
-//DigitalOut scl_pullup(D11,1);
-//DigitalOut intb_pullup(D12,1);
+DigitalOut sda_pullup(D10,1);
+DigitalOut scl_pullup(D11,1);
+DigitalOut intb_pullup(D12,1);
OB1203 ob1203(&i2c); //instantiate the OB1203 object from its class and pass i2c object
Serial pc(USBTX, USBRX,256000); //create a serial port for printing data to a pc
@@ -27,7 +27,7 @@
//USER CONFIGURABLE*********
-bool mode = 1; //0 for PS_LS, 1 for PPG
+bool mode = 1; //0 for PS_LS, 1 for PPG (ignores PS, LS and temp)
bool meas_ps = 1;
bool spo2 = 1; //0 for HR, 1 for SpO2
bool afull = 1; //use Afull interrupt--otherwise PPG new data interrupt
@@ -88,14 +88,20 @@
ob1203.ps_hys_level = 0;
meas_ps ? ob1203.ps_current = 0x1FF : ob1203.ps_current = 0x000;
// ob1203.ps_current = 0;
- ob1203.ps_thres_hi = 0xFF;
- ob1203.ps_thres_lo = 0x00;
+ //ob1203.ps_thres_hi = 0xFF;
+ //ob1203.ps_thres_lo = 0x00;
+
+ ob1203.ps_thres_hi = 2000;
+ ob1203.ps_thres_lo = 1000;
+
//interrupts
ob1203.ls_int_sel = LS_INT_SEL_W;
ob1203.ls_var_mode = LS_THRES_INT_MODE;
- ob1203.ls_int_en = LS_INT_ON;
- ob1203.ppg_ps_en = PPG_PS_ON;
+ //ob1203.ls_int_en = LS_INT_ON;
+ ob1203.ls_int_en = LS_INT_OFF;
+
+ ob1203.ppg_ps_en = PPG_PS_ON; //enable measurements
ob1203.ps_logic_mode = PS_INT_READ_CLEARS;
ob1203.ps_int_en = PS_INT_ON;
@@ -151,14 +157,7 @@
if(mode)
{
- if(spo2)
- {
- ob1203.init_spo2();
- }
- else
- {
- ob1203.init_hr();
- }
+ spo2 ? ob1203.init_spo2() : ob1203.init_hr();
}
else
{
@@ -228,7 +227,7 @@
uint32_t targetIRcounts = 196608; //0.75 of full scale
uint32_t targetRcounts = 196608; //0.75 of full scale
// uint32_t tol1 = 8192; //1 5 bit increment
- uint32_t tol1 = 4096; //1 5 bit increment
+ uint32_t tol1 = 8192; //1 5 bit increment
uint32_t tol2 = 39321; //for 90% and 60% large limits
uint32_t step = 8;
uint32_t IR_in_range = 0;
@@ -485,7 +484,8 @@
else //LS and PS measurement case
{
wait_ms(sample_delay);
- if( meas_ps ? ob1203.psIsNew() : ob1203.lsIsNew() )
+
+ if( meas_ps ? ob1203.psIsNew() : ob1203.lsIsNew() )
{
meas_ps ? valid = ob1203.get_ps_ls_data(ps_ls_data) : valid = ob1203.get_ls_data(ps_ls_data);
if(meas_ps)