-
Notifications
You must be signed in to change notification settings - Fork 0
/
CircuitIoTRGBWStrip.h
47 lines (39 loc) · 1.2 KB
/
CircuitIoTRGBWStrip.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef _CIRCUITIOT_RGBWSTRIP_H_
#define _CIRCUITIOT_RGBWSTRIP_H_
#ifdef ESP8266
#include <ESP8266WiFi.h>
#endif
#ifdef ESP32
#include <WiFi.h>
#endif
#include <WiFiClientSecure.h>
#include "CircuitIoTDevice.h"
#include <EEPROM.h>
#define PROP_RGBW "rgbw"
#define PROP_POWER "power"
#define PROP_WHITE "white"
struct RGBW {
int r,g,b,w;
};
class CircuitIoTRGBWStrip: public CircuitIoTDevice {
public:
CircuitIoTRGBWStrip(WiFiClientSecure& wifiClient, char token[]);
void setup(unsigned int redPin, unsigned int greenPin, unsigned int bluePin, unsigned int whitePin);
void run();
bool pushPowerStateChange(const char* value);
bool pushColorChange(int red, int green, int blue, int white);
private:
int _redPin;
int _greenPin;
int _bluePin;
int _whitePin;
void parseRgbw(const char* value);
void parseWhite(const char* whiteValue);
void changeColor(int red, int green, int blue, int white);
void handlePower(const char* value);
struct RGBW _rgbw;
void pwmWrite(int red, int green, int blue, int white);
protected:
virtual void onDeviceStateChange(const char* deviceId, const char* property, const char* value);
};
#endif