Things/things/DeviceRgb.h

37 lines
940 B
C
Raw Normal View History

2016-04-22 22:32:36 +02:00
#pragma once
#include "Device.h"
#include <Homie.h>
class DeviceRgb : public Device {
public:
inline DeviceRgb(byte rgbRed, byte rgbGreen, byte rgbBlue) {
pinRed = rgbRed;
pinGreen = rgbGreen;
pinBlue = rgbBlue;
}
2016-04-11 00:29:05 +02:00
virtual void deviceSetup();
virtual void deviceRegister();
virtual void deviceLoop();
private:
byte pinRed;
byte pinGreen;
byte pinBlue;
int rgb_red = 0;
int rgb_green = 0;
int rgb_blue = 0;
2016-04-27 21:24:55 +02:00
bool fading = false;
int fade_from_red, fade_to_red;
int fade_from_green, fade_to_green;
int fade_from_blue, fade_to_blue;
unsigned long fade_start = 0;
unsigned long fade_end = 0;
float progress_last = 0;
void setRgb(int red, int green, int blue);
2016-04-27 21:40:33 +02:00
void publishStatus();
bool rgbOnHandler(String value);
bool rgbColorHandler(String message);
bool rgbFadeHandler(String message);
HomieNode rgbNode{"rgb", "rgb"};
};