From e0cdeb1254b3230c222d03c486fb82fb2285beff Mon Sep 17 00:00:00 2001 From: Ewoud Date: Thu, 11 Jul 2024 12:17:07 +0200 Subject: [PATCH] SysModWeb: serveUpload - if upload succes set lastFileUpdated UserModLive: loop20ms - if lastFileUpdated constains .sc run file --- src/Sys/SysModWeb.cpp | 13 +++++++++---- src/Sys/SysModWeb.h | 4 ++++ src/User/UserModLive.h | 8 ++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Sys/SysModWeb.cpp b/src/Sys/SysModWeb.cpp index 7273e7c6..cf94edad 100644 --- a/src/Sys/SysModWeb.cpp +++ b/src/Sys/SysModWeb.cpp @@ -17,6 +17,7 @@ #include "SysModPins.h" #include "User/UserModMDNS.h" +// got multiple definition error here ??? see workaround below // #ifdef STARBASE_USERMOD_LIVE // #include "../User/UserModLive.h" // #endif @@ -505,10 +506,14 @@ void SysModWeb::serveUpload(WebRequest *request, const String& filename, size_t files->filesChanged = true; //if sc files send command to live - // #ifdef STARBASE_USERMOD_LIVE - // if (filename.indexOf(".sc") > 0) - // liveM->run(filename.c_str()); - // #endif + #ifdef STARBASE_USERMOD_LIVE + + strcpy(lastFileUpdated, filename.c_str()); //workaround + + // got multiple definition error here ??? + // if (filename.indexOf(".sc") > 0) + // liveM->run(filename.c_str()); + #endif } } diff --git a/src/Sys/SysModWeb.h b/src/Sys/SysModWeb.h index 5e8ae4a1..1051cd88 100644 --- a/src/Sys/SysModWeb.h +++ b/src/Sys/SysModWeb.h @@ -57,6 +57,10 @@ class SysModWeb:public SysModule { unsigned8 recvUDPCounter = 0; unsigned16 recvUDPBytes = 0; + #ifdef STARBASE_USERMOD_LIVE + char lastFileUpdated[30] = ""; //workaround! + #endif + SysModWeb(); void setup(); diff --git a/src/User/UserModLive.h b/src/User/UserModLive.h index 73b25bab..21dfaf78 100644 --- a/src/User/UserModLive.h +++ b/src/User/UserModLive.h @@ -160,6 +160,14 @@ class UserModLive:public SysModule { time1 = ESP.getCycleCount(); } + void loop20ms() { + //workaround + if (strstr(web->lastFileUpdated, ".sc") != nullptr) { + run(web->lastFileUpdated); + strcpy(web->lastFileUpdated, ""); + } + } + void loop1s() { mdl->setUIValueV("fps1", "%.0f /s", fps); mdl->setUIValueV("fps2", "%d /s", frameCounter);