Moved mode names (& slider data) to a static array
-- may break some things --
This commit is contained in:
parent
e003ec39fb
commit
a6d7ed3824
387
wled00/FX.cpp
387
wled00/FX.cpp
File diff suppressed because it is too large
Load Diff
@ -277,11 +277,11 @@ class WS2812FX {
|
||||
|
||||
static WS2812FX* instance;
|
||||
|
||||
// mode (effect) name and its slider control data array
|
||||
static const char *_modeData[MODE_COUNT];
|
||||
|
||||
public:
|
||||
|
||||
// mode (effect) name and its slider control data array
|
||||
static const char * const _modeData[MODE_COUNT];
|
||||
|
||||
// segment parameters
|
||||
typedef struct Segment { // 35 (36 in memory) bytes
|
||||
uint16_t start; // start index / start X coordinate 2D (left)
|
||||
|
@ -106,10 +106,12 @@ void WS2812FX::setUpMatrix() {
|
||||
}
|
||||
}
|
||||
|
||||
// XY(x,y) - gets pixel index within current segment (takes into account transposed segment)
|
||||
// XY(x,y) - gets pixel index within current segment
|
||||
uint16_t IRAM_ATTR WS2812FX::XY(uint16_t x, uint16_t y) {
|
||||
uint16_t width = SEGMENT.virtualWidth(); // segment width in logical pixels (is already transposed)
|
||||
uint16_t height = SEGMENT.virtualHeight(); // segment height in logical pixels (is already transposed)
|
||||
uint16_t width = SEGMENT.virtualWidth(); // segment width in logical pixels
|
||||
uint16_t height = SEGMENT.virtualHeight(); // segment height in logical pixels
|
||||
/*
|
||||
// it may be unnecessary to perform transpose since pixels should be always addressed using XY() function
|
||||
if (SEGMENT.getOption(SEG_OPTION_TRANSPOSED)) {
|
||||
uint16_t t;
|
||||
// swap X & Y if segment transposed
|
||||
@ -117,6 +119,7 @@ uint16_t IRAM_ATTR WS2812FX::XY(uint16_t x, uint16_t y) {
|
||||
// swap width & height if segment transposed
|
||||
t = width; width = height; height = t;
|
||||
}
|
||||
*/
|
||||
return (x%width) + (y%height) * width;
|
||||
}
|
||||
|
||||
|
@ -1313,7 +1313,9 @@ uint8_t Bus::_gAWM = 255;
|
||||
// Note: Effects can override default pattern behaviour
|
||||
// - FadeToBlack can override the background setting
|
||||
// - Defining SEGCOL(<i>) can override a specific palette using these values (e.g. Color Gradient)
|
||||
const char JSON_mode_names[] PROGMEM = R"=====([
|
||||
const char JSON_mode_names[] PROGMEM = R"=====(["Modenames have moved"])=====";
|
||||
/*
|
||||
R"=====([
|
||||
"Solid",
|
||||
"Blink@!,;!,!,;!",
|
||||
"Breathe@!,;!,!;!",
|
||||
@ -1460,6 +1462,7 @@ const char JSON_mode_names[] PROGMEM = R"=====([
|
||||
"2D Ghost Rider@Fade rate,Blur;!,!,!;!",
|
||||
"2D Blobs@!,# blobs;!,!,!;!"
|
||||
])=====";
|
||||
*/
|
||||
|
||||
const char JSON_palette_names[] PROGMEM = R"=====([
|
||||
"Default","* Random Cycle","* Color 1","* Colors 1&2","* Color Gradient","* Colors Only","Party","Cloud","Lava","Ocean",
|
||||
|
@ -823,6 +823,17 @@ void serializeNodes(JsonObject root)
|
||||
|
||||
void serializeModeData(JsonArray fxdata)
|
||||
{
|
||||
for (size_t i = 0; i < MODE_COUNT; i++) {
|
||||
//char buffer[256];
|
||||
//strcpy_P(buffer, (const char*)pgm_read_dword(&(WS2812FX::_modeData[i])));
|
||||
String lineBuffer = (const char*)pgm_read_dword(&(WS2812FX::_modeData[i]));
|
||||
if (lineBuffer.length() > 0) {
|
||||
uint8_t endPos = lineBuffer.indexOf('@');
|
||||
if (endPos>0) fxdata.add(lineBuffer.substring(endPos));
|
||||
else fxdata.add("");
|
||||
}
|
||||
}
|
||||
/*
|
||||
//JsonArray fxdata = root.createNestedArray("fxdata");
|
||||
String lineBuffer;
|
||||
bool insideQuotes = false;
|
||||
@ -856,11 +867,21 @@ void serializeModeData(JsonArray fxdata)
|
||||
lineBuffer += singleJsonSymbol;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// deserializes mode names string into JsonArray
|
||||
// also removes WLED-SR extensions (@...) from deserialised names
|
||||
void serializeModeNames(JsonArray arr, const char *qstring) {
|
||||
for (size_t i = 0; i < MODE_COUNT; i++) {
|
||||
String lineBuffer = (const char*)pgm_read_dword(&(WS2812FX::_modeData[i]));
|
||||
if (lineBuffer.length() > 0) {
|
||||
uint8_t endPos = lineBuffer.indexOf('@');
|
||||
if (endPos>0) arr.add(lineBuffer.substring(0,endPos));
|
||||
else arr.add(lineBuffer);
|
||||
}
|
||||
}
|
||||
/*
|
||||
String lineBuffer;
|
||||
bool insideQuotes = false;
|
||||
char singleJsonSymbol;
|
||||
@ -891,6 +912,7 @@ void serializeModeNames(JsonArray arr, const char *qstring) {
|
||||
lineBuffer += singleJsonSymbol;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void serveJson(AsyncWebServerRequest* request)
|
||||
|
@ -234,6 +234,22 @@ void releaseJSONBufferLock()
|
||||
// caller must provide large enough buffer for name (incluing SR extensions)!
|
||||
uint8_t extractModeName(uint8_t mode, const char *src, char *dest, uint8_t maxLen)
|
||||
{
|
||||
if (src == JSON_mode_names) {
|
||||
if (mode < MODE_COUNT) {
|
||||
char lineBuffer[256];
|
||||
strcpy_P(lineBuffer, (const char*)pgm_read_dword(&(WS2812FX::_modeData[mode])));
|
||||
if (strlen(lineBuffer) > 0) {
|
||||
size_t j = 0;
|
||||
for (; j < maxLen; j++) {
|
||||
if (lineBuffer[j] == '\0' || lineBuffer[j] == '@') break;
|
||||
dest[j] = lineBuffer[j];
|
||||
}
|
||||
dest[j] = 0; // terminate string
|
||||
}
|
||||
return strlen(dest);
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
uint8_t qComma = 0;
|
||||
bool insideQuotes = false;
|
||||
uint8_t printedChars = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user