Things/things/DeviceLed.h

31 lines
749 B
C
Raw Normal View History

2016-05-17 21:55:41 +00:00
#pragma once
#include "Device.h"
#include <Homie.h>
class DeviceLed : public Device {
public:
2016-05-19 08:44:20 +00:00
inline DeviceLed(byte ledPin, char* ledName):ledNode(ledName, "led") {
2016-05-17 21:55:41 +00:00
pinLed = ledPin;
2016-05-19 08:44:20 +00:00
nameLed = ledName;
2016-05-17 21:55:41 +00:00
}
virtual void deviceSetup();
virtual void deviceRegister();
virtual void deviceLoop();
private:
byte pinLed;
2016-05-19 08:44:20 +00:00
char* nameLed;
2016-05-17 21:55:41 +00:00
int brightness = 0;
bool fading = false;
int fade_from, fade_to;
unsigned long fade_start = 0;
unsigned long fade_end = 0;
float progress_last = 0;
void setLed(int value);
void publishStatus();
bool ledOnHandler(String value);
bool ledBrightnessHandler(String message);
bool ledFadeHandler(String message);
2016-05-19 08:44:20 +00:00
HomieNode ledNode;
2016-05-17 21:55:41 +00:00
};