Skip to content

Commit d7c9cf2

Browse files
committed
Error and Warning fix
1 parent 8d30bef commit d7c9cf2

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

src/SparkFun_Bio_Sensor_Hub_Library.cpp

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -353,44 +353,44 @@ bioData SparkFun_Bio_Sensor_Hub::readSensorBpm(){
353353
MAXFAST_ARRAY_SIZE + MAX30101_LED_ARRAY + MAXFAST_EXTENDED_DATA, bpmSenArrTwo);
354354

355355
// Value of LED one....
356-
libLedBpm.irLed = uint32_t(bpmSenArr[0]) << 16;
357-
libLedBpm.irLed |= uint32_t(bpmSenArr[1]) << 8;
358-
libLedBpm.irLed |= bpmSenArr[2];
356+
libLedBpm.irLed = uint32_t(bpmSenArrTwo[0]) << 16;
357+
libLedBpm.irLed |= uint32_t(bpmSenArrTwo[1]) << 8;
358+
libLedBpm.irLed |= bpmSenArrTwo[2];
359359

360360
// Value of LED two...
361-
libLedBpm.redLed = uint32_t(bpmSenArr[3]) << 16;
362-
libLedBpm.redLed |= uint32_t(bpmSenArr[4]) << 8;
363-
libLedBpm.redLed |= bpmSenArr[5];
361+
libLedBpm.redLed = uint32_t(bpmSenArrTwo[3]) << 16;
362+
libLedBpm.redLed |= uint32_t(bpmSenArrTwo[4]) << 8;
363+
libLedBpm.redLed |= bpmSenArrTwo[5];
364364

365365
// -- What happened here? -- There are two uint32_t values that are given by
366366
// the sensor for LEDs that do not exists on the MAX30101. So we have to
367367
// request those empty values because they occupy the buffer:
368-
// bpmSenArr[6-11].
368+
// bpmSenArrTwo[6-11].
369369

370370
// Heart rate formatting
371-
libLedBpm.heartRate = (uint16_t(bpmSenArr[12]) << 8);
372-
libLedBpm.heartRate |= (bpmSenArr[13]);
371+
libLedBpm.heartRate = (uint16_t(bpmSenArrTwo[12]) << 8);
372+
libLedBpm.heartRate |= (bpmSenArrTwo[13]);
373373
libLedBpm.heartRate /= 10;
374374

375375
// Confidence formatting
376-
libLedBpm.confidence = bpmSenArr[14];
376+
libLedBpm.confidence = bpmSenArrTwo[14];
377377

378378
//Blood oxygen level formatting
379-
libLedBpm.oxygen = uint16_t(bpmSenArr[15]) << 8;
380-
libLedBpm.oxygen |= bpmSenArr[16];
379+
libLedBpm.oxygen = uint16_t(bpmSenArrTwo[15]) << 8;
380+
libLedBpm.oxygen |= bpmSenArrTwo[16];
381381
libLedBpm.oxygen /= 10;
382382

383383
//"Machine State" - has a finger been detected?
384-
libLedBpm.status = bpmSenArr[17];
384+
libLedBpm.status = bpmSenArrTwo[17];
385385

386386
//Sp02 r Value formatting
387-
uint16_t tempVal = uint16_t(bpmArrTwo[6]) << 8;
388-
tempVal |= bpmArrTwo[7];
387+
uint16_t tempVal = uint16_t(bpmSenArrTwo[18]) << 8;
388+
tempVal |= bpmSenArrTwo[19];
389389
libLedBpm.rValue = tempVal;
390-
libLedBpm.rValue /= 10;
390+
libLedBpm.rValue /= 10.0;
391391

392392
//Extended Machine State formatting
393-
libLedBpm.extStatus = bpmArrTwo[20];
393+
libLedBpm.extStatus = bpmSenArrTwo[20];
394394

