-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAnalogPHMeter.h
67 lines (55 loc) · 2.08 KB
/
AnalogPHMeter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef __ANALOG_PH_METER_H__
#define __ANALOG_PH_METER_H__
struct PHCalibrationValue {
char point;
float value[2];
int adc[2];
float slope;
int adcOffset;
};
class AnalogPHMeter {
private:
struct PHCalibrationValue calibrationValue;
unsigned int pin;
float pH;
float temperature;
bool debug;
bool stable;
unsigned char stableCount;
float precision;
unsigned char index;
float valueBefore, deltaValue, sumOfDeltaValue;
float deltaValueBuffer[10];
float defaultSlope;
int defaultAdcAt7;
int readADC(int oversampling = 64);
void inputValue(float value);
public:
AnalogPHMeter(unsigned int pin, float defaultSlope = 0.01f, int defaultAdcAt7 = 410);
AnalogPHMeter &initialize(struct PHCalibrationValue = (struct PHCalibrationValue){});
AnalogPHMeter &singleReading(void);
AnalogPHMeter &temperatureCompensation(float temperature);
AnalogPHMeter &calibration(void);
AnalogPHMeter &calibrationClear(void);
AnalogPHMeter &calibrationMid(float mid);
AnalogPHMeter &calibrationLow(float low);
AnalogPHMeter &calibrationHigh(float high);
AnalogPHMeter &factoryReset(void);
float getpH(void) { return this->pH; };
float getTemperature(void) { return this->temperature; };
float getCalibrationPoint(void) { return this->calibrationValue.point; };
struct PHCalibrationValue getCalibrationValue(void) {
return calibrationValue;
};
unsigned char getpHStableCount(void) { return this->stableCount; };
float getSumOfDeltaValue(void) { return this->sumOfDeltaValue; };
float getDeltaValue(void) { return this->deltaValue; };
float getPrecision(void) { return this->precision; };
float getDefaultSlope(void) { return this->defaultSlope; };
float getDefaultAdcAt7(void) { return this->defaultAdcAt7; };
bool ispHStable(void) { return this->stable; };
AnalogPHMeter & setpHPrecision(float precision) { this->precision = precision; return *this; };
AnalogPHMeter & setDefaultSlope(float slope) { this->defaultSlope = slope; return *this; };
AnalogPHMeter & setDefaultAdcAt7(int adc) { this->defaultAdcAt7 = defaultAdcAt7; return *this; };
};
#endif