Skip to content

Commit 92597b3

Browse files
authored
Sensor values mix up when using multiple sensors
When using 2 (or more) sensors on the same device the sensor values read from the sensors can get mixed up. The struct sense is defined as a global and is reused from multiple instances of the MAX30105 class. Solution: Declare sense as class private:
1 parent e8a0b3e commit 92597b3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/MAX30105.h

+13
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,17 @@ class MAX30105 {
140140
void readRevisionID();
141141

142142
void bitMask(uint8_t reg, uint8_t mask, uint8_t thing);
143+
144+
#define STORAGE_SIZE 4 //Each long is 4 bytes so limit this to fit on your micro
145+
typedef struct Record
146+
{
147+
uint32_t red[STORAGE_SIZE];
148+
uint32_t IR[STORAGE_SIZE];
149+
uint32_t green[STORAGE_SIZE];
150+
byte head;
151+
byte tail;
152+
} sense_struct; //This is our circular buffer of readings from the sensor
153+
154+
sense_struct sense;
155+
143156
};

0 commit comments

Comments
 (0)