Skip to content

Commit f0a8571

Browse files
author
Nathan Seidle
committed
Capitalized Arduino.h. Fix issue 2 on breakout. Remove unused vars. Removed dup defines.
1 parent 4e73ffd commit f0a8571

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/MAX30105.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -740,17 +740,15 @@ uint8_t MAX30105::readRegister8(uint8_t address, uint8_t reg) {
740740
_i2cPort->beginTransmission(address);
741741
_i2cPort->write(reg);
742742
_i2cPort->endTransmission(false);
743-
_i2cPort->requestFrom(address, 1); // Request 1 byte
744743

745-
int tries = 0;
746-
while (!_i2cPort->available())
744+
_i2cPort->requestFrom((uint8_t)address, (uint8_t)1); // Request 1 byte
745+
if (_i2cPort->available())
747746
{
748-
delay(1);
749-
if (tries++ > 200) break;
747+
return(_i2cPort->read());
750748
}
751-
if (tries == 200) return (0); //Fail
752749

753-
return (_i2cPort->read());
750+
return (0); //Fail
751+
754752
}
755753

756754
void MAX30105::writeRegister8(uint8_t address, uint8_t reg, uint8_t value) {

src/spo2_algorithm.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
*******************************************************************************
5858
*/
5959

60-
#include "arduino.h"
60+
#include "Arduino.h"
6161
#include "spo2_algorithm.h"
6262

6363
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
@@ -67,7 +67,7 @@ void maxim_heart_rate_and_oxygen_saturation(uint16_t *pun_ir_buffer, int32_t n_i
6767
int32_t *pn_heart_rate, int8_t *pch_hr_valid)
6868
#else
6969
void maxim_heart_rate_and_oxygen_saturation(uint32_t *pun_ir_buffer, int32_t n_ir_buffer_length, uint32_t *pun_red_buffer, int32_t *pn_spo2, int8_t *pch_spo2_valid,
70-
int32_t *pn_heart_rate, int8_t *pch_hr_valid)
70+
//int32_t *pn_heart_rate, int8_t *pch_hr_valid)
7171
#endif
7272
/**
7373
* \brief Calculate the heart rate and SpO2 level
@@ -87,17 +87,18 @@ void maxim_heart_rate_and_oxygen_saturation(uint32_t *pun_ir_buffer, int32_t n_i
8787
* \retval None
8888
*/
8989
{
90-
uint32_t un_ir_mean,un_only_once ;
90+
uint32_t un_ir_mean;
9191
int32_t k, n_i_ratio_count;
92-
int32_t i, s, m, n_exact_ir_valley_locs_count, n_middle_idx;
93-
int32_t n_th1, n_npks, n_c_min;
92+
int32_t i, n_exact_ir_valley_locs_count, n_middle_idx;
93+
int32_t n_th1, n_npks;
9494
int32_t an_ir_valley_locs[15] ;
9595
int32_t n_peak_interval_sum;
9696

9797
int32_t n_y_ac, n_x_ac;
9898
int32_t n_spo2_calc;
9999
int32_t n_y_dc_max, n_x_dc_max;
100-
int32_t n_y_dc_max_idx, n_x_dc_max_idx;
100+
int32_t n_y_dc_max_idx = 0;
101+
int32_t n_x_dc_max_idx = 0;
101102
int32_t an_ratio[5], n_ratio_average;
102103
int32_t n_nume, n_denom ;
103104

src/spo2_algorithm.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@
6262
#ifndef SPO2_ALGORITHM_H_
6363
#define SPO2_ALGORITHM_H_
6464

65-
#include <arduino.h>
65+
#include <Arduino.h>
6666

6767
#define FS 25 //sampling frequency
6868
#define BUFFER_SIZE (FS * 4)
6969
#define MA4_SIZE 4 // DONOT CHANGE
70-
#define min(x,y) ((x) < (y) ? (x) : (y))
70+
//#define min(x,y) ((x) < (y) ? (x) : (y)) //Defined in Arduino.h
7171

7272
//uch_spo2_table is approximated as -45.060*ratioAverage* ratioAverage + 30.354 *ratioAverage + 94.845 ;
7373
const uint8_t uch_spo2_table[184]={ 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99,

0 commit comments

Comments
 (0)