finally a working modularized version

This commit is contained in:
Ronald Schaten 2016-04-10 00:20:50 +02:00
parent 73395170ac
commit 52c4648c02
3 changed files with 5 additions and 8 deletions

View File

@ -7,7 +7,7 @@
class DeviceDht : public Device { class DeviceDht : public Device {
public: public:
inline DeviceDht(byte dhtPin, byte dhtType) { inline DeviceDht(byte dhtPin, byte dhtType):dht(dhtPin, dhtType) {
pin = dhtPin; pin = dhtPin;
type = dhtType; type = dhtType;
} }
@ -17,9 +17,7 @@ class DeviceDht : public Device {
private: private:
byte pin; byte pin;
byte type; byte type;
// TODO configuration via constructor doesn't work yet DHT dht;
//DHT dht{pin, type};
DHT dht{D4, DHT22};
const int INTERVAL_DHT = 60; const int INTERVAL_DHT = 60;
unsigned long lastSentDHT = 0; unsigned long lastSentDHT = 0;
float humidity, temperature; // raw values from the sensor float humidity, temperature; // raw values from the sensor

View File

@ -17,7 +17,7 @@ class DeviceLdr : public Device {
const int INTERVAL_LDR = 60; const int INTERVAL_LDR = 60;
unsigned long lastSentLDR = 0; unsigned long lastSentLDR = 0;
int ldr = 0; int ldr = 0;
HomieNode ldrNode{"ldr", "ldr"}; HomieNode ldrNode = HomieNode("ldr", "ldr");
}; };
void DeviceLdr::setup() { void DeviceLdr::setup() {

View File

@ -88,9 +88,8 @@ bool DeviceLed::ledColorHandler(String message) {
} }
void DeviceLed::homieRegister() { void DeviceLed::homieRegister() {
// TODO this doesn't work :-( ledNode.subscribe("on", [this](String value) { return ledOnHandler(value); });
//ledNode.subscribe("on", &DeviceLed::ledOnHandler()); ledNode.subscribe("color", std::bind(&DeviceLed::ledColorHandler, this, std::placeholders::_1));
//ledNode.subscribe("color", &DeviceLed::ledColorHandler());
Homie.registerNode(ledNode); Homie.registerNode(ledNode);
} }