Hi guys, I am writing down a library that helps who want to build cheap distance sensors.
We use the IR LED capacitance to determine the distance of the object, with two readings: ambient light check and ir light emission check
I try to write down a library to help people to use free this system but I get some errors:
ERER.cpp:64: error: no ‘void ERER::init(int)’ member function declared in class ‘ERER’
/*
ERER.cpp - Library for ERER sensors.
(use 2 infrared LEDs to build a distance sensor)
Created by Giovanni Blu Mitolo, March 11, 2011.
Released with Creative Commons Attribution licence
*/
#ifndef ERER_h
#define ERER_h
class ERER {
public:
long ambient;
void ambientCheck();
long currentInit;
long distance;
void distanceCheck();
void emissionCheck();
void gain(int setGain)
void init(int emitter);
long lightTime;
void maxRangeValue(int setMaxRangeValue);
void maxRange(int setMaxRange);
long rawData;
void emitterN(int emitterNegative);
void receiverN(int receiverNegative);
void receiverP(int receiverPositive);
private:
int _irEmitterP;
int _irReceiverP;
int _irReceiverN;
int _gain;
long _maxRange;
long _maxRangeValue;
};
#endif
You are using the scope resolution operator on your call to init(), in ambientCheck(), but init() is not declared a static function, so this call won't work.
The ambientCheck function will be called for an instance of the class. That same instance should be used to invoke the init() function, shouldn't it?
I don't think that you want init() to be static. As defined, it is accessing non-static fields. I think you should just drop the ERER:: from in front of the ERER::init() call.
I edit the code following your advise.
This is the actual code:
ERER.h
/*
ERER.cpp - Library for ERER sensors.
(use 2 infrared LEDs to build a distance sensor)
Created by Giovanni Blu Mitolo, March 11, 2011.
Released with Creative Commons Attribution licence
*/
#ifndef ERER_h
#define ERER_h
class ERER {
public:
long ambient;
void ambientCheck();
long currentInit;
long distance;
void distanceCheck();
void emissionCheck();
void gain(int setGain)
void init(int emitter);
long lightTime;
void maxRangeValue(int setMaxRangeValue);
void maxRange(int setMaxRange);
long rawData;
void emitterN(int emitterNegative);
void receiverN(int receiverNegative);
void receiverP(int receiverPositive);
private:
int _irEmitterP;
int _irReceiverP;
int _irReceiverN;
int _gain;
long _maxRange;
long _maxRangeValue;
};
#endif