From 7169be9882d5289e3a420fd44ddd7034bf4dcc95 Mon Sep 17 00:00:00 2001 From: Ronald Schaten Date: Thu, 19 May 2016 10:44:20 +0200 Subject: [PATCH] enable having two led channels --- things/DeviceLed.h | 6 ++++-- things/HardwareH801wifi.h | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/things/DeviceLed.h b/things/DeviceLed.h index 0dd1de2..8f8f7ac 100644 --- a/things/DeviceLed.h +++ b/things/DeviceLed.h @@ -5,14 +5,16 @@ class DeviceLed : public Device { public: - inline DeviceLed(byte ledPin) { + inline DeviceLed(byte ledPin, char* ledName):ledNode(ledName, "led") { pinLed = ledPin; + nameLed = ledName; } virtual void deviceSetup(); virtual void deviceRegister(); virtual void deviceLoop(); private: byte pinLed; + char* nameLed; int brightness = 0; bool fading = false; int fade_from, fade_to; @@ -24,5 +26,5 @@ class DeviceLed : public Device { bool ledOnHandler(String value); bool ledBrightnessHandler(String message); bool ledFadeHandler(String message); - HomieNode ledNode{"led", "led"}; + HomieNode ledNode; }; diff --git a/things/HardwareH801wifi.h b/things/HardwareH801wifi.h index c66ea27..76ccb41 100644 --- a/things/HardwareH801wifi.h +++ b/things/HardwareH801wifi.h @@ -13,8 +13,10 @@ const char* FWNAME = "things@H801wifi"; -const byte PIN_LED = 14; -DeviceLed deviceLed(PIN_LED); +const byte PIN_LED1 = 14; +const byte PIN_LED2 = 4; +DeviceLed deviceLedW1(PIN_LED1, "white1"); +DeviceLed deviceLedW2(PIN_LED2, "white2"); const byte PIN_RGB_RED = 15; const byte PIN_RGB_GREEN = 13; @@ -22,6 +24,7 @@ const byte PIN_RGB_BLUE = 12; DeviceRgb deviceRgb(PIN_RGB_RED, PIN_RGB_GREEN, PIN_RGB_BLUE); Device* devices[] = { - &deviceLed, + &deviceLedW1, + &deviceLedW2, &deviceRgb, };