new device type: led
This commit is contained in:
28
things/DeviceLed.h
Normal file
28
things/DeviceLed.h
Normal 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"};
|
||||
};
|
||||
Reference in New Issue
Block a user