Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: redefinition of 'class MAX30105' #38

Open
kamilah2520 opened this issue Oct 28, 2021 · 0 comments
Open

error: redefinition of 'class MAX30105' #38

kamilah2520 opened this issue Oct 28, 2021 · 0 comments

Comments

@kamilah2520
Copy link

kamilah2520 commented Oct 28, 2021

When I compile the code for my MAX30102, with its .cpp and .h files, I get the following error:

In file included from C:\Users\USUARIO\Documents\Arduino\hr-spo2-max30102\hr-spo2-max30102.ino:6:0: MAX30105.h:52:7: error: redefinition of 'class MAX30105' class MAX30105 { ^~~~~~~~ In file included from C:\Users\USUARIO\Documents\Arduino\hr-spo2-max30102\hr-spo2-max30102.ino:2:0: C:\Users\USUARIO\Documents\Arduino\libraries\SparkFun_MAX3010x_Pulse_and_Proximity_Sensor_Library\src/MAX30105.h:46:7: note: previous definition of 'class MAX30105' class MAX30105 { ^~~~~~~~ exit status 1 redefinition of 'class MAX30105'

These are the header files...
MAX30105.h
`
#pragma once

#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

#include <Wire.h>

#define MAX30105_ADDRESS 0x57 //7-bit I2C Address
//Note that MAX30102 has the same I2C address and Part ID

#define I2C_SPEED_STANDARD 100000
#define I2C_SPEED_FAST 400000

//Define the size of the I2C buffer based on the platform the user has
#if defined(AVR_ATmega328P) || defined(AVR_ATmega168)

//I2C_BUFFER_LENGTH is defined in Wire.H
#define I2C_BUFFER_LENGTH BUFFER_LENGTH

#elif defined(SAMD21G18A)

//SAMD21 uses RingBuffer.h
#define I2C_BUFFER_LENGTH SERIAL_BUFFER_SIZE

#else

//The catch-all default is 32
#define I2C_BUFFER_LENGTH 32

#endif

#ifndef MAX30105_H
#define MAX30105_H

#include "Arduino.h"
class MAX30105 {

public:
MAX30105(void);

boolean begin(TwoWire &wirePort = Wire, uint32_t i2cSpeed = I2C_SPEED_STANDARD, uint8_t i2caddr = MAX30105_ADDRESS);

uint32_t getRed(void); //Returns immediate red value
uint32_t getIR(void); //Returns immediate IR value
uint32_t getGreen(void); //Returns immediate green value
bool safeCheck(uint8_t maxTimeToCheck); //Given a max amount of time, check for new data

// Configuration
void softReset();
void shutDown();
void wakeUp();

void setLEDMode(uint8_t mode);

void setADCRange(uint8_t adcRange);
void setSampleRate(uint8_t sampleRate);
void setPulseWidth(uint8_t pulseWidth);

void setPulseAmplitudeRed(uint8_t value);
void setPulseAmplitudeIR(uint8_t value);
void setPulseAmplitudeGreen(uint8_t value);
void setPulseAmplitudeProximity(uint8_t value);

void setProximityThreshold(uint8_t threshMSB);

//Multi-led configuration mode (page 22)
void enableSlot(uint8_t slotNumber, uint8_t device); //Given slot number, assign a device to slot
void disableSlots(void);

// Data Collection

//Interrupts (page 13, 14)
uint8_t getINT1(void); //Returns the main interrupt group
uint8_t getINT2(void); //Returns the temp ready interrupt
void enableAFULL(void); //Enable/disable individual interrupts
void disableAFULL(void);
void enableDATARDY(void);
void disableDATARDY(void);
void enableALCOVF(void);
void disableALCOVF(void);
void enablePROXINT(void);
void disablePROXINT(void);
void enableDIETEMPRDY(void);
void disableDIETEMPRDY(void);

//FIFO Configuration (page 18)
void setFIFOAverage(uint8_t samples);
void enableFIFORollover();
void disableFIFORollover();
void setFIFOAlmostFull(uint8_t samples);

//FIFO Reading
uint16_t check(void); //Checks for new data and fills FIFO
uint8_t available(void); //Tells caller how many new samples are available (head - tail)
void nextSample(void); //Advances the tail of the sense array
uint32_t getFIFORed(void); //Returns the FIFO sample pointed to by tail
uint32_t getFIFOIR(void); //Returns the FIFO sample pointed to by tail
uint32_t getFIFOGreen(void); //Returns the FIFO sample pointed to by tail

uint8_t getWritePointer(void);
uint8_t getReadPointer(void);
void clearFIFO(void); //Sets the read/write pointers to zero

//Proximity Mode Interrupt Threshold
void setPROXINTTHRESH(uint8_t val);

// Die Temperature
float readTemperature();
float readTemperatureF();

// Detecting ID/Revision
uint8_t getRevisionID();
uint8_t readPartID();

// Setup the IC with user selectable settings
void setup(byte powerLevel = 0x1F, byte sampleAverage = 4, byte ledMode = 3, int sampleRate = 400, int pulseWidth = 411, int adcRange = 4096);

// Low-level I2C communication
uint8_t readRegister8(uint8_t address, uint8_t reg);
void writeRegister8(uint8_t address, uint8_t reg, uint8_t value);

private:
TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware
uint8_t _i2caddr;

//activeLEDs is the number of channels turned on, and can be 1 to 3. 2 is common for Red+IR.
byte activeLEDs; //Gets set during setup. Allows check() to calculate how many bytes to read from FIFO

uint8_t revisionID;

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;

};

#endif`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant