Add physical ledmap support + tiny changes

index.js, FX_fcn.cpp
- add physical ledmaps (lmPxyz.json)
This commit is contained in:
Ewoud
2023-02-28 17:17:22 +01:00
parent fbc9f9143e
commit 6b659ab52e
6 changed files with 831 additions and 796 deletions

View File

@@ -1324,20 +1324,33 @@ function drawSegmentView() {
if (ledmapNr>=0 && ctx) { //WLEDMM: @Troy#2642 : include ledmap = 0 as default ledmap
// console.log("Before fetch ledmap ", lastinfo.ledmap);
var fileName;
let isPhysicalMap = false;
if (ledmapNr==0)
fileName = "ledmap.json"; //0 is ledmap.json, not ledmap0.json
else if (ledmapNr<10)
fileName = "ledmap"+ledmapNr+".json";
else
else {
fileName = ledmapFileNames[ledmapNr-10];
isPhysicalMap = fileName.charAt(2) == "P";
}
fetchAndExecute((loc?`http://${locip}`:'.') + "/", fileName , function(text) {
var ledmapJson = JSON.parse(text);
var counter = 0;
var noMap = [];
for (let i=0;i<maxWidth * maxHeight;i++) noMap.push(i); //initially add all pixels in array
var colorArray = ["yellow", "green", "magenta", "orange"];
for (let i=0;i<ledmapJson["map"].length;i++) {
let mapIndex = ledmapJson["map"][i];
var customMappingTable = [];
if (!isPhysicalMap) {
customMappingTable = ledmapJson["map"];
} else {
for (let i=0;i<maxWidth * maxHeight;i++) customMappingTable.push(-1); //init with noshow
for (let i=0;i<maxWidth * maxHeight;i++)
if (ledmapJson["map"][i]>=0) customMappingTable[ledmapJson["map"][i]] = i;
}
for (let i=0;i<customMappingTable.length;i++) {
let mapIndex = customMappingTable[i];
if (mapIndex != -1) {
ctx.font = parseInt(ppL/3) + 'px Arial';
ctx.fillStyle = "white";