31 lines
749 B
C++
31 lines
749 B
C++
#pragma once
|
|
|
|
#include "Device.h"
|
|
#include <Homie.h>
|
|
|
|
class DeviceLed : public Device {
|
|
public:
|
|
inline DeviceLed(byte ledPin, char* ledName):ledNode(ledName, "led") {
|
|
pinLed = ledPin;
|
|
nameLed = ledName;
|
|
}
|
|
virtual void deviceSetup();
|
|
virtual void deviceRegister();
|
|
virtual void deviceLoop();
|
|
bool ledOnHandler(String value);
|
|
bool ledBrightnessHandler(String message);
|
|
bool ledFadeHandler(String message);
|
|
private:
|
|
byte pinLed;
|
|
char* nameLed;
|
|
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();
|
|
HomieNode ledNode;
|
|
};
|