mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-16 01:58:47 +01:00
moar topics
This commit is contained in:
@@ -30,11 +30,12 @@ class NeoPattern : public Adafruit_NeoPixel
|
||||
pattern ActivePattern; // which pattern is running
|
||||
direction Direction; // direction to run the pattern
|
||||
|
||||
unsigned long Interval; // milliseconds between updates
|
||||
unsigned long lastUpdate; // last update of position
|
||||
unsigned long Interval = 150; // milliseconds between updates
|
||||
unsigned long lastUpdate = 0; // last update of position
|
||||
|
||||
uint32_t Color1, Color2; // What colors are in use
|
||||
uint16_t TotalSteps; // total number of steps in the pattern
|
||||
uint32_t Color1 = 0;
|
||||
uint32_t Color2 = 0; // What colors are in use
|
||||
uint16_t TotalSteps = 255; // total number of steps in the pattern
|
||||
uint16_t Index; // current step within the pattern
|
||||
uint16_t completed = 0;
|
||||
|
||||
@@ -45,19 +46,20 @@ class NeoPattern : public Adafruit_NeoPixel
|
||||
:Adafruit_NeoPixel(pixels, pin, type)
|
||||
{
|
||||
OnComplete = callback;
|
||||
TotalSteps = numPixels();
|
||||
}
|
||||
|
||||
NeoPattern(uint16_t pixels, uint8_t pin, uint8_t type)
|
||||
:Adafruit_NeoPixel(pixels, pin, type)
|
||||
{
|
||||
|
||||
TotalSteps = numPixels();
|
||||
}
|
||||
|
||||
void onCompleteDefault(int pixels) {
|
||||
if(ActivePattern != RAINBOW_CYCLE){
|
||||
//Serial.println("reversing");
|
||||
Reverse();
|
||||
}
|
||||
Reverse();
|
||||
//Serial.println("pattern completed");
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,38 @@ struct NeoPixelConfig : public JsonStruct {
|
||||
}
|
||||
};
|
||||
|
||||
struct NeoPatternMsg : public JsonStruct {
|
||||
String pattern;
|
||||
String payload;
|
||||
String topic;
|
||||
uint color;
|
||||
uint color2;
|
||||
uint totalSteps;
|
||||
void mapJsonObject(JsonObject& root) {
|
||||
root["topic"] = topic;
|
||||
root["pattern"] = pattern;
|
||||
root["payload"] = payload;
|
||||
root["color"] = color;
|
||||
root["color2"] = color2;
|
||||
root["totalSteps"] = totalSteps;
|
||||
}
|
||||
// Map a json object to this struct.
|
||||
void fromJsonObject(JsonObject& json){
|
||||
if(!verifyJsonObject(json)){
|
||||
PRINT_MSG(Serial, "fromJsonObject", "cannot parse JSON");
|
||||
valid = 0;
|
||||
return;
|
||||
}
|
||||
topic = getAttrFromJson(json, "topic");
|
||||
color = getIntAttrFromJson(json, "color");
|
||||
color2 = getIntAttrFromJson(json, "color2");
|
||||
pattern = getAttrFromJson(json, "pattern");
|
||||
payload = getAttrFromJson(json, "payload");
|
||||
totalSteps = getIntAttrFromJson(json, "totalSteps", 255);
|
||||
valid = 1;
|
||||
};
|
||||
};
|
||||
|
||||
struct NeoPatternDto : public JsonStruct {
|
||||
uint mode;
|
||||
uint value;
|
||||
@@ -51,12 +83,14 @@ struct NeoPatternDto : public JsonStruct {
|
||||
void fromJsonObject(JsonObject& json){
|
||||
if(!verifyJsonObject(json)){
|
||||
PRINT_MSG(Serial, "fromJsonObject", "cannot parse JSON");
|
||||
valid = 0;
|
||||
return;
|
||||
}
|
||||
mode = atoi(json[JSON_MODE_NODE]);
|
||||
mode = mode < ARRAY_LENGTH(PIXEL_FNCS) ? mode : 0;
|
||||
value = json[JSON_VALUE];
|
||||
valueStr = json[JSON_VALUE];
|
||||
valid = 1;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user