Skip to content

Commit

Permalink
Merge remote-tracking branch 'ewowi/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoudwijma committed Jun 26, 2024
2 parents 595770f + 7f54753 commit 1929652
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 68 deletions.
2 changes: 1 addition & 1 deletion data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ function receiveData(json) {

if (variable) {
let rowNr = value.rowNr == null?UINT8_MAX:value.rowNr;
// if (variable.id == "fxEnd" || variable.id == "fxSize" || variable.id == "point")
// if (variable.id == "ledsEnd" || variable.id == "ledsSize" || variable.id == "point")
// ppf("receiveData ", variable, value);
variable.fun = -2; // request processed

Expand Down
8 changes: 4 additions & 4 deletions data/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"max": 255,
"n": [
{
"id": "fxTbl",
"id": "ledsTbl",
"type": "table",
"ro": false,
"o": 14,
Expand Down Expand Up @@ -223,7 +223,7 @@
]
},
{
"id": "fxStart",
"id": "ledsStart",
"type": "coord3D",
"ro": false,
"o": 22,
Expand All @@ -237,7 +237,7 @@
]
},
{
"id": "fxEnd",
"id": "ledsEnd",
"type": "coord3D",
"ro": false,
"o": 23,
Expand All @@ -251,7 +251,7 @@
]
},
{
"id": "fxSize",
"id": "ledsSize",
"type": "text",
"ro": true,
"o": 24,
Expand Down
11 changes: 4 additions & 7 deletions src/Sys/SysModFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ void SysModFiles::setup() {
default: return false;
}});

ui->initProgress(parentVar, "drsize", UINT16_MAX, 0, files->totalBytes(), true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue:
mdl->setValue(var, files->usedBytes());
return true;
ui->initProgress(parentVar, "drsize", files->usedBytes(), 0, files->totalBytes(), true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onUI:
ui->setLabel(var, "FS Size");
return true;
Expand Down Expand Up @@ -131,15 +128,15 @@ void SysModFiles::loop() {
}
root.close();

ui->callVarFun("drsize");
mdl->setValue("drsize", files->usedBytes());

for (JsonObject childVar: mdl->varChildren("fileTbl"))
ui->callVarFun(childVar);
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)
}
}

void SysModFiles::loop10s() {
ui->callVarFun("drsize");
mdl->setValue("drsize", files->usedBytes());
}

bool SysModFiles::remove(const char * path) {
Expand Down
8 changes: 4 additions & 4 deletions src/Sys/SysModInstances.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ class SysModInstances:public SysModule {

ppf("insTbl handleNotifications %d\n", notifierUdp.remoteIP()[3]);
for (JsonObject childVar: mdl->varChildren("insTbl"))
ui->callVarFun(childVar); //rowNr //instance - instances.begin()
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP) ); //rowNr //instance - instances.begin()

web->recvUDPCounter++;
web->recvUDPBytes+=packetSize;
Expand Down Expand Up @@ -558,7 +558,7 @@ class SysModInstances:public SysModule {
if (erased) {
ppf("insTbl remove inactive instances\n");
for (JsonObject childVar: mdl->varChildren("insTbl"))
ui->callVarFun(childVar); //no rowNr so all rows updated
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)); //no rowNr so all rows updated

ui->callVarFun("ddpInst", UINT8_MAX, onUI); //rebuild options
ui->callVarFun("artInst", UINT8_MAX, onUI); //rebuild options
Expand Down Expand Up @@ -796,7 +796,7 @@ class SysModInstances:public SysModule {
// ppf("updateInstance updRow\n");

for (JsonObject childVar: mdl->varChildren("insTbl"))
ui->callVarFun(childVar); //rowNr instance - instances.begin()
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)); //rowNr instance - instances.begin()

