Skip to content

Commit

Permalink
genHTML: set value in changeHTML, extend variable properties
Browse files Browse the repository at this point in the history
app.js: save canvasNode.className

index.js
- remove savedData -> store in variable

index.js: changeHTML
- remove varValue -> call changeHTML to set Value:
- if uiFun changeHTML value and push uiFun
- else changeHTML variable (set node value and also label, comment, options etc)

index.js: receiveData variable
- call changeHTML on variable node and table rows

index.js: changeHTML
- use node.className
- store commandjson properties in variable (instead of savedData)
- add if nodetype = th (column vars) (WIP, not used yet)
- value table: check if value is array, otherwise log (not occurring)

initVar set default value uint16Max instead of -1
- AppModLeds, SysModFiles, SysModPins,E131, Instances
  • Loading branch information
ewowi committed Jan 9, 2024
1 parent a0555c3 commit 226c0e5
Show file tree
Hide file tree
Showing 12 changed files with 1,433 additions and 1,407 deletions.
1 change: 1 addition & 0 deletions data/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function userFun(userFunId, data) {
let canvasNode = cE("canvas");
canvasNode.width = pviewNode.width;
canvasNode.height = pviewNode.height;
canvasNode.className = pviewNode.className;
canvasNode.draggable = true;
canvasNode.addEventListener('dragstart', (event) => {event.preventDefault(); event.stopPropagation();});

Expand Down
353 changes: 183 additions & 170 deletions data/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/App/AppEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ class Effects {
}
else
parentVar.remove("n"); //tbd: we should also remove the uiFun and chFun !!
//tbd: we need to reuse the values set...

Effect* effect = effects[ledsV.fx];
effect->controls(parentVar);
Expand Down
11 changes: 9 additions & 2 deletions src/App/AppModLeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class AppModLeds:public SysModule {
currentVar["log"] = true; //logarithmic
currentVar["stage"] = true; //these values override model.json???

ui->initCanvas(parentVar, "pview", -1, false, [](JsonObject var) { //uiFun
ui->initCanvas(parentVar, "pview", uint16Max, false, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Preview");
web->addResponse(var["id"], "comment", "Shows the fixture");
// web->addResponse(var["id"], "comment", "Click to enlarge");
Expand Down Expand Up @@ -109,7 +109,7 @@ class AppModLeds:public SysModule {
// }
}

print->printJson("fxTbl values", rows);
// print->printJson("fxTbl values", rows);
});

currentVar = ui->initSelect(parentVar, "fx", 0, false, [this](JsonObject var) { //uiFun
Expand Down Expand Up @@ -137,6 +137,13 @@ class AppModLeds:public SysModule {
select.add("Multiply"); //6
select.add("Kaleidoscope"); //7
select.add("Fun"); //8

//set default value (array)
// if (!var["value"].isNull()) {
// JsonArray value = web->addResponseA(var["id"], "value");
// value.add(1);
// value.add(2);
// }
}, [this](JsonObject var, uint8_t rowNr) { //chFun

ledsV.projectionNr = mdl->varToValue(var, rowNr);
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void SysModFiles::setup() {
ui->initText(tableVar, "flName", nullptr, 32, true, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Name");
});
ui->initNumber(tableVar, "flSize", -1, 0, uint16Max, true, [](JsonObject var) { //uiFun
ui->initNumber(tableVar, "flSize", uint16Max, 0, uint16Max, true, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Size (B)");
});
ui->initURL(tableVar, "flLink", nullptr, true, [](JsonObject var) { //uiFun
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModPins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void SysModPins::setup() {
web->addResponse(var["id"], "label", "Details");
});

ui->initCanvas(parentVar, "board", -1, true, [](JsonObject var) { //uiFun
ui->initCanvas(parentVar, "board", uint16Max, true, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Board layout");
web->addResponse(var["id"], "comment", "WIP");
}, nullptr, [](JsonObject var, uint8_t* buffer) { //loopFun
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ JsonObject SysModUI::initVar(JsonObject parent, const char * id, const char * ty

//create new var
if (differentParents || var.isNull()) {
USER_PRINTF("initVar create new %s: %s->%s\n", type, parentId, id);
USER_PRINTF("initVar create new %s var: %s->%s\n", type, parentId, id);
if (parent.isNull()) {
JsonArray vars = mdl->model->as<JsonArray>();
var = vars.createNestedObject();
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class SysModUI:public SysModule {

//no call of fun for buttons otherwise all buttons will be fired which is highly undesirable
if (strcmp(type,"button") != 0 && chFun && (!isPointer || value)) { //!isPointer because 0 is also a value then
USER_PRINTF("chFun init %s v:%s\n", var["id"].as<const char *>(), var["value"].as<String>());
USER_PRINTF("initVarAndUpdate chFun init %s v:%s\n", var["id"].as<const char *>(), var["value"].as<String>());
if (var["value"].is<JsonArray>()) {
int rowNr = 0;
for (JsonVariant val:var["value"].as<JsonArray>()) {
Expand Down
2 changes: 1 addition & 1 deletion src/SysModules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void SysModules::setup() {
else {
USER_PRINTF(" no rowNr!!");
}
print->printJson(" ", var);
// print->printJson(" ", var);

});
}
Expand Down
6 changes: 3 additions & 3 deletions src/User/UserModE131.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ class UserModE131:public SysModule {
row.add(varToWatch.savedValue);
}
});
ui->initNumber(tableVar, "e131Channel", -1, 1, 512, true, [](JsonObject var) { //uiFun
ui->initNumber(tableVar, "e131Channel", uint16Max, 1, 512, true, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Channel");
});
ui->initText(tableVar, "e131Name", nullptr, 32, true, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Name");
});
ui->initNumber(tableVar, "e131Max", -1, 0, uint16Max, true, [](JsonObject var) { //uiFun
ui->initNumber(tableVar, "e131Max", uint16Max, 0, uint16Max, true, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Max");
});
ui->initNumber(tableVar, "e131Value", -1, 0, 255, true, [](JsonObject var) { //uiFun
ui->initNumber(tableVar, "e131Value", uint16Max, 0, 255, true, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Value");
});

Expand Down
6 changes: 3 additions & 3 deletions src/User/UserModInstances.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ class UserModInstances:public SysModule {
ui->initText(tableVar, "insType", nullptr, 16, true, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Type");
});
ui->initNumber(tableVar, "insVersion", -1, 0, (unsigned long)-1, true, [](JsonObject var) { //uiFun
ui->initNumber(tableVar, "insVersion", uint16Max, 0, (unsigned long)-1, true, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Version");
});
ui->initNumber(tableVar, "insUp", -1, 0, (unsigned long)-1, true, [](JsonObject var) { //uiFun
ui->initNumber(tableVar, "insUp", uint16Max, 0, (unsigned long)-1, true, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Uptime");
});
// ui->initNumber(tableVar, "insTime", -1, 0, (unsigned long)-1, true, [](JsonObject var) { //uiFun
// ui->initNumber(tableVar, "insTime", uint16Max, 0, (unsigned long)-1, true, [](JsonObject var) { //uiFun
// web->addResponse(var["id"], "label", "Timestamp");
// });

Expand Down
Loading

0 comments on commit 226c0e5

Please sign in to comment.