new device type: led

This commit is contained in:
2016-05-17 23:55:41 +02:00
parent 783286849a
commit 7a79f1ca12
3 changed files with 133 additions and 0 deletions

28
things/DeviceLed.h Normal file
View File

@@ -0,0 +1,28 @@
#pragma once
#include "Device.h"
#include <Homie.h>
class DeviceLed : public Device {
public:
inline DeviceLed(byte ledPin) {
pinLed = ledPin;
}
virtual void deviceSetup();
virtual void deviceRegister();
virtual void deviceLoop();
private:
byte pinLed;
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);
HomieNode ledNode{"led", "led"};
};