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