//tbd: now done for all rows, should be done only for updated rows!
}
Expand All @@ -816,7 +816,7 @@ class SysModInstances:public SysModule {
// for (std::vector<InstanceInfo>::iterator instance=instances.begin(); instance!=instances.end(); ++instance) {
// if (instance->ip == messageIP) {
for (JsonObject childVar: mdl->varChildren("insTbl")) {
ui->callVarFun(childVar); //no rowNr, update all
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)); //no rowNr, update all
}
// }
// }
Expand Down
27 changes: 14 additions & 13 deletions src/Sys/SysModModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,20 @@ void SysModModel::findVars(const char * property, bool value, FindFun fun, JsonA
}
}

void SysModModel::varToValues(JsonObject var, JsonArray row) {

//add value for each child
// JsonArray row = rows.add<JsonArray>();
for (JsonObject childVar : var["n"].as<JsonArray>()) {
print->printJson("fxTbl childs", childVar);
row.add(childVar["value"]);

if (!childVar["n"].isNull()) {
varToValues(childVar, row.add<JsonArray>());
}
}
}
//currently not used
// void SysModModel::varToValues(JsonObject var, JsonArray row) {

// //add value for each child
// // JsonArray row = rows.add<JsonArray>();
// for (JsonObject childVar : var["n"].as<JsonArray>()) {
// print->printJson("varToValues childs", childVar);
// row.add(childVar["value"]);

// if (!childVar["n"].isNull()) {
// varToValues(childVar, row.add<JsonArray>());
// }
// }
// }

bool checkDash(JsonObject var) {
if (var["dash"])
Expand Down
4 changes: 2 additions & 2 deletions src/Sys/SysModModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ class SysModModel:public SysModule {
JsonObject findParentVar(const char * id, JsonObject parent = JsonObject());
void findVars(const char * id, bool value, FindFun fun, JsonArray parent = JsonArray());

//recursively add values in a variant
void varToValues(JsonObject var, JsonArray values);
//recursively add values in a variant, currently not used
// void varToValues(JsonObject var, JsonArray values);

//sends dash var change to udp (if init), sets pointer if pointer var and run onChange
bool callVarChangeFun(JsonObject var, unsigned8 rowNr = UINT8_MAX, bool init = false);
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModPins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void SysModPins::loop() {
pinsChanged = false;

for (JsonObject childVar: mdl->varChildren("pinTbl"))
ui->callVarFun(childVar);
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)
}
}

Expand Down
29 changes: 9 additions & 20 deletions src/Sys/SysModSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ void SysModSystem::setup() {
print->fFormat(chipInfo, sizeof(chipInfo)-1, "%s %s (%d.%d.%d) c#:%d %d mHz f:%d KB %d mHz %d", ESP.getChipModel(), ESP.getSdkVersion(), ESP_ARDUINO_VERSION_MAJOR, ESP_ARDUINO_VERSION_MINOR, ESP_ARDUINO_VERSION_PATCH, ESP.getChipCores(), ESP.getCpuFreqMHz(), ESP.getFlashChipSize()/1024, ESP.getFlashChipSpeed()/1000000, ESP.getFlashChipMode());
ui->initText(parentVar, "chip", chipInfo, 16, true);

ui->initProgress(parentVar, "heap", UINT16_MAX, 0, ESP.getHeapSize()/1000, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue:
mdl->setValue(var, (ESP.getHeapSize()-ESP.getFreeHeap()) / 1000);
return true;
ui->initProgress(parentVar, "heap", (ESP.getHeapSize()-ESP.getFreeHeap()) / 1000, 0, ESP.getHeapSize()/1000, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onChange:
var["max"] = ESP.getHeapSize()/1000; //makes sense?
web->addResponseV(var["id"], "comment", "f:%d / t:%d (l:%d) B", ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getMaxAllocHeap());
Expand All @@ -109,10 +106,7 @@ void SysModSystem::setup() {
}});

if (psramFound()) {
ui->initProgress(parentVar, "psram", UINT16_MAX, 0, ESP.getPsramSize()/1000, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue:
mdl->setValue(var, (ESP.getPsramSize()-ESP.getFreePsram()) / 1000);
return true;
ui->initProgress(parentVar, "psram", (ESP.getPsramSize()-ESP.getFreePsram()) / 1000, 0, ESP.getPsramSize()/1000, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onChange:
var["max"] = ESP.getPsramSize()/1000; //makes sense?
web->addResponseV(var["id"], "comment", "%d / %d (%d) B", ESP.getFreePsram(), ESP.getPsramSize(), ESP.getMinFreePsram());
Expand All @@ -121,23 +115,18 @@ void SysModSystem::setup() {
}});
}

ui->initProgress(parentVar, "mainStack", UINT16_MAX, 0, getArduinoLoopTaskStackSize(), true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue:
mdl->setValue(var, sysTools_get_arduino_maxStackUsage());
return true;
ui->initProgress(parentVar, "mainStack", sysTools_get_arduino_maxStackUsage(), 0, getArduinoLoopTaskStackSize(), true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onUI:
ui->setLabel(var, "Main stack");
return true;
case onChange:
var["max"] = getArduinoLoopTaskStackSize(); //makes sense?
web->addResponseV(var["id"], "comment", "%d of %d B", sysTools_get_arduino_maxStackUsage(), getArduinoLoopTaskStackSize());
return true;
default: return false;
}});

