Things/things/DeviceLed.h

31 lines
749 B
C
Raw Normal View History

2016-05-17 23:55:41 +02:00
#pragma once
#include "Device.h"
#include <Homie.h>
class DeviceLed : public Device {
public:
2016-05-19 10:44:20 +02:00
inline DeviceLed(byte ledPin, char* ledName):ledNode(ledName, "led") {
2016-05-17 23:55:41 +02:00
pinLed = ledPin;
2016-05-19 10:44:20 +02:00
nameLed = ledName;
2016-05-17 23:55:41 +02:00
}
virtual void deviceSetup();
virtual void deviceRegister();
virtual void deviceLoop();
2016-05-21 19:17:03 +02:00
bool ledOnHandler(String value);
bool ledBrightnessHandler(String message);
bool ledFadeHandler(String message);
2016-05-17 23:55:41 +02:00
private:
byte pinLed;
2016-05-19 10:44:20 +02:00
char* nameLed;
2016-05-17 23:55:41 +02: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();
2016-05-19 10:44:20 +02:00
HomieNode ledNode;
2016-05-17 23:55:41 +02:00
};