-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathESP_SHD_WS2812bStrip.h
75 lines (62 loc) · 2.28 KB
/
ESP_SHD_WS2812bStrip.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef ESP_SHD_LEDSTRIP
#define ESP_SHD_LEDSTRIP
#define FASTLED_ESP8266_RAW_PIN_ORDER
#include "ESP_SmartHomeDevice.h"
#include "PubSubClient.h"
#include "FastLED.h"
#define MAX_NUM_OF_LEDS 144
#define MAX_NUM_OF_SECTIONS 5
#define DATA_PIN 4
#define DEBUG 0
enum ignitionDirection { IGNITION_SINGLE_FORWARD, IGNITION_SINGLE_BACKWARD, IGNITION_BOTH_FORWARD, IGNITION_BOTH_BACKWARD };
class ShdWs2812bStrip : public ESP_SmartHomeDevice {
public:
static void initStrip(uint16_t _numberOfLeds, uint16_t _updateInterval);
ShdWs2812bStrip(uint16_t _firstLed, uint16_t _lastLed, uint16_t _ignitionPoint, ignitionDirection _ignitionDirection, uint8_t _hopsPerShow, uint8_t _flankLength);
static void toggleCallback(void *_objectPointer);
void toggle();
private:
// static functions and variables for the entire strip:
static void show();
static CRGB leds[MAX_NUM_OF_LEDS];
static uint16_t numberOfLeds;
static uint32_t millisLastStripUpdate;
static uint32_t millisStripUpdateInterval;
static uint8_t numberOfSections;
static ShdWs2812bStrip * sections[MAX_NUM_OF_SECTIONS];
static bool correctlyInitialized;
static uint16_t counter5ms;
static uint8_t gammaCorrection[256];
// variables for each section
uint8_t sectionNumber;
uint16_t sectionLength;
uint8_t firstLed, lastLed;
uint16_t setPoint[3], shownValue[3], savedValue[3];
int16_t delta[3];
uint8_t flankLength;
uint8_t hopsPerShow;
uint16_t updateInterval;
bool directionInverted;
bool directionTmpInverted;
bool igniting;
uint16_t ignitionCounter;
uint16_t ignitionPoint;
char subTopicColor[50], pubTopicColor[50], subTopicState[50], pubTopicState[50], pubTopicBrightness[50], payloadBuffer[50];
ignitionDirection direction;
// functions for each section:
bool handleMqttRequest(char* _topic, byte* _payload, uint16_t _length);
void setNewColor(uint8_t _newRed, uint8_t _newGreen, uint8_t _newBlue);
void timer5msHandler();
void updateCRGBs();
//void (ShdWs2812bStrip::*ignitionFunction)();
void callIgnitionFunction();
void igniteBothDir();
void igniteSingleDir();
bool fillLedWithNewColor(uint16_t _ledIndex);
bool fillLedWithNewColor(uint16_t _ledIndex1, uint16_t _ledIndex2);
void clearPayloadBuffer();
void republish();
void subscribe();
void changeStatus();
};
#endif