forked from D3R-ST3FAN/LaCrosseGatewayMQTT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalogPort.cpp
More file actions
44 lines (34 loc) · 798 Bytes
/
Copy pathAnalogPort.cpp
File metadata and controls
44 lines (34 loc) · 798 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
#include "AnalogPort.h"
AnalogPort::AnalogPort() {
m_enabled = false;
}
bool AnalogPort::TryInitialize(unsigned int u1023) {
m_enabled = true;
m_u1023 = u1023;
return true;
}
String AnalogPort::GetFhemDataString(){
String result = "";
if (millis() < m_lastMeasurement ) {
m_lastMeasurement = 0;
}
if (millis() >= m_lastMeasurement + 4000) {
m_lastMeasurement = millis();
result += "LGW ANALOG";
m_lastValue = analogRead(A0);
result += " ";
result += (byte)(m_lastValue >> 8);
result += " ";
result += (byte)(m_lastValue);
}
return result;
}
word AnalogPort::GetLastValue() {
return m_lastValue;
}
bool AnalogPort::IsEnabled() {
return m_enabled;
}
unsigned int AnalogPort::GetU1023() {
return m_u1023;
}