Skip to content

Commit

Permalink
Sensor values mix up when using multiple sensors
Browse files Browse the repository at this point in the history
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:
  • Loading branch information
beegee-tokyo authored Dec 17, 2018
1 parent e8a0b3e commit 92597b3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/MAX30105.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,17 @@ class MAX30105 {
void readRevisionID();

void bitMask(uint8_t reg, uint8_t mask, uint8_t thing);

#define STORAGE_SIZE 4 //Each long is 4 bytes so limit this to fit on your micro
typedef struct Record
{
uint32_t red[STORAGE_SIZE];
uint32_t IR[STORAGE_SIZE];
uint32_t green[STORAGE_SIZE];
byte head;
byte tail;
} sense_struct; //This is our circular buffer of readings from the sensor

sense_struct sense;

};

0 comments on commit 92597b3

Please sign in to comment.