Skip to content

Commit

Permalink
Fix deleteRow, ledsList to pointerlist, fix Leds cons/destructor
Browse files Browse the repository at this point in the history
index.htm / main.cpp
- add AI (WIP)

index.js
- add varRemoveValuesForRow and use in delRow
- receiveData value: check for rowNr (WIP)
- changeHTML Coord3D: check if value is array (e.g. for pro/point)

AppEffects:
- set contextRowNr in pre/postDetails

AppFixture / AppModLeds
- ledsList: change to vector of pointer to Leds and use  for (Leds *leds: ledsList)
- bugfix in case there are no Leds in ledsList

SysModModel:
- add varRemoveValuesForRow
- set contextRowNr in pre/postDetails

SysModUI: delRow: call varRemoveValuesForRow
  • Loading branch information
ewowi committed Feb 28, 2024
1 parent cbeef13 commit b1d0795
Show file tree
Hide file tree
Showing 19 changed files with 1,889 additions and 1,707 deletions.
3 changes: 2 additions & 1 deletion data/index.htm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
@title StarMod
@file index.htm
@date 20240226
@date 20240228
@repo https://github.com/ewowi/StarMod
@Authors https://github.com/ewowi/StarMod/commits/main
@Copyright © 2024 Github StarMod Commit Authors
Expand Down Expand Up @@ -41,6 +41,7 @@ <h2><div id="instanceName"></div></h2>
<input type="button" value="User" id="vUser" onclick="setView(this)">
<input type="button" value="System" id="vSys" onclick="setView(this)">
<input type="button" value="All" id="vAll" onclick="setView(this)">
<input type="button" value="AI" id="vAI" onclick="setView(this)">
<span> | </span>
<input type="button" value="Save" id="bSave" onclick="saveModel(this)">
<span> | </span>
Expand Down
73 changes: 51 additions & 22 deletions data/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @title StarMod
// @file index.css
// @date 20240226
// @date 20240228
// @repo https://github.com/ewowi/StarMod
// @Authors https://github.com/ewowi/StarMod/commits/main
// @Copyright © 2024 Github StarMod Commit Authors
Expand Down Expand Up @@ -496,6 +496,17 @@ function genTableRowHTML(json, parentNode = null, rowNr = UINT8_MAX) {
setInstanceTableColumns();
}

function varRemoveValuesForRow(variable, rowNr) {
if (variable.n) {
for (let childVar of variable.n) {
if (Array.isArray(childVar.value)) {
childVar.value.splice(rowNr);
}
varRemoveValuesForRow(childVar, rowNr);
}
}
}

