-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCQRobotTDS.h
36 lines (28 loc) · 832 Bytes
/
CQRobotTDS.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
#ifndef CQROBOT_H
#define CQROBOT_H
#include "Arduino.h"
#define CQROBOT_SCOUNT 30
class CQRobotTDS
{
public:
CQRobotTDS(int pin, float aref=5.0);
~CQRobotTDS();
float update(); //read and calculate
float update(float temp); //read and calculate
void setTemperature(float temp); //set the temperature and execute temperature compensation
void setAdcRange(float range); //1024 for 10bit ADC;4096 for 12bit ADC
float getTdsValue();
private:
int pin;
float aref; // default 5.0V on Arduino UNO
float adcRange;
float temperature;
float tdsValue;
int analogBuffer[CQROBOT_SCOUNT]; // store the analog value in the array, read from ADC
int analogBufferTemp[CQROBOT_SCOUNT];
int analogBufferIndex = 0;
int copyIndex = 0;
float averageVoltage = 0;
int getMedianNum(int bArray[], int iFilterLen);
};
#endif