updated screen + added OTA
This commit is contained in:
23
sensor.h
23
sensor.h
@@ -42,6 +42,7 @@ class AQSSensor
|
||||
bool _publish = false;
|
||||
const uint32_t _scaleMin;
|
||||
const uint32_t _scaleMax;
|
||||
bool _valid;
|
||||
|
||||
public:
|
||||
AQSSensor(String name, sensor_e sensor, String unit,
|
||||
@@ -58,14 +59,23 @@ public:
|
||||
sprintf(_topic, "Sensors/%s/%s", deviceID.c_str(), name.c_str());
|
||||
sprintf(_topic_1h, "Sensors/%s/%s/1h/", deviceID.c_str(), name.c_str());
|
||||
sprintf(_topic_24h, "Sensors/%s/%s/24h/", deviceID.c_str(), name.c_str());
|
||||
_valid = false;
|
||||
}
|
||||
|
||||
void publish(void)
|
||||
{
|
||||
_publish = true;
|
||||
if (_valid)
|
||||
{
|
||||
_publish = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("Sensor %s : Not published (invalid)\n", _name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
String getName(void)
|
||||
String
|
||||
getName(void)
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
@@ -88,17 +98,18 @@ public:
|
||||
|
||||
virtual void set(uint32_t value)
|
||||
{
|
||||
if((value > _scaleMin) && (value < _scaleMax))
|
||||
if ((value > _scaleMin) && (value < _scaleMax))
|
||||
{
|
||||
_value = value;
|
||||
_average1h.add(_value);
|
||||
_average24h.add(_value);
|
||||
_valid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("Sensor %s: value out of bounds (%d)\n", _name.c_str(), value);
|
||||
Serial.printf("Sensor %s set(%d): value out of bounds\n", _name.c_str(), _value);
|
||||
_valid = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
uint32_t value() { return _value; }
|
||||
@@ -113,7 +124,7 @@ public:
|
||||
|
||||
sensor_e getSensor(void) { return _sensor; }
|
||||
|
||||
String getUnit(void) { return _unit;}
|
||||
String getUnit(void) { return _unit; }
|
||||
|
||||
uint32_t getMin(void) { return _scaleMin; }
|
||||
uint32_t getMax(void) { return _scaleMax; }
|
||||
|
||||
Reference in New Issue
Block a user