ui->initProgress(parentVar, "tcpStack", UINT16_MAX, 0, CONFIG_ASYNC_TCP_TASK_STACK_SIZE, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue:
mdl->setValue(var, sysTools_get_webserver_maxStackUsage());
return true;
ui->initProgress(parentVar, "tcpStack", sysTools_get_webserver_maxStackUsage(), 0, CONFIG_ASYNC_TCP_TASK_STACK_SIZE, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onUI:
ui->setLabel(var, "TCP stack");
return true;
Expand Down Expand Up @@ -237,12 +226,12 @@ void SysModSystem::loop1s() {
loopCounter = 0;
}
void SysModSystem::loop10s() {
ui->callVarFun("heap");
ui->callVarFun("mainStack");
ui->callVarFun("tcpStack");
mdl->setValue("heap", (ESP.getHeapSize()-ESP.getFreeHeap()) / 1000);
mdl->setValue("mainStack", sysTools_get_arduino_maxStackUsage());
mdl->setValue("tcpStack", sysTools_get_webserver_maxStackUsage());

if (psramFound()) {
ui->callVarFun("psram");
mdl->setValue("psram", (ESP.getPsramSize()-ESP.getFreePsram()) / 1000);
}

//heartbeat
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void SysModUI::loop() {

void SysModUI::loop1s() {
//if something changed in vloops
callVarFun("vlLoopps");
callVarFun("vlLoopps", UINT8_MAX, onSetValue); //set the value (WIP)
for (VarLoop &varLoop : loopFunctions)
varLoop.counter = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class SysModUI: public SysModule {
JsonArray setOptions(JsonObject var) {
return web->addResponseA(var["id"], "options");
}
//return the options from onSetValue (don't forget to clear responseObject)
//return the options from onUI (don't forget to clear responseObject)
JsonArray getOptions(JsonObject var) {
callVarFun(var, UINT8_MAX, onUI); //rebuild options
return web->getResponseObject()[mdl->varID(var)]["options"];
Expand Down
4 changes: 2 additions & 2 deletions src/Sys/SysModWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ void SysModWeb::loop() {

// ppf("SysModWeb clientsChanged\n");
for (JsonObject childVar: mdl->varChildren("clTbl"))
ui->callVarFun(childVar);
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)
}

}

void SysModWeb::loop1s() {
for (JsonObject childVar: mdl->varChildren("clTbl"))
ui->callVarFun(childVar);
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)

mdl->setUIValueV("wsSend", "#: %d /s T: %d B/s B:%d B/s", sendWsCounter, sendWsTBytes, sendWsBBytes);
sendWsCounter = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/User/UserModE131.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class UserModE131:public SysModule {
return true;
case onChange:
for (JsonObject childVar: mdl->varChildren("e131Tbl"))
ui->callVarFun(childVar);
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)
return true;
default: return false;
}});
Expand Down
Loading

0 comments on commit 1929652

Please sign in to comment.