IDT Optical Sensors / Mbed 2 deprecated OB1203_IDT

Dependencies:   mbed OB1203_example_driver

Revision:
22:e23b60520b6a
Parent:
21:97a0d4167902
Child:
24:4e6884f52ba0
--- a/main.cpp	Mon Nov 05 16:51:29 2018 +0000
+++ b/main.cpp	Thu Jul 23 20:24:58 2020 +0000
@@ -2,8 +2,6 @@
 #include "OB1203.h"
 #include "math.h"
 
-
-
 //normal
 I2C i2c(I2C_SDA,I2C_SCL); //instantiate an i2c object from its class
 #define intb_pin D3
@@ -15,7 +13,7 @@
 InterruptIn intb(intb_pin); //declare an interrupt pin for INTB
 
 //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.
+// 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);
@@ -38,7 +36,8 @@
 bool irAGC = 1;
 bool trim_oscillator = 0;
 bool printCurrent = 1;
-//****************************
+bool turn_off_prox_trim = 1;
+//***************************
 
 //internal settings
 bool intFlagged =0;
@@ -70,6 +69,10 @@
     {
         ob1203.ppg_ps_mode = PS_MODE;
     }
+    if (turn_off_prox_trim) {
+        ob1203.led1_trim = 0;
+        ob1203.led2_trim = 0;
+    }
     ob1203.ps_pulses = PS_PULSES(3);
 //    pc.printf("ps_pulses = %02X\r\n",ob1203.ps_pulses);
     ob1203.ps_pwidth = PS_PWIDTH(1);
@@ -109,27 +112,38 @@
         ob1203.ppg_int_en = PPG_INT_ON;
     }
     //PPG
-    ob1203.ir_current = 0x1AF; //max 1023. 3FF
+    ob1203.ir_current = 0x0F; //max 1023. 3FF
     if (spo2)
     {
 //        ob1203.r_current = 0x0FF;
-    ob1203.r_current = 0x1AF; //max 511. 1FF
+    ob1203.r_current = 0x07; //max 511. 1FF
     }
     else 
     {   
         ob1203.r_current = 0;
     }
+    
     ob1203.ppg_ps_gain = PPG_PS_GAIN_1;
+    
     ob1203.ppg_pow_save = PPG_POW_SAVE_OFF;
     ob1203.led_flip = LED_FLIP_OFF;
+    //ob1203.led_flip = LED_FLIP_ON;
     ob1203.ch1_can_ana = PPG_CH1_CAN(0);
     ob1203.ch2_can_ana = PPG_CH2_CAN(0);
     //use rate 1 with pulse width 3 and average 4, or rate 3 with pulse width 4 and average 3 for 100 sps (50Hz basis) or 120 sps sample rate (60Hz basis)
-    ob1203.ppg_avg = PPG_AVG(4); //2^n averages
+    
+    
+    //DEBUGGING******************************************************
+    ob1203.ppg_avg = PPG_AVG(0);
+    //ob1203.ppg_avg = PPG_AVG(4); //2^n averages
+    
+    //DEGUGGING*****************************************************
     ob1203.ppg_rate = PPG_RATE(1); 
+    //ob1203.ppg_rate = PPG_RATE(6);
+    
     ob1203.ppg_pwidth = PPG_PWIDTH(3);
-    ob1203.ppg_freq = PPG_FREQ_50HZ;
-//    ob1203.ppg_freq = PPG_FREQ_60HZ;
+//    ob1203.ppg_freq = PPG_FREQ_50HZ;
+    ob1203.ppg_freq = PPG_FREQ_PRODUCTION;
     ob1203.bio_trim = 3; //max 3 --this dims the ADC sensitivity, but reduces noise
     ob1203.led_trim = 0x00; //can use to overwrite trim setting and max out the current 
     ob1203.ppg_LED_settling = PPG_LED_SETTLING(2); //hidden regstier for adjusting LED setting time (not a factor for noise)
@@ -390,7 +404,7 @@
                             if(irAGC)
                             {
                                 ob1203.do_agc(ppgData[2*n],0);  
-                            }//end IR AGC case 
+                            }//end IR AGC case
                             if(spo2 && redAGC)
                             {
                                 ob1203.do_agc(ppgData[2*n+1],1);