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
main.cpp@17:81a9df351dcd, 2018-10-02 (annotated)
- Committer:
- laserdad
- Date:
- Tue Oct 02 13:24:40 2018 +0000
- Revision:
- 17:81a9df351dcd
- Parent:
- 16:0a113303c3ed
added some comments for nrfPort
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
laserdad | 0:e9ae48b7f6f6 | 1 | #include "mbed.h" |
laserdad | 0:e9ae48b7f6f6 | 2 | #include "OB1203.h" |
laserdad | 0:e9ae48b7f6f6 | 3 | #include "math.h" |
laserdad | 4:3aee2ca931b8 | 4 | //#include "SoftI2C.h" |
laserdad | 0:e9ae48b7f6f6 | 5 | |
laserdad | 14:ae0be10b73cd | 6 | |
laserdad | 14:ae0be10b73cd | 7 | //normal |
laserdad | 14:ae0be10b73cd | 8 | I2C i2c(I2C_SDA,I2C_SCL); //instantiate an i2c object from its class |
laserdad | 0:e9ae48b7f6f6 | 9 | #define intb_pin D3 |
laserdad | 0:e9ae48b7f6f6 | 10 | |
laserdad | 14:ae0be10b73cd | 11 | //slave board// |
laserdad | 14:ae0be10b73cd | 12 | //I2C i2c(D12,PA_7); |
laserdad | 14:ae0be10b73cd | 13 | //#define intb_pin D10 |
laserdad | 14:ae0be10b73cd | 14 | |
laserdad | 14:ae0be10b73cd | 15 | InterruptIn intb(intb_pin); //declare an interrupt pin for INTB |
laserdad | 0:e9ae48b7f6f6 | 16 | |
laserdad | 14:ae0be10b73cd | 17 | //setting three 3 pins high to function as pullups for SDA, SCL and INTB |
laserdad | 14:ae0be10b73cd | 18 | //Connect these pins to SDA, SCL and INTB by 2.7K resistors. |
laserdad | 14:ae0be10b73cd | 19 | //5K resistors also work usually |
laserdad | 16:0a113303c3ed | 20 | DigitalOut sda_pullup(D10,1); |
laserdad | 16:0a113303c3ed | 21 | DigitalOut scl_pullup(D11,1); |
laserdad | 16:0a113303c3ed | 22 | DigitalOut intb_pullup(D12,1); |
laserdad | 13:5ce84c68066e | 23 | |
laserdad | 14:ae0be10b73cd | 24 | OB1203 ob1203(&i2c); //instantiate the OB1203 object from its class and pass i2c object |
laserdad | 14:ae0be10b73cd | 25 | Serial pc(USBTX, USBRX,256000); //create a serial port for printing data to a pc |
laserdad | 17:81a9df351dcd | 26 | //Serial nrfPort(PA_9, PA_10, 115200); |
laserdad | 17:81a9df351dcd | 27 | //nrfPort.printf("my data %f\r\n",mydata); |
laserdad | 17:81a9df351dcd | 28 | |
laserdad | 14:ae0be10b73cd | 29 | Timer t; //use a microsecond timer for time stamping data |
laserdad | 0:e9ae48b7f6f6 | 30 | |
laserdad | 1:fb6b2b4d5d8a | 31 | |
laserdad | 6:aaa2f8fb5123 | 32 | //USER CONFIGURABLE********* |
laserdad | 16:0a113303c3ed | 33 | bool mode = 1; //0 for PS_LS, 1 for PPG (ignores PS, LS and temp) |
laserdad | 7:3ed0f0522b43 | 34 | bool meas_ps = 1; |
laserdad | 12:5de5f550e765 | 35 | bool spo2 = 1; //0 for HR, 1 for SpO2 |
laserdad | 4:3aee2ca931b8 | 36 | bool afull = 1; //use Afull interrupt--otherwise PPG new data interrupt |
laserdad | 14:ae0be10b73cd | 37 | bool meas_temp = 0; |
laserdad | 13:5ce84c68066e | 38 | bool printAvg = 0; //default 0 print raw data |
laserdad | 13:5ce84c68066e | 39 | bool redAGC = 1; |
laserdad | 13:5ce84c68066e | 40 | bool IRAGC = 1; |
laserdad | 14:ae0be10b73cd | 41 | bool trim_oscillator = 1; |
laserdad | 14:ae0be10b73cd | 42 | bool printCurrent = 1; |
laserdad | 6:aaa2f8fb5123 | 43 | //**************************** |
laserdad | 6:aaa2f8fb5123 | 44 | |
laserdad | 6:aaa2f8fb5123 | 45 | //internal settings |
laserdad | 6:aaa2f8fb5123 | 46 | bool intFlagged =0; |
laserdad | 6:aaa2f8fb5123 | 47 | int sample_delay = 25; //ms |
laserdad | 1:fb6b2b4d5d8a | 48 | |
laserdad | 14:ae0be10b73cd | 49 | void defaultConfig() //populate the default settings here |
laserdad | 0:e9ae48b7f6f6 | 50 | { |
laserdad | 14:ae0be10b73cd | 51 | //high accuracy oscillator trim overwrite option |
laserdad | 14:ae0be10b73cd | 52 | ob1203.osc_trim = 0x3F; //max trim code =0x3F |
laserdad | 14:ae0be10b73cd | 53 | //temperature sensor settings (hidden registers) |
laserdad | 4:3aee2ca931b8 | 54 | meas_temp ? ob1203.temp_en = TEMP_ON : ob1203.temp_en = TEMP_OFF; |
laserdad | 14:ae0be10b73cd | 55 | //LS settings |
laserdad | 12:5de5f550e765 | 56 | ob1203.ls_res = LS_RES(2); //2= 18bit 100ms, 0= max res |
laserdad | 12:5de5f550e765 | 57 | ob1203.ls_rate = LS_RATE(2); //2 =100ms, 4 = 500ms |
laserdad | 4:3aee2ca931b8 | 58 | ob1203.ls_gain = LS_GAIN(3); //gain 3 default (range) |
laserdad | 1:fb6b2b4d5d8a | 59 | ob1203.ls_thres_hi = 0x000FFFFF; |
laserdad | 0:e9ae48b7f6f6 | 60 | ob1203.ls_thres_lo = 0; |
laserdad | 0:e9ae48b7f6f6 | 61 | ob1203.ls_sai = LS_SAI_OFF; |
laserdad | 0:e9ae48b7f6f6 | 62 | ob1203.ls_mode = RGB_MODE; |
laserdad | 0:e9ae48b7f6f6 | 63 | ob1203.ls_en = LS_ON; |
laserdad | 14:ae0be10b73cd | 64 | //PS and PPG settings |
laserdad | 0:e9ae48b7f6f6 | 65 | ob1203.ps_sai_en = PS_SAI_OFF; |
laserdad | 5:ebe305e08430 | 66 | // ob1203.ps_sai_en = PS_SAI_ON; |
laserdad | 1:fb6b2b4d5d8a | 67 | if(mode) |
laserdad | 1:fb6b2b4d5d8a | 68 | { |
laserdad | 3:d3a1fc19bee6 | 69 | if (spo2) |
laserdad | 3:d3a1fc19bee6 | 70 | { |
laserdad | 3:d3a1fc19bee6 | 71 | ob1203.ppg_ps_mode = SPO2_MODE; |
laserdad | 3:d3a1fc19bee6 | 72 | } |
laserdad | 3:d3a1fc19bee6 | 73 | else |
laserdad | 3:d3a1fc19bee6 | 74 | { |
laserdad | 3:d3a1fc19bee6 | 75 | ob1203.ppg_ps_mode = HR_MODE; |
laserdad | 3:d3a1fc19bee6 | 76 | } |
laserdad | 3:d3a1fc19bee6 | 77 | |
laserdad | 1:fb6b2b4d5d8a | 78 | } |
laserdad | 1:fb6b2b4d5d8a | 79 | else |
laserdad | 1:fb6b2b4d5d8a | 80 | { |
laserdad | 1:fb6b2b4d5d8a | 81 | ob1203.ppg_ps_mode = PS_MODE; |
laserdad | 1:fb6b2b4d5d8a | 82 | } |
laserdad | 12:5de5f550e765 | 83 | ob1203.ps_pulses = PS_PULSES(3); |
laserdad | 1:fb6b2b4d5d8a | 84 | // pc.printf("ps_pulses = %02X\r\n",ob1203.ps_pulses); |
laserdad | 7:3ed0f0522b43 | 85 | ob1203.ps_pwidth = PS_PWIDTH(1); |
laserdad | 7:3ed0f0522b43 | 86 | ob1203.ps_rate = PS_RATE(4); |
laserdad | 1:fb6b2b4d5d8a | 87 | // pc.printf("ps_rate = %02X\r\n",ob1203.ps_rate); |
laserdad | 12:5de5f550e765 | 88 | ob1203.ps_avg_en = PS_AVG_OFF; |
laserdad | 0:e9ae48b7f6f6 | 89 | ob1203.ps_can_ana = PS_CAN_ANA_0; |
laserdad | 14:ae0be10b73cd | 90 | ob1203.ps_digital_can = 150; |
laserdad | 0:e9ae48b7f6f6 | 91 | ob1203.ps_hys_level = 0; |
laserdad | 14:ae0be10b73cd | 92 | meas_ps ? ob1203.ps_current = 0x1FF : ob1203.ps_current = 0x000; |
laserdad | 4:3aee2ca931b8 | 93 | // ob1203.ps_current = 0; |
laserdad | 16:0a113303c3ed | 94 | //ob1203.ps_thres_hi = 0xFF; |
laserdad | 16:0a113303c3ed | 95 | //ob1203.ps_thres_lo = 0x00; |
laserdad | 16:0a113303c3ed | 96 | |
laserdad | 16:0a113303c3ed | 97 | ob1203.ps_thres_hi = 2000; |
laserdad | 16:0a113303c3ed | 98 | ob1203.ps_thres_lo = 1000; |
laserdad | 16:0a113303c3ed | 99 | |
laserdad | 0:e9ae48b7f6f6 | 100 | |
laserdad | 0:e9ae48b7f6f6 | 101 | //interrupts |
laserdad | 0:e9ae48b7f6f6 | 102 | ob1203.ls_int_sel = LS_INT_SEL_W; |
laserdad | 0:e9ae48b7f6f6 | 103 | ob1203.ls_var_mode = LS_THRES_INT_MODE; |
laserdad | 16:0a113303c3ed | 104 | //ob1203.ls_int_en = LS_INT_ON; |
laserdad | 16:0a113303c3ed | 105 | ob1203.ls_int_en = LS_INT_OFF; |
laserdad | 16:0a113303c3ed | 106 | |
laserdad | 16:0a113303c3ed | 107 | ob1203.ppg_ps_en = PPG_PS_ON; //enable measurements |
laserdad | 4:3aee2ca931b8 | 108 | |
laserdad | 0:e9ae48b7f6f6 | 109 | ob1203.ps_logic_mode = PS_INT_READ_CLEARS; |
laserdad | 0:e9ae48b7f6f6 | 110 | ob1203.ps_int_en = PS_INT_ON; |
laserdad | 0:e9ae48b7f6f6 | 111 | ob1203.ls_persist = LS_PERSIST(2); |
laserdad | 0:e9ae48b7f6f6 | 112 | ob1203.ps_persist = PS_PERSIST(2); |
laserdad | 11:640cced1ee5d | 113 | |
laserdad | 11:640cced1ee5d | 114 | |
laserdad | 11:640cced1ee5d | 115 | //BIO SETTINGS |
laserdad | 4:3aee2ca931b8 | 116 | //int |
laserdad | 4:3aee2ca931b8 | 117 | if(afull) |
laserdad | 4:3aee2ca931b8 | 118 | { |
laserdad | 4:3aee2ca931b8 | 119 | ob1203.afull_int_en = AFULL_INT_ON; |
laserdad | 4:3aee2ca931b8 | 120 | ob1203.ppg_int_en = PPG_INT_OFF; |
laserdad | 4:3aee2ca931b8 | 121 | } |
laserdad | 4:3aee2ca931b8 | 122 | else |
laserdad | 4:3aee2ca931b8 | 123 | { |
laserdad | 4:3aee2ca931b8 | 124 | ob1203.afull_int_en = AFULL_INT_OFF; |
laserdad | 4:3aee2ca931b8 | 125 | ob1203.ppg_int_en = PPG_INT_ON; |
laserdad | 4:3aee2ca931b8 | 126 | } |
laserdad | 0:e9ae48b7f6f6 | 127 | //PPG |
laserdad | 13:5ce84c68066e | 128 | ob1203.ir_current = 0x1AF; //max 1023. 3FF |
laserdad | 3:d3a1fc19bee6 | 129 | if (spo2) |
laserdad | 3:d3a1fc19bee6 | 130 | { |
laserdad | 4:3aee2ca931b8 | 131 | // ob1203.r_current = 0x0FF; |
laserdad | 13:5ce84c68066e | 132 | ob1203.r_current = 0x1AF; //max 511. 1FF |
laserdad | 3:d3a1fc19bee6 | 133 | } |
laserdad | 3:d3a1fc19bee6 | 134 | else |
laserdad | 3:d3a1fc19bee6 | 135 | { |
laserdad | 3:d3a1fc19bee6 | 136 | ob1203.r_current = 0; |
laserdad | 3:d3a1fc19bee6 | 137 | } |
laserdad | 10:7fbf298ee05f | 138 | ob1203.ppg_ps_gain = PPG_PS_GAIN_1; |
laserdad | 0:e9ae48b7f6f6 | 139 | ob1203.ppg_pow_save = PPG_POW_SAVE_OFF; |
laserdad | 0:e9ae48b7f6f6 | 140 | ob1203.led_flip = LED_FLIP_OFF; |
laserdad | 11:640cced1ee5d | 141 | ob1203.ch1_can_ana = PPG_CH1_CAN(0); |
laserdad | 11:640cced1ee5d | 142 | ob1203.ch2_can_ana = PPG_CH2_CAN(0); |
laserdad | 14:ae0be10b73cd | 143 | //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) |
laserdad | 14:ae0be10b73cd | 144 | ob1203.ppg_avg = PPG_AVG(4); //2^n averages |
laserdad | 14:ae0be10b73cd | 145 | ob1203.ppg_rate = PPG_RATE(1); |
laserdad | 12:5de5f550e765 | 146 | ob1203.ppg_pwidth = PPG_PWIDTH(3); |
laserdad | 12:5de5f550e765 | 147 | ob1203.ppg_freq = PPG_FREQ_50HZ; |
laserdad | 12:5de5f550e765 | 148 | // ob1203.ppg_freq = PPG_FREQ_60HZ; |
laserdad | 14:ae0be10b73cd | 149 | ob1203.bio_trim = 3; //max 3 --this dims the ADC sensitivity, but reduces noise |
laserdad | 14:ae0be10b73cd | 150 | ob1203.led_trim = 0x00; //can use to overwrite trim setting and max out the current |
laserdad | 14:ae0be10b73cd | 151 | ob1203.ppg_LED_settling = PPG_LED_SETTLING(2); //hidden regstier for adjusting LED setting time (not a factor for noise) |
laserdad | 14:ae0be10b73cd | 152 | ob1203.ppg_ALC_track = PPG_ALC_TRACK(2); //hidden register for adjusting ALC track and hold time (not a factor for noise) |
laserdad | 14:ae0be10b73cd | 153 | ob1203.diff = DIFF_ON; //hidden register for turning off subtraction of residual ambient light after ALC |
laserdad | 14:ae0be10b73cd | 154 | ob1203.alc = ALC_ON; //hidden register for turning off ambient light cancelleation track and hold circuit |
laserdad | 14:ae0be10b73cd | 155 | ob1203.sig_out = SIGNAL_OUT; //hidden register for selecting ambient sample or LED sample if DIFF is off |
laserdad | 0:e9ae48b7f6f6 | 156 | ob1203.fifo_rollover_en = FIFO_ROLL_ON; |
laserdad | 13:5ce84c68066e | 157 | ob1203.fifo_afull_advance_warning = AFULL_ADVANCE_WARNING(0x0F); //warn as quickly as possible (after 17 samples with 0x0F) |
laserdad | 13:5ce84c68066e | 158 | |
laserdad | 14:ae0be10b73cd | 159 | //run initialization according to user compile settings |
laserdad | 14:ae0be10b73cd | 160 | |
laserdad | 0:e9ae48b7f6f6 | 161 | if(mode) |
laserdad | 0:e9ae48b7f6f6 | 162 | { |
laserdad | 16:0a113303c3ed | 163 | spo2 ? ob1203.init_spo2() : ob1203.init_hr(); |
laserdad | 0:e9ae48b7f6f6 | 164 | } |
laserdad | 0:e9ae48b7f6f6 | 165 | else |
laserdad | 0:e9ae48b7f6f6 | 166 | { |
laserdad | 5:ebe305e08430 | 167 | meas_ps ? ob1203.init_ps_rgb() : ob1203.init_rgb(); |
laserdad | 0:e9ae48b7f6f6 | 168 | } |
laserdad | 14:ae0be10b73cd | 169 | if(trim_oscillator) |
laserdad | 14:ae0be10b73cd | 170 | ob1203.setOscTrim(); |
laserdad | 14:ae0be10b73cd | 171 | |
laserdad | 0:e9ae48b7f6f6 | 172 | } |
laserdad | 0:e9ae48b7f6f6 | 173 | |
laserdad | 1:fb6b2b4d5d8a | 174 | void regDump(uint8_t Addr, uint8_t startByte, uint8_t endByte) |
laserdad | 1:fb6b2b4d5d8a | 175 | { |
laserdad | 1:fb6b2b4d5d8a | 176 | /*print the values of up to 20 registers--buffer limit, e.g.*/ |
laserdad | 1:fb6b2b4d5d8a | 177 | char regData[20]; |
laserdad | 1:fb6b2b4d5d8a | 178 | int numBytes; |
laserdad | 1:fb6b2b4d5d8a | 179 | if (endByte>=startByte) { |
laserdad | 1:fb6b2b4d5d8a | 180 | numBytes = (endByte-startByte+1) < 20 ? (endByte-startByte+1) : 20; |
laserdad | 1:fb6b2b4d5d8a | 181 | } else { |
laserdad | 1:fb6b2b4d5d8a | 182 | numBytes=1; |
laserdad | 1:fb6b2b4d5d8a | 183 | } |
laserdad | 1:fb6b2b4d5d8a | 184 | |
laserdad | 1:fb6b2b4d5d8a | 185 | regData[0] = startByte; |
laserdad | 1:fb6b2b4d5d8a | 186 | i2c.write(Addr,regData,1,true); |
laserdad | 1:fb6b2b4d5d8a | 187 | i2c.read(Addr, regData, numBytes); |
laserdad | 1:fb6b2b4d5d8a | 188 | for(int n=0; n<numBytes; n++) { |
laserdad | 1:fb6b2b4d5d8a | 189 | pc.printf("%02X, %02X \r\n", startByte+n, regData[n]); |
laserdad | 1:fb6b2b4d5d8a | 190 | } |
laserdad | 1:fb6b2b4d5d8a | 191 | } |
laserdad | 1:fb6b2b4d5d8a | 192 | |
laserdad | 0:e9ae48b7f6f6 | 193 | |
laserdad | 0:e9ae48b7f6f6 | 194 | void intEvent(void) |
laserdad | 0:e9ae48b7f6f6 | 195 | { |
laserdad | 0:e9ae48b7f6f6 | 196 | intFlagged = 1; |
laserdad | 0:e9ae48b7f6f6 | 197 | } |
laserdad | 0:e9ae48b7f6f6 | 198 | |
laserdad | 0:e9ae48b7f6f6 | 199 | int main() |
laserdad | 14:ae0be10b73cd | 200 | /*This program is messy bacause it allows several different print options and interrupt modes |
laserdad | 14:ae0be10b73cd | 201 | Most of the variables are associated with an optional FIR filter to make data pretty. |
laserdad | 14:ae0be10b73cd | 202 | */ |
laserdad | 0:e9ae48b7f6f6 | 203 | { |
laserdad | 4:3aee2ca931b8 | 204 | int numInts = 0; |
laserdad | 10:7fbf298ee05f | 205 | uint32_t running_avg = 10; |
laserdad | 10:7fbf298ee05f | 206 | uint32_t ps_running_avg = 100; |
laserdad | 7:3ed0f0522b43 | 207 | uint32_t ps_avg_ptr = 0; |
laserdad | 3:d3a1fc19bee6 | 208 | char avg_ptr = 0; |
laserdad | 4:3aee2ca931b8 | 209 | int baseline_ptr = 0; |
laserdad | 10:7fbf298ee05f | 210 | uint32_t running_baseline = 240; |
laserdad | 3:d3a1fc19bee6 | 211 | int first = 1; |
laserdad | 3:d3a1fc19bee6 | 212 | uint32_t IRavg = 0; |
laserdad | 3:d3a1fc19bee6 | 213 | uint32_t Ravg = 0; |
laserdad | 3:d3a1fc19bee6 | 214 | uint32_t IRprev = 0; |
laserdad | 3:d3a1fc19bee6 | 215 | uint32_t Rprev = 0; |
laserdad | 3:d3a1fc19bee6 | 216 | uint32_t prevAvg = 0; |
laserdad | 3:d3a1fc19bee6 | 217 | uint32_t IR_avg_buffer[running_avg]; |
laserdad | 3:d3a1fc19bee6 | 218 | uint32_t R_avg_buffer[running_avg]; |
laserdad | 4:3aee2ca931b8 | 219 | uint32_t IR_baseline_buffer[running_baseline]; |
laserdad | 4:3aee2ca931b8 | 220 | uint32_t R_baseline_buffer[running_baseline]; |
laserdad | 4:3aee2ca931b8 | 221 | uint32_t IRbaseline_prev=0;; |
laserdad | 4:3aee2ca931b8 | 222 | uint32_t Rbaseline_prev=0;; |
laserdad | 4:3aee2ca931b8 | 223 | uint32_t IRbaseline=0; |
laserdad | 4:3aee2ca931b8 | 224 | uint32_t Rbaseline=0; |
laserdad | 4:3aee2ca931b8 | 225 | uint32_t prevBaseline=0; |
laserdad | 7:3ed0f0522b43 | 226 | uint32_t PSavg = 0; |
laserdad | 7:3ed0f0522b43 | 227 | uint32_t PSprev = 0; |
laserdad | 7:3ed0f0522b43 | 228 | uint32_t PS_avg_buffer[ps_running_avg]; |
laserdad | 7:3ed0f0522b43 | 229 | |
laserdad | 13:5ce84c68066e | 230 | uint32_t targetIRcounts = 196608; //0.75 of full scale |
laserdad | 13:5ce84c68066e | 231 | uint32_t targetRcounts = 196608; //0.75 of full scale |
laserdad | 13:5ce84c68066e | 232 | // uint32_t tol1 = 8192; //1 5 bit increment |
laserdad | 16:0a113303c3ed | 233 | uint32_t tol1 = 8192; //1 5 bit increment |
laserdad | 13:5ce84c68066e | 234 | uint32_t tol2 = 39321; //for 90% and 60% large limits |
laserdad | 13:5ce84c68066e | 235 | uint32_t step = 8; |
laserdad | 13:5ce84c68066e | 236 | uint32_t IR_in_range = 0; |
laserdad | 13:5ce84c68066e | 237 | uint32_t R_in_range = 0; |
laserdad | 13:5ce84c68066e | 238 | bool update = 0; |
laserdad | 14:ae0be10b73cd | 239 | uint32_t in_range_persist = 4; |
laserdad | 14:ae0be10b73cd | 240 | uint16_t maxIRcurrent =0x2AF; |
laserdad | 14:ae0be10b73cd | 241 | |
laserdad | 7:3ed0f0522b43 | 242 | for (int n=0;n<ps_running_avg;n++) |
laserdad | 7:3ed0f0522b43 | 243 | { |
laserdad | 7:3ed0f0522b43 | 244 | PS_avg_buffer[n] =0; |
laserdad | 7:3ed0f0522b43 | 245 | } |
laserdad | 7:3ed0f0522b43 | 246 | |
laserdad | 14:ae0be10b73cd | 247 | i2c.frequency( 400000 ); //always use max speed I2C |
laserdad | 0:e9ae48b7f6f6 | 248 | char valid; |
laserdad | 14:ae0be10b73cd | 249 | uint32_t ps_ls_data[7]; //array for storing parsed samples |
laserdad | 14:ae0be10b73cd | 250 | char samples2Read = 6; //FIFO samples, e.g. 4 samples * 3 bytes = 12 bytes (or 2 SpO2 samples) |
laserdad | 2:ee175f471ecb | 251 | char fifoBuffer[samples2Read*3]; |
laserdad | 0:e9ae48b7f6f6 | 252 | uint32_t ppgData[samples2Read]; |
laserdad | 0:e9ae48b7f6f6 | 253 | |
laserdad | 1:fb6b2b4d5d8a | 254 | |
laserdad | 1:fb6b2b4d5d8a | 255 | pc.printf("register settings\r\n"); |
laserdad | 1:fb6b2b4d5d8a | 256 | regDump(OB1203_ADDR,0,19); |
laserdad | 1:fb6b2b4d5d8a | 257 | regDump(OB1203_ADDR,20,39); |
laserdad | 1:fb6b2b4d5d8a | 258 | regDump(OB1203_ADDR,40,59); |
laserdad | 1:fb6b2b4d5d8a | 259 | regDump(OB1203_ADDR,60,77); |
laserdad | 1:fb6b2b4d5d8a | 260 | |
laserdad | 1:fb6b2b4d5d8a | 261 | pc.printf("do initial config\r\n"); |
laserdad | 14:ae0be10b73cd | 262 | defaultConfig(); //do the ASIC configuration now |
laserdad | 1:fb6b2b4d5d8a | 263 | |
laserdad | 1:fb6b2b4d5d8a | 264 | pc.printf("print new register config\r\n"); |
laserdad | 1:fb6b2b4d5d8a | 265 | regDump(OB1203_ADDR,0,19); |
laserdad | 1:fb6b2b4d5d8a | 266 | regDump(OB1203_ADDR,20,39); |
laserdad | 1:fb6b2b4d5d8a | 267 | regDump(OB1203_ADDR,40,59); |
laserdad | 1:fb6b2b4d5d8a | 268 | regDump(OB1203_ADDR,60,77); |
laserdad | 1:fb6b2b4d5d8a | 269 | |
laserdad | 0:e9ae48b7f6f6 | 270 | |
laserdad | 14:ae0be10b73cd | 271 | intb.fall(&intEvent); //attach a falling interrupt |
laserdad | 14:ae0be10b73cd | 272 | t.start(); //start microsecond timer for datalogging |
laserdad | 5:ebe305e08430 | 273 | |
laserdad | 0:e9ae48b7f6f6 | 274 | while(1) |
laserdad | 0:e9ae48b7f6f6 | 275 | { |
laserdad | 14:ae0be10b73cd | 276 | if(mode) //PPG case******************************************************* |
laserdad | 0:e9ae48b7f6f6 | 277 | { |
laserdad | 14:ae0be10b73cd | 278 | if(!intb.read()) //check the intb to see if it is low (or could check variable set by ISR here) |
laserdad | 2:ee175f471ecb | 279 | { |
laserdad | 14:ae0be10b73cd | 280 | if(!afull) //if you are using sample completion interrupts |
laserdad | 4:3aee2ca931b8 | 281 | { |
laserdad | 14:ae0be10b73cd | 282 | numInts++; //increment counter to get data every so many interrupts if ppg new data interrupt mode |
laserdad | 4:3aee2ca931b8 | 283 | } |
laserdad | 4:3aee2ca931b8 | 284 | else |
laserdad | 4:3aee2ca931b8 | 285 | { |
laserdad | 4:3aee2ca931b8 | 286 | numInts = samples2Read; |
laserdad | 4:3aee2ca931b8 | 287 | } |
laserdad | 2:ee175f471ecb | 288 | intFlagged = 1; |
laserdad | 4:3aee2ca931b8 | 289 | if( (numInts < samples2Read) && !afull) |
laserdad | 4:3aee2ca931b8 | 290 | { |
laserdad | 14:ae0be10b73cd | 291 | ob1203.get_status(); //clear interrupt--not time to get data yet |
laserdad | 4:3aee2ca931b8 | 292 | } |
laserdad | 14:ae0be10b73cd | 293 | else if(intFlagged && (numInts==samples2Read) ) //time to get data |
laserdad | 3:d3a1fc19bee6 | 294 | { |
laserdad | 4:3aee2ca931b8 | 295 | numInts = 0; |
laserdad | 4:3aee2ca931b8 | 296 | ob1203.getFifoSamples(samples2Read,fifoBuffer); |
laserdad | 4:3aee2ca931b8 | 297 | // for (int n=0;n<samples2Read*3;n++) |
laserdad | 4:3aee2ca931b8 | 298 | // { |
laserdad | 4:3aee2ca931b8 | 299 | // pc.printf("%02X ",fifoBuffer[n]); |
laserdad | 4:3aee2ca931b8 | 300 | // } |
laserdad | 4:3aee2ca931b8 | 301 | // pc.printf("\r\n"); |
laserdad | 4:3aee2ca931b8 | 302 | ob1203.parseFifoSamples(samples2Read,fifoBuffer,ppgData); |
laserdad | 4:3aee2ca931b8 | 303 | // for (int n=0;n<samples2Read;n++) |
laserdad | 4:3aee2ca931b8 | 304 | // { |
laserdad | 4:3aee2ca931b8 | 305 | // pc.printf("%d ",ppgData[n]); |
laserdad | 4:3aee2ca931b8 | 306 | // } |
laserdad | 4:3aee2ca931b8 | 307 | // pc.printf("\r\n"); |
laserdad | 4:3aee2ca931b8 | 308 | if(first) //populate average and baseline buffers the first time we run |
laserdad | 3:d3a1fc19bee6 | 309 | { |
laserdad | 4:3aee2ca931b8 | 310 | for(int n=0;n<running_avg;n++) |
laserdad | 4:3aee2ca931b8 | 311 | { |
laserdad | 4:3aee2ca931b8 | 312 | IR_avg_buffer[n] = ppgData[0]; |
laserdad | 4:3aee2ca931b8 | 313 | IRavg += IR_avg_buffer[n]; |
laserdad | 4:3aee2ca931b8 | 314 | if(spo2) |
laserdad | 4:3aee2ca931b8 | 315 | { |
laserdad | 4:3aee2ca931b8 | 316 | R_avg_buffer[n] = ppgData[1]; |
laserdad | 4:3aee2ca931b8 | 317 | Ravg += R_avg_buffer[n]; |
laserdad | 4:3aee2ca931b8 | 318 | } |
laserdad | 4:3aee2ca931b8 | 319 | |
laserdad | 4:3aee2ca931b8 | 320 | } |
laserdad | 4:3aee2ca931b8 | 321 | for( int n=0;n<running_baseline;n++) |
laserdad | 4:3aee2ca931b8 | 322 | { |
laserdad | 4:3aee2ca931b8 | 323 | IR_baseline_buffer[n] = 0; |
laserdad | 4:3aee2ca931b8 | 324 | if(spo2) |
laserdad | 4:3aee2ca931b8 | 325 | { |
laserdad | 4:3aee2ca931b8 | 326 | R_baseline_buffer[n] = 0; |
laserdad | 4:3aee2ca931b8 | 327 | } |
laserdad | 4:3aee2ca931b8 | 328 | } |
laserdad | 4:3aee2ca931b8 | 329 | first = 0; |
laserdad | 13:5ce84c68066e | 330 | }//end if first |
laserdad | 13:5ce84c68066e | 331 | |
laserdad | 4:3aee2ca931b8 | 332 | for (int n=0;n<samples2Read/2;n++) |
laserdad | 4:3aee2ca931b8 | 333 | { |
laserdad | 4:3aee2ca931b8 | 334 | ( avg_ptr+1 == running_avg ) ? avg_ptr = 0 : avg_ptr++; |
laserdad | 4:3aee2ca931b8 | 335 | ( baseline_ptr+1 == running_baseline) ? baseline_ptr = 0 : baseline_ptr++; |
laserdad | 4:3aee2ca931b8 | 336 | IRprev = IR_avg_buffer[avg_ptr]; //load the sample you are about to write over |
laserdad | 4:3aee2ca931b8 | 337 | IR_avg_buffer[avg_ptr] = ppgData[2*n]; //load the new sample in the buffer |
laserdad | 4:3aee2ca931b8 | 338 | IRavg += (IR_avg_buffer[avg_ptr] - IRprev); //update the average by removing the old sample and adding the new |
laserdad | 4:3aee2ca931b8 | 339 | |
laserdad | 4:3aee2ca931b8 | 340 | IRbaseline_prev = IR_baseline_buffer[baseline_ptr]; //load the sample you are about to write over |
laserdad | 4:3aee2ca931b8 | 341 | IR_baseline_buffer[baseline_ptr] = ppgData[2*n]; //load the new sample in the buffer |
laserdad | 4:3aee2ca931b8 | 342 | IRbaseline += (IR_baseline_buffer[baseline_ptr] - IRbaseline_prev); //update the average by removing the old sample and adding the new |
laserdad | 4:3aee2ca931b8 | 343 | |
laserdad | 14:ae0be10b73cd | 344 | if(spo2) //print two columsn of data |
laserdad | 3:d3a1fc19bee6 | 345 | { |
laserdad | 4:3aee2ca931b8 | 346 | Rprev = R_avg_buffer[avg_ptr]; |
laserdad | 4:3aee2ca931b8 | 347 | R_avg_buffer[avg_ptr] = ppgData[2*n+1]; |
laserdad | 4:3aee2ca931b8 | 348 | Ravg += (R_avg_buffer[avg_ptr] - Rprev); |
IDTsanjoseuser | 8:21738f9c5835 | 349 | |
laserdad | 4:3aee2ca931b8 | 350 | // pc.printf("%d, %d, %d, %d\r\n",IRavg/running_avg,Ravg/running_avg, IR_avg_buffer[avg_ptr],R_avg_buffer[avg_ptr]); |
laserdad | 4:3aee2ca931b8 | 351 | |
laserdad | 4:3aee2ca931b8 | 352 | Rbaseline_prev = R_baseline_buffer[baseline_ptr]; |
laserdad | 4:3aee2ca931b8 | 353 | R_baseline_buffer[baseline_ptr] = ppgData[2*n+1]; |
laserdad | 4:3aee2ca931b8 | 354 | Rbaseline += (R_baseline_buffer[baseline_ptr] - Rbaseline_prev); |
laserdad | 4:3aee2ca931b8 | 355 | |
laserdad | 13:5ce84c68066e | 356 | if(printAvg) |
laserdad | 13:5ce84c68066e | 357 | { |
IDTsanjoseuser | 8:21738f9c5835 | 358 | //PRINT AVG DATA |
laserdad | 13:5ce84c68066e | 359 | pc.printf("%d,%d,%d\r\n",t.read_us(),IRavg/running_avg,Ravg/running_avg); |
laserdad | 4:3aee2ca931b8 | 360 | // pc.printf("%d,%d\r\n",IRavg/running_avg-IRbaseline/running_baseline, Ravg/running_avg-Rbaseline/running_baseline); |
laserdad | 4:3aee2ca931b8 | 361 | // pc.printf("%d,%d,%d,%d\r\n",Ravg/running_avg,Rbaseline/running_baseline,Rbaseline_prev,Ravg/running_avg-Rbaseline/running_baseline); |
laserdad | 13:5ce84c68066e | 362 | } |
laserdad | 13:5ce84c68066e | 363 | else |
laserdad | 13:5ce84c68066e | 364 | { |
laserdad | 13:5ce84c68066e | 365 | //PRINT RAW DATA |
laserdad | 14:ae0be10b73cd | 366 | if(printCurrent) |
laserdad | 14:ae0be10b73cd | 367 | { |
laserdad | 14:ae0be10b73cd | 368 | pc.printf("%d, %d, %d, %d, %d\r\n",t.read_us(),ppgData[2*n],ppgData[2*n+1],ob1203.ir_current,ob1203.r_current); //print with us counter time stamp (use only with slower data rates or averaging as this slows down the data printing); |
laserdad | 14:ae0be10b73cd | 369 | } |
laserdad | 14:ae0be10b73cd | 370 | else |
laserdad | 14:ae0be10b73cd | 371 | { |
laserdad | 14:ae0be10b73cd | 372 | pc.printf("%d, %d, %d\r\n",t.read_us(),ppgData[2*n],ppgData[2*n+1]); //print with us counter time stamp (use only with slower data rates or averaging as this slows down the data printing); |
laserdad | 13:5ce84c68066e | 373 | // pc.printf("%d, %d\r\n",ppgData[2*n],ppgData[2*n+1]); //print without us timer (faster) |
laserdad | 14:ae0be10b73cd | 374 | } |
laserdad | 13:5ce84c68066e | 375 | } |
laserdad | 13:5ce84c68066e | 376 | }//end SpO2 case |
laserdad | 14:ae0be10b73cd | 377 | else //HR mode print one column of data |
laserdad | 4:3aee2ca931b8 | 378 | { |
laserdad | 4:3aee2ca931b8 | 379 | ( avg_ptr+1 == running_avg ) ? avg_ptr = 0 : avg_ptr++; |
laserdad | 4:3aee2ca931b8 | 380 | ( baseline_ptr+1 == running_baseline) ? baseline_ptr = 0 : baseline_ptr++; |
laserdad | 4:3aee2ca931b8 | 381 | IRprev = IR_avg_buffer[avg_ptr]; |
laserdad | 4:3aee2ca931b8 | 382 | IR_avg_buffer[avg_ptr] = ppgData[2*n+1]; |
laserdad | 4:3aee2ca931b8 | 383 | prevAvg = IRavg; |
laserdad | 4:3aee2ca931b8 | 384 | IRavg += (IR_avg_buffer[avg_ptr] - IRprev); |
laserdad | 4:3aee2ca931b8 | 385 | |
laserdad | 4:3aee2ca931b8 | 386 | IRbaseline_prev = IR_baseline_buffer[baseline_ptr]; //load the sample you are about to write over |
laserdad | 4:3aee2ca931b8 | 387 | IR_baseline_buffer[baseline_ptr] = ppgData[2*n]; //load the new sample in the buffer |
laserdad | 4:3aee2ca931b8 | 388 | prevBaseline = IRbaseline; |
laserdad | 4:3aee2ca931b8 | 389 | IRbaseline += (IR_baseline_buffer[baseline_ptr] - IRbaseline_prev); //update the average by removing the old sample and adding the new |
IDTsanjoseuser | 8:21738f9c5835 | 390 | |
laserdad | 4:3aee2ca931b8 | 391 | |
laserdad | 13:5ce84c68066e | 392 | if(printAvg) |
laserdad | 13:5ce84c68066e | 393 | { |
IDTsanjoseuser | 8:21738f9c5835 | 394 | //PRINT AVG DATA |
laserdad | 13:5ce84c68066e | 395 | pc.printf("%d\r\n%d\r\n",prevAvg/running_avg-prevBaseline/running_baseline,IRavg/running_avg-IRbaseline/running_baseline); |
laserdad | 13:5ce84c68066e | 396 | } |
laserdad | 13:5ce84c68066e | 397 | else |
laserdad | 13:5ce84c68066e | 398 | { |
laserdad | 13:5ce84c68066e | 399 | //PRINT RAW DATA |
laserdad | 13:5ce84c68066e | 400 | pc.printf("%d\r\n%d\r\n",ppgData[2*n],ppgData[2*n+1]); |
laserdad | 13:5ce84c68066e | 401 | // pc.printf("%d, %d, %d\r\n",t.read_us(),ppgData[2*n],ppgData[2*n+1]); //print with us counter time stamp (use only with slower data rates or averaging as this slows down the data printing); |
laserdad | 13:5ce84c68066e | 402 | |
laserdad | 13:5ce84c68066e | 403 | } |
laserdad | 13:5ce84c68066e | 404 | }//HR case |
laserdad | 13:5ce84c68066e | 405 | if(n+1==samples2Read/2) |
laserdad | 13:5ce84c68066e | 406 | { |
laserdad | 13:5ce84c68066e | 407 | if(IRAGC) |
laserdad | 13:5ce84c68066e | 408 | { |
laserdad | 13:5ce84c68066e | 409 | if( ppgData[2*n] > targetIRcounts + (IR_in_range>in_range_persist ? tol2: tol1) ) |
laserdad | 13:5ce84c68066e | 410 | { |
laserdad | 13:5ce84c68066e | 411 | if(ppgData[2*n]>targetIRcounts + tol2) |
laserdad | 13:5ce84c68066e | 412 | IR_in_range=0; |
laserdad | 13:5ce84c68066e | 413 | if(ob1203.ir_current>step) |
laserdad | 13:5ce84c68066e | 414 | { |
laserdad | 14:ae0be10b73cd | 415 | // pc.printf("IR %d, IRc %d--, IR_in_range %d\r\n",ppgData[2*n],ob1203.ir_current,IR_in_range); |
laserdad | 13:5ce84c68066e | 416 | ob1203.ir_current -= step; |
laserdad | 13:5ce84c68066e | 417 | update = 1; |
laserdad | 13:5ce84c68066e | 418 | |
laserdad | 13:5ce84c68066e | 419 | } |
laserdad | 13:5ce84c68066e | 420 | } |
laserdad | 13:5ce84c68066e | 421 | else if( ppgData[2*n] < targetIRcounts - (IR_in_range>in_range_persist ? tol2 : tol1) ) |
laserdad | 13:5ce84c68066e | 422 | { |
laserdad | 13:5ce84c68066e | 423 | if(ppgData[2*n]<targetIRcounts - tol2) |
laserdad | 13:5ce84c68066e | 424 | IR_in_range=0; |
laserdad | 14:ae0be10b73cd | 425 | if(ob1203.ir_current+step<maxIRcurrent) //no need to go to full current |
laserdad | 13:5ce84c68066e | 426 | { |
laserdad | 13:5ce84c68066e | 427 | ob1203.ir_current += step; |
laserdad | 13:5ce84c68066e | 428 | update = 1; |
laserdad | 14:ae0be10b73cd | 429 | // pc.printf("IR %d, IRc %d++, IR_in range %d\r\n", ppgData[2*n],ob1203.ir_current,IR_in_range); |
laserdad | 13:5ce84c68066e | 430 | } |
laserdad | 13:5ce84c68066e | 431 | } |
laserdad | 13:5ce84c68066e | 432 | else |
laserdad | 13:5ce84c68066e | 433 | { |
laserdad | 14:ae0be10b73cd | 434 | if( (ppgData[2*n] > (targetRcounts-tol1) ) && (ppgData[2*n] < (targetRcounts+tol1)) ) |
laserdad | 14:ae0be10b73cd | 435 | IR_in_range++; |
laserdad | 13:5ce84c68066e | 436 | } |
laserdad | 13:5ce84c68066e | 437 | }//end IR AGC case |
laserdad | 13:5ce84c68066e | 438 | |
laserdad | 13:5ce84c68066e | 439 | if(spo2 && redAGC) |
laserdad | 13:5ce84c68066e | 440 | { |
laserdad | 13:5ce84c68066e | 441 | if( ppgData[2*n+1] > targetRcounts + (R_in_range>in_range_persist ? tol2 : tol1) ) |
laserdad | 13:5ce84c68066e | 442 | { |
laserdad | 13:5ce84c68066e | 443 | if(ppgData[2*n+1]>targetRcounts + tol2) |
laserdad | 13:5ce84c68066e | 444 | R_in_range=0; |
laserdad | 13:5ce84c68066e | 445 | if(ob1203.r_current>step) |
laserdad | 13:5ce84c68066e | 446 | { |
laserdad | 14:ae0be10b73cd | 447 | // pc.printf("R %d, Rc %d--,R_in_range %d\r\n", ppgData[2*n+1],ob1203.r_current,R_in_range); |
laserdad | 13:5ce84c68066e | 448 | ob1203.r_current -= step; |
laserdad | 13:5ce84c68066e | 449 | update = 1; |
laserdad | 13:5ce84c68066e | 450 | } |
laserdad | 13:5ce84c68066e | 451 | } |
laserdad | 13:5ce84c68066e | 452 | else if( ppgData[2*n+1] < targetRcounts - (R_in_range>in_range_persist ? tol2 : tol1) ) |
laserdad | 13:5ce84c68066e | 453 | { |
laserdad | 13:5ce84c68066e | 454 | if(ppgData[2*n+1]<targetRcounts - tol2) |
laserdad | 13:5ce84c68066e | 455 | R_in_range=0; |
laserdad | 13:5ce84c68066e | 456 | if(ob1203.r_current+step<0x1FF) |
laserdad | 13:5ce84c68066e | 457 | { |
laserdad | 13:5ce84c68066e | 458 | |
laserdad | 14:ae0be10b73cd | 459 | // pc.printf("R %d, Rc %d++,R_in_range %d\r\n", ppgData[2*n+1],ob1203.r_current,R_in_range); |
laserdad | 13:5ce84c68066e | 460 | ob1203.r_current += step; |
laserdad | 13:5ce84c68066e | 461 | update = 1; |
laserdad | 13:5ce84c68066e | 462 | } |
laserdad | 13:5ce84c68066e | 463 | } |
laserdad | 13:5ce84c68066e | 464 | else |
laserdad | 13:5ce84c68066e | 465 | { |
laserdad | 14:ae0be10b73cd | 466 | if( (ppgData[2*n+1] > (targetRcounts-tol1) ) && (ppgData[2*n+1] < (targetRcounts+tol1)) ) |
laserdad | 14:ae0be10b73cd | 467 | R_in_range++; |
laserdad | 13:5ce84c68066e | 468 | } |
laserdad | 13:5ce84c68066e | 469 | if(update) |
laserdad | 13:5ce84c68066e | 470 | { |
laserdad | 13:5ce84c68066e | 471 | ob1203.setPPGcurrent(); |
laserdad | 13:5ce84c68066e | 472 | ob1203.resetFIFO(); |
laserdad | 13:5ce84c68066e | 473 | update=0; |
laserdad | 13:5ce84c68066e | 474 | } |
laserdad | 14:ae0be10b73cd | 475 | }//end R AGC case |
laserdad | 4:3aee2ca931b8 | 476 | } |
laserdad | 13:5ce84c68066e | 477 | }//end sample loop |
laserdad | 13:5ce84c68066e | 478 | |
laserdad | 13:5ce84c68066e | 479 | |
laserdad | 13:5ce84c68066e | 480 | |
laserdad | 13:5ce84c68066e | 481 | intFlagged = 0; |
laserdad | 13:5ce84c68066e | 482 | |
laserdad | 13:5ce84c68066e | 483 | }//end if time to read samples |
laserdad | 4:3aee2ca931b8 | 484 | } //end if !intb |
laserdad | 14:ae0be10b73cd | 485 | }// end mode (PPG case) |
laserdad | 14:ae0be10b73cd | 486 | //********************************************************************* |
laserdad | 14:ae0be10b73cd | 487 | else //LS and PS measurement case |
laserdad | 0:e9ae48b7f6f6 | 488 | { |
laserdad | 1:fb6b2b4d5d8a | 489 | wait_ms(sample_delay); |
laserdad | 16:0a113303c3ed | 490 | |
laserdad | 16:0a113303c3ed | 491 | if( meas_ps ? ob1203.psIsNew() : ob1203.lsIsNew() ) |
laserdad | 1:fb6b2b4d5d8a | 492 | { |
laserdad | 5:ebe305e08430 | 493 | meas_ps ? valid = ob1203.get_ps_ls_data(ps_ls_data) : valid = ob1203.get_ls_data(ps_ls_data); |
laserdad | 7:3ed0f0522b43 | 494 | if(meas_ps) |
laserdad | 7:3ed0f0522b43 | 495 | { |
laserdad | 7:3ed0f0522b43 | 496 | ( ps_avg_ptr+1 == ps_running_avg ) ? ps_avg_ptr = 0 : ps_avg_ptr++; |
laserdad | 7:3ed0f0522b43 | 497 | PSprev = PS_avg_buffer[ps_avg_ptr]; //load the sample you are about to write over |
laserdad | 7:3ed0f0522b43 | 498 | PS_avg_buffer[ps_avg_ptr] = ps_ls_data[0]; //load the new sample in the buffer |
laserdad | 7:3ed0f0522b43 | 499 | PSavg += (PS_avg_buffer[ps_avg_ptr] - PSprev); //update the average by removing the old sample and adding the new |
laserdad | 7:3ed0f0522b43 | 500 | // pc.printf("%d %d %d %d %d ",ps_avg_ptr, PSprev, PS_avg_buffer[ps_avg_ptr],ps_ls_data[0],PSavg); |
laserdad | 7:3ed0f0522b43 | 501 | } |
laserdad | 5:ebe305e08430 | 502 | if (meas_temp) |
laserdad | 5:ebe305e08430 | 503 | { |
laserdad | 5:ebe305e08430 | 504 | ob1203.setMainConfig(); |
laserdad | 5:ebe305e08430 | 505 | } |
laserdad | 12:5de5f550e765 | 506 | pc.printf("%d, %d %d %d %d %d\r\n",ps_ls_data[0],ps_ls_data[1],ps_ls_data[2],ps_ls_data[3],ps_ls_data[4],ps_ls_data[5]); |
laserdad | 12:5de5f550e765 | 507 | // pc.printf("%d, %d %d %d %d %d %d %d\r\n",(PSavg/ps_running_avg),ps_ls_data[0],ps_ls_data[1],ps_ls_data[2],ps_ls_data[3],ps_ls_data[4],ps_ls_data[5],ps_ls_data[6]); |
laserdad | 4:3aee2ca931b8 | 508 | |
laserdad | 1:fb6b2b4d5d8a | 509 | } |
laserdad | 2:ee175f471ecb | 510 | // else |
laserdad | 2:ee175f471ecb | 511 | // { |
laserdad | 2:ee175f471ecb | 512 | // pc.printf("status = %04X\r\n",ob1203.get_status() ); |
laserdad | 2:ee175f471ecb | 513 | // } |
laserdad | 0:e9ae48b7f6f6 | 514 | } |
laserdad | 1:fb6b2b4d5d8a | 515 | }//end while |
laserdad | 1:fb6b2b4d5d8a | 516 | }//end main |