//process json from server, json is assumed to be an object
function receiveData(json) {
// console.log("receiveData", json);
Expand All @@ -510,6 +521,9 @@ function receiveData(json) {
if (key == "uiFun") {
console.log("receiveData no action", key, value); //should not happen anymore
}
else if (key == "aiButton") {
console.log("receiveData", key, value);
}
else if (key == "view") {
console.log("receiveData", key, value);
changeHTMLView(value);
Expand Down Expand Up @@ -565,10 +579,14 @@ function receiveData(json) {
let tableVar = findVar(tableId);
let rowNr = value.rowNr;

//delete the row here as well...

let tableNode = gId(tableId);

tableNode.deleteRow(rowNr + 1); //header counts as 0

varRemoveValuesForRow(tableVar, rowNr);

console.log("delRow ", tableVar, tableNode, rowNr);

} else if (key == "updRow") { //update the row of a table
Expand All @@ -594,12 +612,13 @@ function receiveData(json) {
let variable = findVar(key);

if (variable) {
// if (variable.id == "fixFirst" || variable.id == "fixRowEnd" || variable.id == "fixColEnd")
let rowNr = value.rowNr == null?UINT8_MAX:value.rowNr;
// if (variable.id == "fxEnd" || variable.id == "fxSize" || variable.id == "point")
// console.log("receiveData ", variable, value);
variable.fun = -2; // request processed

value.chk = "uiFun";
changeHTML(variable, value); //changeHTML will find the rownumbers if needed
changeHTML(variable, value, rowNr); //changeHTML will find the rownumbers if needed
}
else
console.log("receiveData key is no variable", key, value);
Expand Down Expand Up @@ -825,28 +844,35 @@ function changeHTML(variable, commandJson, rowNr = UINT8_MAX) {
if (commandJson.value) node.value = commandJson.value; //else the id / label is used as button label
}
else if (node.className == "coord3D") {
// console.log("chHTML value coord3D", node, commandJson.value, rowNr);

if (commandJson.value && Object.keys(commandJson.value)) { //tbd: support arrays (now only objects)
if (variable.ro) {
let sep = "";
node.textContent = "";
for (let key of Object.keys(commandJson.value)) {
node.textContent += sep + commandJson.value[key];
sep = ",";
console.log("chHTML value coord3D", node, commandJson.value, rowNr);

if (commandJson.value) {
//tbd: support Coord3D as array (now only objects work)
let value = commandJson.value;
if (Array.isArray(commandJson.value) && rowNr != UINT8_MAX)
value = commandJson.value[rowNr];

if (Object.keys(value)) {
if (variable.ro) {
let sep = "";
node.textContent = "";
for (let key of Object.keys(value)) {
node.textContent += sep + value[key];
sep = ",";
}
}
}
else {
let index = 0;
for (let key of Object.keys(commandJson.value)) {
let childNode = node.childNodes[index++];
childNode.value = commandJson.value[key];
childNode.dispatchEvent(new Event("input")); // triggers addEventListener('input',...). now only used for input type range (slider), needed e.g. for qlc+ input
else {
let index = 0;
for (let key of Object.keys(value)) {
let childNode = node.childNodes[index++];
childNode.value = value[key];
childNode.dispatchEvent(new Event("input")); // triggers addEventListener('input',...). now only used for input type range (slider), needed e.g. for qlc+ input
}
}
}
else
console.log(" dev value coord3D value not object[x,y,z]", variable.id, node.id, commandJson.value);
}
else
console.log(" value coord3D value not object[x,y,z]", variable.id, node.id, commandJson.value);
}
else if (node.className == "select") {
if (variable.ro) {
Expand Down Expand Up @@ -1278,6 +1304,7 @@ function changeHTMLView(value) {

// console.log("changeHTMLView", node, node.value, node.id, mdlContainerNode, mdlContainerNode.childNodes);

gId("vAI").classList.remove("selected");
gId("vApp").classList.remove("selected");
gId("vStage").classList.remove("selected");
gId("vUser").classList.remove("selected");
Expand All @@ -1297,9 +1324,11 @@ function changeHTMLView(value) {
else {
for (let moduleNode of divNode.childNodes) {
if (moduleNode.className) {
if (value=="vAI" && moduleNode.id == "AI")
found = true;
if (value=="vApp" && moduleNode.className == "appmod")
found = true;
if (value=="vSys" && moduleNode.className == "sysmod")
if (value=="vSys" && moduleNode.className == "sysmod")
found = true;
if (value=="vUser" && moduleNode.className == "usermod")
found = true;
Expand Down
11 changes: 4 additions & 7 deletions src/App/AppEffects.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
@title StarMod
@file AppEffects.h
@date 20240227
@date 20240228
@repo https://github.com/ewowi/StarMod
@Authors https://github.com/ewowi/StarMod/commits/main
@Copyright © 2024 Github StarMod Commit Authors
Expand Down Expand Up @@ -983,6 +983,7 @@ class AudioRings:public RingEffect {

class FreqMatrix:public Effect {
public:
char tesst[77];
const char * name() {
return "FreqMatrix 1D";
}
Expand Down Expand Up @@ -1136,20 +1137,16 @@ class Effects {

leds.sharedData.clear(); //make sure all values are 0

mdl->preUpdateDetails(var);

Effect* effect = effects[leds.fx];

mdl->contextRowNr = rowNr;
// effect->loop(leds); //do a loop to set sharedData right
// leds.sharedData.loop();
mdl->varPreDetails(var, rowNr);
effect->controls(var, leds); //new controls have positive order (var["o"])
mdl->contextRowNr = UINT8_MAX;
mdl->varPostDetails(var, rowNr);

effect->setup(leds); //if changed then run setup once (like call==0 in WLED)

mdl->postUpdateDetails(var, rowNr);

print->printJson("control", var);
// if (mdl->varOrder(var) >= 0) { //post init
// var["o"] = -mdl->varOrder(var); //make positive again
Expand Down
Loading

0 comments on commit b1d0795

Please sign in to comment.