43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
#ifndef ADC_H
|
|
#define ADC_H
|
|
#include "AdcSetting.h"
|
|
|
|
class Adc
|
|
{
|
|
public:
|
|
virtual ~Adc() = 0;
|
|
|
|
virtual void begin() = 0;
|
|
virtual double getQuantum();
|
|
virtual double sampleValue(int16_t channel, boolean sgl = true) = 0;
|
|
virtual double sampleValue() = 0;
|
|
virtual double sampleVoltage(int16_t channel, boolean sgl = true) = 0;
|
|
virtual double sampleVoltage() = 0;
|
|
|
|
//Async methods
|
|
enum STATE {STARTED = 0, RESULT_READY, IDLING, SAMPLING};
|
|
virtual void startSample(int16_t channel, boolean sgl = true) = 0;
|
|
virtual void startSample() = 0;
|
|
virtual double getSampleVoltage() = 0;
|
|
|
|
boolean isSampleReady();
|
|
double getSampleValue();
|
|
//End of async methods
|
|
|
|
void setAdcSetting(AdcSetting adcSetting);
|
|
AdcSetting getAdcSetting();
|
|
protected:
|
|
Adc();
|
|
|
|
int16_t _lastChannel;
|
|
AdcSetting _adcSetting;
|
|
//Async part
|
|
STATE _state;
|
|
double _sampledValue;
|
|
uint8_t _numOfSamples;
|
|
unsigned long _elapsedTime;
|
|
private:
|
|
};
|
|
|
|
#endif //ADC_H
|