mirror of
https://gitlab.com/wirelos/sprocket-plugin-neopixel.git
synced 2025-12-14 21:52:21 +01:00
add pixel stuff to src
This commit is contained in:
@@ -1,64 +0,0 @@
|
|||||||
#ifndef __NEOPATTERN_STATE__
|
|
||||||
#define __NEOPATTERN_STATE__
|
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
|
||||||
#include "utils/utils_print.h"
|
|
||||||
#include "JsonStruct.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct NeoPixelConfig : public JsonStruct {
|
|
||||||
// FIXME constants!
|
|
||||||
int pin = 4;
|
|
||||||
int length = 8;
|
|
||||||
int brightness = 100;
|
|
||||||
int updateInterval = 100;
|
|
||||||
int defaultColor = 100; // FIXME remove unused
|
|
||||||
void mapJsonObject(JsonObject& root) {
|
|
||||||
root["pin"] = pin;
|
|
||||||
root["length"] = length;
|
|
||||||
root["brightness"] = brightness;
|
|
||||||
root["updateInterval"] = updateInterval;
|
|
||||||
root["defaultColor"] = defaultColor;
|
|
||||||
}
|
|
||||||
void fromJsonObject(JsonObject& json) {
|
|
||||||
pin = getIntAttrFromJson(json, "pin", pin);
|
|
||||||
length = getIntAttrFromJson(json, "length", length);
|
|
||||||
brightness = getIntAttrFromJson(json, "brightness", brightness);
|
|
||||||
updateInterval = getIntAttrFromJson(json, "updateInterval", updateInterval);
|
|
||||||
defaultColor = getIntAttrFromJson(json, "defaultColor", defaultColor);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct NeoPatternState : public JsonStruct {
|
|
||||||
uint pattern = 0;
|
|
||||||
uint color= 0;
|
|
||||||
uint color2= 0;
|
|
||||||
uint totalSteps = 16;
|
|
||||||
uint brightness = 64;
|
|
||||||
|
|
||||||
void mapJsonObject(JsonObject& root) {
|
|
||||||
root["pattern"] = pattern;
|
|
||||||
root["color"] = color;
|
|
||||||
root["color2"] = color2;
|
|
||||||
root["totalSteps"] = totalSteps;
|
|
||||||
root["brightness"] = brightness;
|
|
||||||
|
|
||||||
}
|
|
||||||
// Map a json object to this struct.
|
|
||||||
void fromJsonObject(JsonObject& json){
|
|
||||||
if(!verifyJsonObject(json)){
|
|
||||||
PRINT_MSG(Serial, "fromJsonObject", "cannot parse JSON");
|
|
||||||
valid = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
color = getIntAttrFromJson(json, "color", color);
|
|
||||||
color2 = getIntAttrFromJson(json, "color2", color2);
|
|
||||||
pattern = getIntAttrFromJson(json, "pattern", pattern);
|
|
||||||
brightness = getIntAttrFromJson(json, "brightness", brightness);
|
|
||||||
totalSteps = getIntAttrFromJson(json, "totalSteps", totalSteps);
|
|
||||||
valid = 1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -5,12 +5,10 @@
|
|||||||
#define _TASK_STD_FUNCTION
|
#define _TASK_STD_FUNCTION
|
||||||
|
|
||||||
#include "TaskSchedulerDeclarations.h"
|
#include "TaskSchedulerDeclarations.h"
|
||||||
#include "MeshNet.h"
|
|
||||||
#include "Plugin.h"
|
#include "Plugin.h"
|
||||||
#include "NeoPixelConfig.h"
|
#include "NeoPixelConfig.h"
|
||||||
#include "NeoPatternState.h"
|
#include "NeoPatternState.h"
|
||||||
#include "NeoPattern.cpp"
|
#include "NeoPattern.cpp"
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|||||||
Reference in New Issue
Block a user