Commit d1883e9f authored by PhiBo's avatar PhiBo 🚀

Move sensor class to new file

parent 2543f608
#include "../sensor_node.h"
BaseSensor::BaseSensor()
{
}
void BaseSensor::finish(SensorNode *sensor)
{
}
void BaseSensor::run(SensorNode *sensor)
{
}
void BaseSensor::start(SensorNode *sensor)
{
}
#include "../sensor_node.h"
SensorDHT::SensorDHT(uint8_t *options)
{
this->dht = new DHT(options[0], DHT22);
}
void SensorDHT::finish(SensorNode *sensor)
{
float value;
value = this->dht->readTemperature();
sensor->writeValue(
SENSOR_VALUE_TEMPERATURE,
value
);
value = this->dht->readHumidity();
sensor->writeValue(
SENSOR_VALUE_HUMIDITY,
value
);
}
void SensorDHT::start(SensorNode *sensor)
{
this->dht->readTemperature();
this->dht->readHumidity();
}
...@@ -161,42 +161,6 @@ void SensorNode::writeValue(uint8_t type, float value) ...@@ -161,42 +161,6 @@ void SensorNode::writeValue(uint8_t type, float value)
this->value_count++; this->value_count++;
} }
BaseSensor::BaseSensor()
{
}
SensorDHT::SensorDHT(uint8_t *options)
{
this->dht = new DHT(options[0], DHT22);
}
void SensorDHT::start(SensorNode *sensor)
{
this->dht->readTemperature();
this->dht->readHumidity();
}
void SensorDHT::run(SensorNode *sensor)
{
}
void SensorDHT::finish(SensorNode *sensor)
{
float value;
value = this->dht->readTemperature();
sensor->writeValue(
SENSOR_VALUE_TEMPERATURE,
value
);
value = this->dht->readHumidity();
sensor->writeValue(
SENSOR_VALUE_HUMIDITY,
value
);
}
SensorWifiModuleRemote::SensorWifiModuleRemote(ArduRPCRequest &rpc, uint8_t handler_id) : ArduRPCRequestHandler() SensorWifiModuleRemote::SensorWifiModuleRemote(ArduRPCRequest &rpc, uint8_t handler_id) : ArduRPCRequestHandler()
{ {
this->_rpc = &rpc; this->_rpc = &rpc;
......
...@@ -78,7 +78,6 @@ class SensorDHT : public BaseSensor ...@@ -78,7 +78,6 @@ class SensorDHT : public BaseSensor
SensorDHT(uint8_t *); SensorDHT(uint8_t *);
void void
finish(SensorNode *), finish(SensorNode *),
run(SensorNode *),
start(SensorNode *); start(SensorNode *);
private: private:
DHT *dht; DHT *dht;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment