-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsensorReader.cpp
More file actions
48 lines (39 loc) · 786 Bytes
/
Copy pathsensorReader.cpp
File metadata and controls
48 lines (39 loc) · 786 Bytes
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
#include "sensorReader.h"
#include "phSensor.h"
#include "globalMtx.h"
#include <unistd.h>
#include <iostream>
using namespace std;
void startSensorReader()
{
while (1)
{
readPH();
sleep(5);
}
}
void readPH()
{
if (!phSensors.empty())
{
for (int i = 0; i < phSensors.size(); i++)
{
char buff[50];
if (phSensors[i]->isOperating())
{
snprintf(buff, sizeof(buff), "%.2f", phSensors[i]->getNewPHReading());
//phSensors[i]->startSleepmode(); //dont overdo it. It seems like the device tend to freeze at some point
string phStr = buff;
cout << "Slot " << phSensors[i]->getSlotPosition() << ": " << phStr << endl;
}
else
{
cout << "PH-Reading paused!" << endl;
}
}
}
else
{
cout << "not ph sensor found" << endl;
}
}