Skip to content

Commit

Permalink
Live scripts: if script changed: kill firtst and execute new script a…
Browse files Browse the repository at this point in the history
…s task
  • Loading branch information
ewoudwijma committed Jun 29, 2024
1 parent d01e949 commit b0ef128
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Sys/SysModUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class SysModUI: public SysModule {
//only print vars with a value and not onSetValue as that changes a lot due to insTbl clTbl etc (tbd)
// if (!var["value"].isNull() &&
if (funType != onSetValue) {
ppf("%sFun %s", funType==onSetValue?"val":funType==onUI?"ui":funType==onChange?"ch":funType==onAddRow?"add":funType==onDeleteRow?"del":"other", mdl->varID(var));
ppf("on%s %s", funType==onSetValue?"SetValue":funType==onUI?"UI":funType==onChange?"Change":funType==onAddRow?"Add":funType==onDeleteRow?"Del":"Other", mdl->varID(var));
if (rowNr != UINT8_MAX) {
ppf("[%d] (", rowNr);
if (funType == onChange) ppf("%s ->", var["oldValue"][rowNr].as<String>().c_str());
Expand Down
13 changes: 9 additions & 4 deletions src/User/UserModLive.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,19 @@ class UserModLive:public SysModule {
//set script
uint8_t fileNr = var["value"];

if (fileNr > 0) {
SCExecutable._kill(); //kill any old tasks

ppf("%s script f:%d f:%d\n", name, funType, fileNr);

if (fileNr > 0) { //not None

fileNr--; //-1 as none is no file

char fileName[32] = "";

files->seqNrToName(fileName, fileNr, ".sc");

ppf("%s script f:%d f:%d\n", name, funType, fileNr);
// ppf("%s script f:%d f:%d\n", name, funType, fileNr);

if (strcmp(fileName, "") != 0) {

Expand All @@ -93,11 +97,10 @@ class UserModLive:public SysModule {

if (p.parse_c(&script))
{
SCExecutable.execute("main");
SCExecutable.executeAsTask("main");
}
f.close();
}

}
else
ppf("UserModLive setup file for %d not found", fileNr);
Expand All @@ -106,6 +109,8 @@ class UserModLive:public SysModule {
default: return false;
}}); //fixture

// ui->initButton

addExternal("show1", externalType::function, (void *)&show1);
addExternal("show2", externalType::function, (void *)&show2);

Expand Down
2 changes: 1 addition & 1 deletion src/User/UserModMPU6050.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class UserModMPU6050: public SysModule {
VectorFloat gravityVector;

UserModMPU6050() :SysModule("Motion Tracking") {
// isEnabled = false;
isEnabled = false; //need to explicitly start it in Modules Panel
};

void setup() {
Expand Down

0 comments on commit b0ef128

Please sign in to comment.