From 365f98e53b43dec3d5758c9958e3d5ea062c1184 Mon Sep 17 00:00:00 2001 From: Ewoud Date: Fri, 26 Jan 2024 16:24:33 +0100 Subject: [PATCH] WIP --- platformio.ini | 2 +- src/App/AppLeds.cpp | 2 +- src/App/AppLeds.h | 2 +- src/App/AppModLeds.h | 27 +++++++++++++++++++-------- src/Sys/SysModNetwork.cpp | 2 +- src/Sys/SysModUI.cpp | 2 +- src/Sys/SysModWeb.cpp | 11 ++++++----- 7 files changed, 30 insertions(+), 18 deletions(-) diff --git a/platformio.ini b/platformio.ini index ba7cd040..58155a8d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -29,7 +29,7 @@ build_flags = -D USERMOD_ARTNET -D USERMOD_DDP lib_deps = - https://github.com/FastLED/FastLED.git + https://github.com/FastLED/FastLED.git@3.6.0 [usermod_e131] build_flags = diff --git a/src/App/AppLeds.cpp b/src/App/AppLeds.cpp index 2d25f52d..a0f98755 100644 --- a/src/App/AppLeds.cpp +++ b/src/App/AppLeds.cpp @@ -131,7 +131,7 @@ void Leds::fixtureProjectAndMap() { //1024 crash in makebuffer... float scale = 1; if (size.x * size.y > 256) - scale = (sqrt((float)256.0 / (size.x * size.y))); //avoid very high virtual resolutions + scale = (sqrt((float)256.0 / (size.x * size.y))); //avoid high virtual resolutions size.x *= scale; size.y *= scale; x = (x+1) * scale - 1; diff --git a/src/App/AppLeds.h b/src/App/AppLeds.h index b7060a67..e672278e 100644 --- a/src/App/AppLeds.h +++ b/src/App/AppLeds.h @@ -69,7 +69,7 @@ class Leds { //track pins and leds uint8_t currPin; uint16_t prevLeds; - Coord3D startPos = {0,0,0}, endPos = {8,8,1}; //default + Coord3D startPos = {0,0,0}, endPos = {7,7,0}; //default float distance(uint16_t x1, uint16_t y1, uint16_t z1, uint16_t x2, uint16_t y2, uint16_t z2) { return sqrtf((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2)); diff --git a/src/App/AppModLeds.h b/src/App/AppModLeds.h index 8762e7e1..2bba43a6 100644 --- a/src/App/AppModLeds.h +++ b/src/App/AppModLeds.h @@ -141,28 +141,39 @@ class AppModLeds:public SysModule { }); currentVar["stage"] = true; - ui->initCoord3D(tableVar, "fxStart", 0, 0, 127, false, [](JsonObject var) { //uiFun + ui->initCoord3D(tableVar, "fxStart", UINT16_MAX, 0, 127, false, [](JsonObject var) { //uiFun web->addResponse(var["id"], "label", "Start"); }, [this](JsonObject var, uint8_t rowNr) { //chFun + leds.startPos = mdl->getValue(var, rowNr).as(); + + USER_PRINTF("fxStart %d %d %d - %d %d %d\n", leds.startPos.x, leds.startPos.y, leds.startPos.z, leds.endPos.x, leds.endPos.y, leds.endPos.z); + leds.fadeToBlackBy(); - leds.startPos = mdl->getValue(var, rowNr).as(); doMap = true; + }, nullptr, 1, [this](JsonObject var, uint8_t rowNr) { //valueFun + mdl->setValue(var, leds.startPos, rowNr); }); - ui->initCoord3D(tableVar, "fxEnd", 0, 0, 127, false, [](JsonObject var) { //uiFun + + ui->initCoord3D(tableVar, "fxEnd", UINT16_MAX, 0, 127, false, [](JsonObject var) { //uiFun web->addResponse(var["id"], "label", "End"); }, [this](JsonObject var, uint8_t rowNr) { //chFun + leds.endPos = mdl->getValue(var, rowNr).as(); + + USER_PRINTF("fxEnd %d %d %d - %d %d %d\n", leds.startPos.x, leds.startPos.y, leds.startPos.z, leds.endPos.x, leds.endPos.y, leds.endPos.z); + leds.fadeToBlackBy(); - leds.endPos = mdl->getValue(var, rowNr).as(); doMap = true; + }, nullptr, 1, [this](JsonObject var, uint8_t rowNr) { //valueFun + mdl->setValue(var, leds.endPos, rowNr); }); - ui->initCoord3D(tableVar, "fxSize", 0, 0, 127, true, [this](JsonObject var) { //uiFun + ui->initCoord3D(tableVar, "fxSize", UINT16_MAX, 0, 127, true, [this](JsonObject var) { //uiFun web->addResponse(var["id"], "label", "Size"); - web->addResponse(var["id"], "value", leds.size); + web->addResponse(var["id"], "value", leds.size); //value in uiFun is only send to the ui, not stored in model }); // , nullptr, nullptr, 1, [this](JsonObject var, uint8_t rowNr) { //valueFun // // char detail[32]; @@ -173,7 +184,7 @@ class AppModLeds:public SysModule { ui->initNumber(tableVar, "fxCount", UINT16_MAX, 0, UINT8_MAX, true, [this](JsonObject var) { //uiFun web->addResponse(var["id"], "label", "Count"); - // web->addResponse(var["id"], "value", leds.nrOfLeds); + // web->addResponse(var["id"], "value", leds.nrOfLeds); //value in uiFun is only send to the ui, not stored in model }, nullptr, nullptr, 1, [this](JsonObject var, uint8_t rowNr) { //valueFun mdl->setValue(var, leds.nrOfLeds, rowNr); }); @@ -206,7 +217,7 @@ class AppModLeds:public SysModule { } }); //fixture - ui->initCoord3D(parentVar, "fixSize", 0, 0, 127, true, [this](JsonObject var) { //uiFun + ui->initCoord3D(parentVar, "fixSize", UINT16_MAX, 0, 127, true, [this](JsonObject var) { //uiFun web->addResponse(var["id"], "label", "Size"); web->addResponse(var["id"], "value", leds.sizeP); }); diff --git a/src/Sys/SysModNetwork.cpp b/src/Sys/SysModNetwork.cpp index ede8f8fd..6056befc 100644 --- a/src/Sys/SysModNetwork.cpp +++ b/src/Sys/SysModNetwork.cpp @@ -45,7 +45,7 @@ void SysModNetwork::setup() { ui->initButton(parentVar, "connect", nullptr, false, [](JsonObject var) { //uiFun web->addResponse(var["id"], "comment", "Force reconnect (loose current connection)"); }, [this](JsonObject var, uint8_t) { //chFun - mdl->doWriteModel = true; //saves the model + // mdl->doWriteModel = true; //saves the model forceReconnect = true; }); ui->initText(parentVar, "nwstatus", nullptr, 32, true, [](JsonObject var) { //uiFun diff --git a/src/Sys/SysModUI.cpp b/src/Sys/SysModUI.cpp index 3cd566ef..9285eb7d 100644 --- a/src/Sys/SysModUI.cpp +++ b/src/Sys/SysModUI.cpp @@ -178,7 +178,7 @@ void SysModUI::setChFunAndWs(JsonObject var, uint8_t rowNr, const char * value) if (!var["chFun"].isNull()) {//isNull needed here! size_t funNr = var["chFun"]; if (funNr < cFunctions.size()) { - USER_PRINTF("chFun %s r:%d v:%s\n", var["id"].as(), rowNr, var["value"].as().c_str()); + USER_PRINTF("chFun %s[%d] <- %s\n", var["id"].as(), rowNr, var["value"].as().c_str()); cFunctions[funNr](var, rowNr); } else diff --git a/src/Sys/SysModWeb.cpp b/src/Sys/SysModWeb.cpp index a82f7cd7..021f0c72 100644 --- a/src/Sys/SysModWeb.cpp +++ b/src/Sys/SysModWeb.cpp @@ -349,12 +349,13 @@ void SysModWeb::sendDataWs(std::function fi for (auto loopClient:ws->getClients()) { if (!client || client == loopClient) { - if (loopClient->status() == WS_CONNECTED && !loopClient->queueIsFull() && (!isBinary || loopClient->queueLength() <= WS_MAX_QUEUED_MESSAGES / web->ws->count() / 2)) { //binary is lossy + if (loopClient->status() == WS_CONNECTED && !loopClient->queueIsFull() && (!isBinary || loopClient->queueLength() <= 3)) { //WS_MAX_QUEUED_MESSAGES / ws->count() / 2)) { //binary is lossy isBinary?loopClient->binary(wsBuf): loopClient->text(wsBuf); sendDataWsCounter++; } else { - print->printClient("sendDataWs client full or not connected\n", loopClient); + print->printClient("sendDataWs client full or not connected", loopClient); //causes crash + // USER_PRINTF("sendDataWs client full or not connected\n"); // ws->cleanupClients(); //only if above threshold // ws->_cleanBuffers(); } @@ -365,9 +366,9 @@ void SysModWeb::sendDataWs(std::function fi } else { USER_PRINT_Async("sendDataWs WS buffer allocation failed\n"); - ws->_cleanBuffers(); - ws->cleanupClients(0); //disconnect ALL clients to release memory ws->closeAll(1013); //code 1013 = temporary overload, try again later + ws->cleanupClients(0); //disconnect ALL clients to release memory + ws->_cleanBuffers(); } } @@ -387,7 +388,7 @@ bool SysModWeb::addURL(const char * uri, const char * contentType, const char * if (strcmp(uri, "/") == 0) { - if (captivePortal(request)) return; + // if (captivePortal(request)) return; // if (handleIfNoneMatchCacheHeader(request)) return;