add pixel stuff to src

This commit is contained in:
2018-11-15 17:55:26 +01:00
parent acfad93691
commit a81abbdb72
5 changed files with 0 additions and 66 deletions

View File

@@ -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

View File

@@ -5,12 +5,10 @@
#define _TASK_STD_FUNCTION
#include "TaskSchedulerDeclarations.h"
#include "MeshNet.h"
#include "Plugin.h"
#include "NeoPixelConfig.h"
#include "NeoPatternState.h"
#include "NeoPattern.cpp"
#include "config.h"
using namespace std;
using namespace std::placeholders;