Demo program for the MAX30101WING that calculates heart rate and SpO2 data.
Dependencies: MAX30101 max32630fthr
Fork of MAX30101_HR_SPO2 by
Diff: main.cpp
- Revision:
- 13:ef4a84158e4c
- Parent:
- 12:ac85295f8713
--- a/main.cpp Tue Mar 06 03:00:25 2018 +0000 +++ b/main.cpp Thu Mar 08 16:29:29 2018 +0000 @@ -135,30 +135,17 @@ if(rc == 0) { // Convert read bytes into samples - for(idx = 0, c=0; idx < readBytes; idx+=3) { - - sample = (fifoData[idx]<<16) | (fifoData[idx+1]<<8) | (fifoData[idx+2]); - opSample = sample; - opSample&=0x03FFFF; //Mask MSB [23:18] - - if(idx==0) { - - redData[r] = opSample;//saves to buff for calculations - r++; + for (idx = 0; idx < readBytes; idx+=9) { + if (r >= 500 || ir >= 500 || g >= 500) { + pc.printf("Overflow!"); + } + redData[r++] = ((fifoData[idx] << 16) | (fifoData[idx + 1] << 8) | (fifoData[idx + 2])) & 0x03FFFF; - } else if(idx==3) { - - irData[ir] = opSample; //saves to buff for calculations - ir++; - - } else { + irData[ir++] = ((fifoData[idx + 3] << 16) | (fifoData[idx + 4] << 8) | (fifoData[idx + 5])) & 0x03FFFF; - greenData[g] = opSample; //saves to buff for calculations - g++; + greenData[g++] = ((fifoData[idx + 6] << 16) | (fifoData[idx + 7] << 8) | (fifoData[idx + 8])) & 0x03FFFF; + } - } - - } if(r>=500 && ir>=500 && g>500)//checks to make sure there are 500