395395
// There are two additional bytes of data that were requested but that
396396
// have not been implemented in firmware 10.1 so will not be saved to
@@ -427,7 +427,6 @@ bioData SparkFun_Bio_Sensor_Hub::readSensorBpm(){
427427
uint8_t SparkFun_Bio_Sensor_Hub::setPulseWidth(uint16_t width){
428428

429429
uint8_t bits;
430-
uint8_t statusByte;
431430
uint8_t regVal;
432431

433432
// Make sure the correct pulse width is selected.
@@ -476,7 +475,6 @@ uint16_t SparkFun_Bio_Sensor_Hub::readPulseWidth(){
476475
uint8_t SparkFun_Bio_Sensor_Hub::setSampleRate(uint16_t sampRate){
477476

478477
uint8_t bits;
479-
uint8_t statusByte;
480478
uint8_t regVal;
481479

482480
// Make sure the correct sample rate was picked
@@ -532,7 +530,6 @@ uint16_t SparkFun_Bio_Sensor_Hub::readSampleRate(){
532530
// 62.5pA - 16384nA
533531
uint8_t SparkFun_Bio_Sensor_Hub::setAdcRange(uint16_t adcVal){
534532

535-
uint8_t statusByte;
536533
uint8_t regVal;
537534
uint8_t bits;
538535

@@ -544,7 +541,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAdcRange(uint16_t adcVal){
544541

545542
regVal = readRegisterMAX30101(CONFIGURATION_REGISTER);
546543
regVal &= ADC_MASK;
547-
regVal |= (adcVal << 5);
544+
regVal |= bits << 5;
548545

549546
writeRegisterMAX30101(CONFIGURATION_REGISTER, regVal);
550547

@@ -611,7 +608,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::getMcuType() {
611608
int32_t SparkFun_Bio_Sensor_Hub::getBootloaderInf() {
612609

613610
int32_t bootVers = 0;
614-
int32_t* revNum;
611+
int32_t revNum[4] = {0};
615612
readMultipleBytes(BOOTLOADER_INFO, BOOTLOADER_VERS, 0x00, 4, revNum);
616613

617614
if( revNum[1] != SUCCESS )
@@ -675,7 +672,8 @@ uint8_t SparkFun_Bio_Sensor_Hub::accelControl(uint8_t accelSwitch) {
675672
// Write Byte : outputType (Parameter values in OUTPUT_MODE_WRITE_BYTE)
676673
uint8_t SparkFun_Bio_Sensor_Hub::setOutputMode(uint8_t outputType) {
677674

678-
if (outputType < PAUSE || outputType > SENSOR_ALGO_COUNTER) // Bytes between 0x00 and 0x07
675+
// if (outputType < PAUSE || outputType > SENSOR_ALGO_COUNTER) // Bytes between 0x00 and 0x07
676+
if ( outputType > SENSOR_ALGO_COUNTER ) // Bytes between 0x00 and 0x07
679677
return INCORR_PARAM;
680678

681679
// Check that communication was successful, not that the IC is outputting
@@ -695,8 +693,8 @@ uint8_t SparkFun_Bio_Sensor_Hub::setOutputMode(uint8_t outputType) {
695693
// (begin).
696694
uint8_t SparkFun_Bio_Sensor_Hub::setFifoThreshold(uint8_t intThresh) {
697695

698-
if( intThresh < 0 || intThresh > 255)
699-
return INCORR_PARAM;
696+
// if(( intThresh < 0 )||( intThresh > 255 ))
697+
// return INCORR_PARAM;
700698

701699
// Checks that there was succesful communcation, not that the threshold was
702700
// set correctly.
@@ -851,7 +849,8 @@ uint8_t* SparkFun_Bio_Sensor_Hub::dumpRegisterAccelerometer(uint8_t numReg, uint
851849
// 100 percent.
852850
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoRange(uint8_t perc) {
853851

854-
if( perc < 0 || perc > 100)
852+
// if( perc < 0 || perc > 100)
853+
if( perc > 100)
855854
return INCORR_PARAM;
856855

857856
// Successful communication or no?
@@ -869,7 +868,8 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoRange(uint8_t perc) {
869868
// It takes a paramater of zero to 100 percent.
870869
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoStepSize(uint8_t step) {
871870

872-
if( step < 0 || step > 100)
871+
// if( step < 0 || step > 100)
872+
if( step > 100 )
873873
return INCORR_PARAM;
874874

875875
// Successful communication or no?
@@ -886,7 +886,8 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoStepSize(uint8_t step) {
886886
// This function changes the sensitivity of the AGC algorithm.
887887
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSensitivity(uint8_t sense) {
888888

889-
if( sense < 0 || sense > 100 )
889+
// if( sense < 0 || sense > 100 )
890+
if( sense > 100 )
890891
return INCORR_PARAM;
891892

892893
// Successful communication or no?
@@ -904,8 +905,8 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSensitivity(uint8_t sense) {
904905
// It takes a paramater of zero to 255.
905906
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSamples(uint8_t avg) {
906907

907-
if( avg < 0 || avg > 255 )
908-
return INCORR_PARAM;
908+
// if( avg < 0 || avg > 255 )
909+
// return INCORR_PARAM;
909910

910911
// Successful communication or no?
911912
uint8_t statusByte = writeByte(CHANGE_ALGORITHM_CONFIG, SET_AVG_SAMPLES, AGC_SENSITIVITY_ID, avg);
@@ -1391,7 +1392,7 @@ uint32_t SparkFun_Bio_Sensor_Hub::readLongByte(uint8_t _familyByte, uint8_t _ind
13911392
uint8_t _writeByte)
13921393
{
13931394

1394-
uint32_t returnByte;
1395+
uint32_t returnByte = 0;
13951396
uint8_t statusByte;
13961397

13971398
_i2cPort->beginTransmission(_address);
@@ -1404,7 +1405,7 @@ uint32_t SparkFun_Bio_Sensor_Hub::readLongByte(uint8_t _familyByte, uint8_t _ind
14041405
_i2cPort->requestFrom(_address, (sizeof(returnByte) * 3) + sizeof(statusByte) );
14051406
statusByte = _i2cPort->read();
14061407
if( statusByte ) // Pass through if SUCCESS (0x00).
1407-
return statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
1408+
return (uint32_t)statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
14081409

14091410
for(uint8_t i = 0; i < (sizeof(returnByte) * 3); i++){ // Reading three long bytes
14101411
returnByte |= (_i2cPort->read() << 24);

0 commit comments

Comments
 (0)