Skip to content

Commit

Permalink
Live scripts: version 2.5 to 2.7 (multiple scripts)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoudwijma committed Oct 4, 2024
1 parent 8404d99 commit d090d6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build_flags =
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1 ;tbd experiment without
;-D CONFIG_ASYNC_TCP_TASK_STACK_SIZE ; 8192*2 here as default !!!
lib_deps =
https://github.com/MoonModules/ESPAsyncWebServer.git @ 3.2.2 ; + queueLength (see https://github.com/esphome/ESPAsyncWebServer/pull/38)
https://github.com/MoonModules/ESPAsyncWebServer.git @ 3.2.2 ; + queueLen(gth) (see https://github.com/esphome/ESPAsyncWebServer/pull/38)
; https://github.com/mathieucarbou/ESPAsyncWebServer.git @ 3.3.5 ; WIP...

; ESPAsyncWebServer AirCoookie v2.0.7 version (2.2.1 is latest)
Expand Down Expand Up @@ -70,7 +70,7 @@ lib_deps =
build_flags =
-D STARBASE_USERMOD_LIVE
lib_deps =
https://github.com/hpwit/ASMParser.git#v2.5 ;0.0.1+sha.d1fed6d 20240904
https://github.com/hpwit/ASMParser.git#v2.7 ;2.7 supports multiple scripts running at the same time

[STARBASE]
build_flags =
Expand Down
21 changes: 12 additions & 9 deletions src/User/UserModLive.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ class UserModLive:public SysModule {
addExternalVal("uint8_t", "slider2", &slider2); //used in map function
addExternalVal("uint8_t", "slider3", &slider3); //used in map function

// runningPrograms.setPrekill(pre, post); //for clockless driver...
runningPrograms.setFunctionToSync(show);

} //setup

void addExternalVal(string result, string name, void * ptr) {
Expand Down Expand Up @@ -221,7 +224,7 @@ class UserModLive:public SysModule {
}

void loop() {
if (__run_handle) { //isRunning
if (myexec.isRunning()) {
if (loopState == 2) {// show has been called (in other loop)
loopState = 0; //waiting on live script
// ppf("loopState %d\n", loopState);
Expand All @@ -240,14 +243,12 @@ class UserModLive:public SysModule {
if (strncmp(this->fileName, web->lastFileUpdated+4, sizeof(this->fileName)) == 0) { //+4 remove del:
ppf("loop20ms kill %s\n", web->lastFileUpdated);
kill();
// ui->callVarFun("script2", UINT8_MAX, onUI); //rebuild options
}
//else nothing
}
else {
ppf("loop20ms run %s -> %s\n", this->fileName, web->lastFileUpdated);
run(web->lastFileUpdated);
// ui->callVarFun("script2", UINT8_MAX, onUI); //rebuild options
}
strlcpy(web->lastFileUpdated, "", sizeof(web->lastFileUpdated));
}
Expand Down Expand Up @@ -280,17 +281,19 @@ class UserModLive:public SysModule {

scScript += string(f.readString().c_str()); // add sc file

scScript += "void main(){resetStat();setup();while(2>1){loop();show();}}";
scScript += "void main(){resetStat();setup();while(2>1){loop();show();}}"; //add main which calls setup and loop

ppf("Before parsing of %s\n", fileName);
ppf("%s:%d f:%d / t:%d (l:%d) B [%d %d]\n", __FUNCTION__, __LINE__, ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getMaxAllocHeap(), esp_get_free_heap_size(), esp_get_free_internal_heap_size());

if (p.parseScript(&scScript))
myexec = p.parseScript(&scScript);

if (myexec.exeExist)
{
ppf("parsing %s done\n", fileName);
ppf("%s:%d f:%d / t:%d (l:%d) B [%d %d]\n", __FUNCTION__, __LINE__, ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getMaxAllocHeap(), esp_get_free_heap_size(), esp_get_free_internal_heap_size());

SCExecutable.executeAsTask("main"); //"setup" not working
myexec.executeAsTask("main");
// ppf("setup done\n");
strlcpy(this->fileName, fileName, sizeof(this->fileName));
}
Expand All @@ -302,9 +305,9 @@ class UserModLive:public SysModule {
}

void kill() {
if (__run_handle) { //isRunning
if (myexec.isRunning()) {
ppf("kill %s\n", fileName);
SCExecutable._kill(); //kill any old tasks
myexec._kill();
fps = 0;
strlcpy(fileName, "", sizeof(fileName));
}
Expand All @@ -315,4 +318,4 @@ class UserModLive:public SysModule {
extern UserModLive *liveM;


//asm_parser.h:325:1: warning: control reaches end of non-void function
//asm_parser.h:393:1: warning: control reaches end of non-void function

0 comments on commit d090d6d

Please sign in to comment.