Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into S2_patch3
Browse files Browse the repository at this point in the history
  • Loading branch information
softhack007 committed Feb 8, 2024
2 parents 14c2f2c + 0744f70 commit 8ce574e
Show file tree
Hide file tree
Showing 20 changed files with 1,630 additions and 1,612 deletions.
51 changes: 29 additions & 22 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ let jsonValues = {};
let uiFunCommands = [];
let model = []; //model.json (as send by the server), used by FindVar
let savedView = null;
const UINT8_MAX = 255;

function gId(c) {return d.getElementById(c);}
function cE(e) { return d.createElement(e); }
Expand Down Expand Up @@ -97,7 +98,7 @@ function makeWS() {
// console.log("WS receive update", json);
receiveData(json);
else
console.log("program error array not expected", json);
console.log("dev array not expected", json);
}
}
}
Expand Down Expand Up @@ -137,7 +138,7 @@ function linearToLogarithm(json, value) {
return Math.round(result);
}

function createHTML(json, parentNode = null, rowNr = -1) {
function createHTML(json, parentNode = null, rowNr = UINT8_MAX) {

// console.log("createHTML", json, parentNode);
if (Array.isArray(json)) {
Expand All @@ -153,9 +154,9 @@ function createHTML(json, parentNode = null, rowNr = -1) {
else { // json is variable
let variable = json;

if (Array.isArray(variable.value) && rowNr != -1) {
if (Array.isArray(variable.value) && rowNr != UINT8_MAX) {
if (rowNr < variable.value.length && variable.value[rowNr] == null) {
console.log("not showing this var as value is null", variable, rowNr);
// console.log("not showing this var as value is null", variable, rowNr);
return;
}
}
Expand All @@ -167,7 +168,7 @@ function createHTML(json, parentNode = null, rowNr = -1) {
}
let parentNodeType = parentNode.nodeName.toLocaleLowerCase();

let isPartOfTableRow = (rowNr != -1);
let isPartOfTableRow = (rowNr != UINT8_MAX);

// if (!variable || !variable.id) {
// console.log("genHTML no variable and id", variable, parentNode); //tbd: caused by more data then columns in table...
Expand Down Expand Up @@ -317,7 +318,7 @@ function createHTML(json, parentNode = null, rowNr = -1) {
varNode = cE("input");
varNode.type = variable.type;
varNode.disabled = variable.ro;
varNode.value = initCap(variable.id); //initial label
varNode.value = initCap(variable.id); //initial label, button.value is the label shown on the button
varNode.addEventListener('click', (event) => {console.log(variable.type + " click", event.target);sendValue(event.target);});
} else if (variable.type == "range") {
varNode = cE("input");
Expand Down Expand Up @@ -364,6 +365,10 @@ function createHTML(json, parentNode = null, rowNr = -1) {
zNode.addEventListener('change', (event) => {console.log(variable.type + " change", event.target.parentNode);sendValue(event.target.parentNode);});
varNode.appendChild(zNode);
}
} else if (variable.type == "progress") {
varNode = cE("progress");
varNode.min = variable.min?variable.min:0; //if not specified then unsigned value (min=0)
if (variable.max) varNode.max = variable.max;
} else {
//input types: text, search, tel, url, email, and password.

Expand Down Expand Up @@ -447,7 +452,7 @@ function createHTML(json, parentNode = null, rowNr = -1) {
} //not an array but variable
}

function genTableRowHTML(json, parentNode = null, rowNr = -1) {
function genTableRowHTML(json, parentNode = null, rowNr = UINT8_MAX) {
let variable = json;
let tbodyNode = parentNode.querySelector("tbody");
// console.log("genTableRowHTML", parentNode.id, rowNr, tbodyNode.querySelectorAll("tr").length);
Expand Down Expand Up @@ -508,8 +513,8 @@ function receiveData(json) {
}
else if (key == "details") {
let variable = value.var;
let rowNr = value.rowNr == null?-1:value.rowNr;
let nodeId = variable.id + ((rowNr != -1)?"#" + rowNr:"");
let rowNr = value.rowNr == null?UINT8_MAX:value.rowNr;
let nodeId = variable.id + ((rowNr != UINT8_MAX)?"#" + rowNr:"");
//if var object with .n, create .n (e.g. see setEffect and fixtureGenChFun, tbd: )
console.log("receiveData details", key, variable, nodeId, rowNr);
if (gId(nodeId + "_n")) gId(nodeId + "_n").remove(); //remove old ndiv
Expand All @@ -533,7 +538,7 @@ function receiveData(json) {
// console.log("updRow main", tableId, tableRows, tableNode, tableVar);

let rowFound = false;
let rowNr = -1;
let rowNr = UINT8_MAX;
for (let nodeRowNr = 1, rowNode; rowNode = tableNode.rows[nodeRowNr]; nodeRowNr++) { //<table> rows starting with header row
rowNr = nodeRowNr - 1;
// console.log(" noderow", rowNr, rowNode);
Expand Down Expand Up @@ -593,28 +598,28 @@ function receiveData(json) {
} //receiveData

//do something with an existing (variable) node, key is an existing node, json is what to do with it
function changeHTML(variable, commandJson, rowNr = -1) {
function changeHTML(variable, commandJson, rowNr = UINT8_MAX) {

let node = null;

if (rowNr != -1) node = gId(variable.id + "#" + rowNr);
if (rowNr != UINT8_MAX) node = gId(variable.id + "#" + rowNr);
else node = gId(variable.id);

if (!node) {
//we should find all nodes, it's a bit if a trick just checking for node0 (what if deleted): tbd: improve
let rowNodes = document.querySelectorAll(`${variable.type}[id*="${variable.id}#"]`); //find nodes from the right class with id + #nr
for (let subNode of rowNodes) {
let rowNr = parseInt(subNode.id.substring(variable.id.length + 1));
console.log("changeHTML found row nodes !", variable, subNode, commandJson, rowNr);
// console.log("changeHTML found row nodes !", variable, subNode, commandJson, rowNr);
changeHTML(variable, commandJson, rowNr); //recursive call of all nodes
}
if (rowNodes.length == 0)
console.log("dev changeHTML no node !", variable, node, commandJson, rowNr);
// if (rowNodes.length == 0) //can happen e.g. fixture parameters
// console.log("changeHTML no node !", variable, node, commandJson, rowNr);
return;
}

let nodeType = node.nodeName.toLocaleLowerCase();
let isPartOfTableRow = (rowNr != -1);
let isPartOfTableRow = (rowNr != UINT8_MAX);

if (commandJson.hasOwnProperty("label")) {
if (nodeType == "th") //table header
Expand Down Expand Up @@ -747,7 +752,7 @@ function changeHTML(variable, commandJson, rowNr = -1) {
let trNodes = tableNode.querySelector('tbody').querySelectorAll("tr");
let tableVar = findVar(tableNode.id); //tbd: table in table
let valueLength = Array.isArray(commandJson.value)?commandJson.value.length:1; //tbd: use table nr of rows (not saved yet)
// console.log("changeHTML th column", node.id, (rowNr == -1)?JSON.stringify(commandJson.value):commandJson.value[rowNr], commandJson.chk, rowNr);
// console.log("changeHTML th column", node.id, (rowNr == UINT8_MAX)?JSON.stringify(commandJson.value):commandJson.value[rowNr], commandJson.chk, rowNr);

let max = Math.max(valueLength, trNodes.length);
for (let newRowNr = 0; newRowNr<max;newRowNr++) {
Expand All @@ -773,9 +778,9 @@ function changeHTML(variable, commandJson, rowNr = -1) {

}
else if (node.parentNode.parentNode.nodeName.toLocaleLowerCase() == "td" && Array.isArray(commandJson.value)) { //table column, called for each column cell!!!
// console.log("changeHTML value array", node.parentNode.parentNode.nodeName.toLocaleLowerCase(), node.id, (rowNr == -1)?JSON.stringify(commandJson.value):commandJson.value[rowNr], commandJson.chk, rowNr);
// console.log("changeHTML value array", node.parentNode.parentNode.nodeName.toLocaleLowerCase(), node.id, (rowNr == UINT8_MAX)?JSON.stringify(commandJson.value):commandJson.value[rowNr], commandJson.chk, rowNr);

if (rowNr == -1) {
if (rowNr == UINT8_MAX) {
console.log("changeHTML value array should not happen when no rowNr", variable, node, commandJson, rowNr);
let newRowNr = 0;
for (let val of commandJson.value) {
Expand Down Expand Up @@ -848,7 +853,7 @@ function changeHTML(variable, commandJson, rowNr = -1) {
console.log(" value coord3D value not object[x,y,z]", commandJson.value);
}
else {//inputs or select
if (Array.isArray(commandJson.value) && rowNr != -1)
if (Array.isArray(commandJson.value) && rowNr != UINT8_MAX)
node.value = commandJson.value[rowNr];
else
node.value = commandJson.value;
Expand All @@ -863,7 +868,7 @@ function changeHTML(variable, commandJson, rowNr = -1) {

//value assignments depending on different situations

if ((variable.value == null || !Array.isArray(variable.value)) && !Array.isArray(commandJson.value) && rowNr == -1) {
if ((variable.value == null || !Array.isArray(variable.value)) && !Array.isArray(commandJson.value) && rowNr == UINT8_MAX) {
//no arrays and rowNr. normal situation
if (variable.value != commandJson.value)
variable.value = commandJson.value;
Expand All @@ -888,7 +893,7 @@ function changeHTML(variable, commandJson, rowNr = -1) {
variable.value[rowNr] = commandJson.value;
}
}
else if (!Array.isArray(variable.value) && !Array.isArray(commandJson.value) && rowNr != -1) {
else if (!Array.isArray(variable.value) && !Array.isArray(commandJson.value) && rowNr != UINT8_MAX) {
if (variable.value != commandJson.value) {
console.log("chHTML column with one value for all rows", variable.id, node.id, variable.value, commandJson.value, rowNr);
variable.value = commandJson.value;
Expand Down Expand Up @@ -1007,6 +1012,8 @@ function sendValue(varNode) {
command[varId].value = varNode.querySelector("input").checked;
else if (varNode.nodeName.toLocaleLowerCase() == "span")
command[varId].value = varNode.innerText;
else if (varNode.className == "button")
command[varId].value = true;
else if (varNode.className == "coord3D") {
let coord = {};
coord.x = parseInt(varNode.childNodes[0].value);
Expand Down
29 changes: 27 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ lib_deps =
build_flags =
-D USERMOD_WLEDAUDIO
lib_deps =
https://github.com/netmindz/WLED-sync#v0.14.0.b16
https://github.com/netmindz/WLED-sync#07737aff9523a615f507b9525ffe55c98c440f8f ;; fixes 'Could not parse manifest' warning



Expand All @@ -84,7 +84,6 @@ build_flags =
${starmod.build_flags}
-DCONFIG_ASYNC_TCP_USE_WDT=0
-DLFS_THREADSAFE ;; enables use of semaphores in LittleFS driver
-DARDUINO_USB_CDC_ON_BOOT=0 ;; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (needed on "classic ESP32")
${appmod_leds.build_flags}
${usermod_e131.build_flags}
; ${usermod_ha.build_flags}
Expand All @@ -106,8 +105,19 @@ upload_speed = 1500000
build_flags =
${env.build_flags}
-DCONFIG_IDF_TARGET_ESP32=1
-DARDUINO_USB_CDC_ON_BOOT=0 ;; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (needed on "classic ESP32")


[env:pico32]
board = pico32 ;https://github.com/platformio/platform-espressif32/blob/develop/boards/pico32.json
; recommended to pin to a platform version, see https://github.com/platformio/platform-espressif32/releases
platform = [email protected] ;using platformio/framework-arduinoespressif32 @ ~3.20014.0 / framework-arduinoespressif32 @ 3.20014.231204 (2.0.14)
upload_speed = 230400 ;; reduced speed, as a manually attached serial-to-USB Module is needed on most pico boards (flimsy cables -> not reliable connection)
build_flags =
${env.build_flags}
-DCONFIG_IDF_TARGET_ESP32=1
-DARDUINO_USB_CDC_ON_BOOT=0 ;; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (needed on "classic ESP32")


[env:lolin_d32]
board = lolin_d32 ;https://github.com/platformio/platform-espressif32/blob/develop/boards/lolin_d32.json (no differences with esp32dev)
Expand All @@ -116,6 +126,7 @@ platform = [email protected] ;using platformio/framework-arduinoespressif32 @ ~3
build_flags =
${env.build_flags}
-DCONFIG_IDF_TARGET_ESP32=1
-DARDUINO_USB_CDC_ON_BOOT=0 ;; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (needed on "classic ESP32")



Expand All @@ -135,6 +146,20 @@ build_flags = ${env.build_flags}
-D LOLIN_WIFI_FIX ;; workaround for LOLIN C3/S2/S3 wifi instability. https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi


[env:lolin_c3_mini]
board = lolin_c3_mini ;https://github.com/platformio/platform-espressif32/blob/develop/boards/lolin_c3_mini.json
;; platform = [email protected] ;; WLED default framework version
platform = [email protected] ;; this one behaves better for debugging
upload_speed = 256000
build_unflags =
; -DARDUINO_USB_CDC_ON_BOOT=1 ;; un-comment if you want to use a "real" serial-to-USB moddule !!!! make sure =0 and not =1 is uncommented!!
build_flags = ${env.build_flags}
-DDCONFIG_IDF_TARGET_ESP32C3=1
-DARDUINO_USB_CDC_ON_BOOT=1 ;; for debugging over USB
; -DARDUINO_USB_CDC_ON_BOOT=0 ;; with serial-to-USB moddule (use in case your board hangs without USB connection)
-DARDUINO_USB_MODE=1 ;; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (mandatory on -C3)
-DLOLIN_WIFI_FIX ;; activate workaround for LOLIN C3/S2/S3 wifi instability. https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi
; -D DEBUG=1 -D CORE_DEBUG_LEVEL=1 -D ARDUINOJSON_DEBUG=1 ;; for more debug output



Expand Down
12 changes: 1 addition & 11 deletions src/App/AppEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ class GEQEffect:public Effect {
if (e131mod->isEnabled) {
e131mod->patchChannel(3, "fadeOut", 255); // TODO: add constant for name
e131mod->patchChannel(4, "ripple", 255);
ui->processUiFun("e131Tbl");
ui->processUiFun("e131Tbl"); // sends data to ws...
}

#endif
Expand Down Expand Up @@ -1090,16 +1090,6 @@ class Effects {
// }
//remove vars with all values -99

JsonDocument *responseDoc = web->getResponseDoc();
responseDoc->clear(); //needed for deserializeJson?
JsonObject responseObject = responseDoc->to<JsonObject>();

responseObject["details"]["var"] = var;
responseObject["details"]["rowNr"] = rowNr;

print->printJson("var", responseObject);
web->sendDataWs(responseObject); //always send, also when no children, to remove them from ui

} // fx < size

return doMap;
Expand Down
5 changes: 3 additions & 2 deletions src/App/AppFixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@

if (pixel >= startPosAdjusted && pixel <= endPosAdjusted) {

// to display ScrollingText on one side of a cube (WIP)
if (fixtureDimension == 3 && endPosAdjusted.z == 0)
fixtureDimension = _2D;

Expand Down Expand Up @@ -319,8 +320,8 @@
}

USER_PRINTF("projectAndMap V:%dx%dx%d V:%dx%dx%d and V:%d P:%d\n", leds->size.x, leds->size.y, leds->size.z, size.x, size.y, size.z, leds->nrOfLeds, nrOfLeds);
mdl->setValue("fxSize", leds->size, rowNr);
mdl->setValue("fxCount", leds->nrOfLeds, rowNr);

mdl->setValueV("fxSize", rowNr, "%d x %d x %d = %d", leds->size.x, leds->size.y, leds->size.z, leds->nrOfLeds);

USER_PRINTF("leds[%d].size = %d + %d\n", leds->rowNr, sizeof(Leds), leds->mappingTable.size()); //44

Expand Down
1 change: 1 addition & 0 deletions src/App/AppLeds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ CRGB Leds::getPixelColor(uint16_t indexV) {
return CRGB::Black;
}
else if (!mappingTable[indexV].size()) //if no physMap // Core 1 panic'ed (LoadProhibited). Exception was unhandled. - std::vector<unsigned short, std::allocator<unsigned short> >::size()
// by blurrows CRGB cur = getPixelColor(XY(i,row));?
{
USER_PRINTF(" dev gPC P:%d >= %d", mappingTable[indexV][0], NUM_LEDS_Max);
return CRGB::Black;
Expand Down
8 changes: 1 addition & 7 deletions src/App/AppModFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,11 @@ class AppModFixture:public SysModule {
char fileName[32] = "";
if (files->seqNrToName(fileName, lds->fixture.fixtureNr)) {
//send to pview a message to get file filename
JsonDocument *responseDoc = web->getResponseDoc();
responseDoc->clear(); //needed for deserializeJson?
JsonVariant responseVariant = responseDoc->as<JsonVariant>();

web->addResponse("pview", "file", JsonString(fileName, JsonString::Copied));
web->sendDataWs(responseVariant);
print->printJson("fixture chFun send ws done", responseVariant); //during server startup this is not send to a client, so client refresh should also trigger this
}
}); //fixture

ui->initCoord3D(parentVar, "fixSize", lds->fixture.size, 0, UINT16_MAX, true, [this](JsonObject var) { //uiFun
ui->initCoord3D(parentVar, "fixSize", lds->fixture.size, UINT8_MAX, 0, UINT16_MAX, true, [this](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Size");
// web->addResponse(var["id"], "value", fixture.size);
});
Expand Down
Loading

0 comments on commit 8ce574e

Please sign in to comment.