Add physical ledmap support + tiny changes
index.js, FX_fcn.cpp - add physical ledmaps (lmPxyz.json)
This commit is contained in:
@@ -322,8 +322,8 @@ typedef enum mapping1D2D {
|
||||
M12_pArc = 2,
|
||||
M12_pCorner = 3,
|
||||
M12_jMap = 4, //WLEDMM jMap
|
||||
M12_sCircle = 5, //WLEDMM jMap
|
||||
M12_sBlock = 6 //WLEDMM jMap
|
||||
M12_sCircle = 5, //WLEDMM Circle
|
||||
M12_sBlock = 6 //WLEDMM Block
|
||||
} mapping1D2D_t;
|
||||
|
||||
// segment, 72 bytes
|
||||
|
||||
@@ -2019,6 +2019,8 @@ void WS2812FX::loadCustomPalettes() {
|
||||
bool WS2812FX::deserializeMap(uint8_t n) {
|
||||
// 2D support creates its own ledmap (on the fly) if a ledmap.json exists it will overwrite built one.
|
||||
|
||||
bool isPhysicalMap = false;
|
||||
|
||||
char fileName[32];
|
||||
//WLEDMM: als support segment name ledmaps
|
||||
bool isFile = false;;
|
||||
@@ -2033,6 +2035,7 @@ bool WS2812FX::deserializeMap(uint8_t n) {
|
||||
if (n == 10 + segment_index && !isFile && seg.name != nullptr) {
|
||||
sprintf_P(fileName, PSTR("/lm%s.json"), seg.name);
|
||||
isFile = WLED_FS.exists(fileName);
|
||||
isPhysicalMap = seg.name[0] == 'P';
|
||||
}
|
||||
if (isFile) break;
|
||||
segment_index++;
|
||||
@@ -2083,8 +2086,20 @@ bool WS2812FX::deserializeMap(uint8_t n) {
|
||||
#endif
|
||||
customMappingSize = map.size();
|
||||
customMappingTable = new uint16_t[customMappingSize];
|
||||
for (uint16_t i=0; i<MIN(customMappingSize, map.size()); i++)
|
||||
customMappingTable[i] = (uint16_t) (map[i]<0 ? 0xFFFFU : map[i]);
|
||||
|
||||
if (!isPhysicalMap) {
|
||||
for (uint16_t i=0; i<MIN(customMappingSize, map.size()); i++)
|
||||
customMappingTable[i] = (uint16_t) (map[i]<0 ? 0xFFFFU : map[i]);
|
||||
}
|
||||
else {
|
||||
for (int i=0; i<customMappingSize;i++) customMappingTable[i] = (uint16_t)0xFFFFU; //WLEDMM: init with no show
|
||||
//assign all >=0 mappings to customMappingTable
|
||||
for (uint16_t i=0; i<map.size(); i++)
|
||||
if (map[i]>=0)
|
||||
customMappingTable[map[i].as<uint16_t>()] = i;
|
||||
}
|
||||
|
||||
|
||||
loadedLedmap = n;
|
||||
|
||||
#ifdef WLED_DEBUG
|
||||
|
||||
@@ -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";
|
||||
|
||||
1573
wled00/html_ui.h
1573
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@@ -49,9 +49,11 @@
|
||||
void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
{
|
||||
//WLEDMM add USER_PRINT
|
||||
String temp;
|
||||
serializeJson(elem, temp);
|
||||
USER_PRINTF("deserializeSegment %s\n", temp.c_str());
|
||||
if (elem.size()!=1 || elem["stop"] != 0) { // not for {"stop":0}
|
||||
String temp;
|
||||
serializeJson(elem, temp);
|
||||
USER_PRINTF("deserializeSegment %s\n", temp.c_str());
|
||||
}
|
||||
|
||||
byte id = elem["id"] | it;
|
||||
if (id >= strip.getMaxSegments()) return;
|
||||
|
||||
@@ -736,7 +736,7 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8
|
||||
if (sequenceNumber > 15) sequenceNumber = 0;
|
||||
|
||||
if (!ddpUdp.beginPacket(client, DDP_DEFAULT_PORT)) { // port defined in ESPAsyncE131.h
|
||||
DEBUG_PRINTLN(F("WiFiUDP.beginPacket returned an error"));
|
||||
DEBUG_PRINTLN(F("DDP WiFiUDP.beginPacket returned an error"));
|
||||
return 1; // problem
|
||||
}
|
||||
|
||||
@@ -777,7 +777,7 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8
|
||||
}
|
||||
|
||||
if (!ddpUdp.endPacket()) {
|
||||
DEBUG_PRINTLN(F("WiFiUDP.endPacket returned an error"));
|
||||
DEBUG_PRINTLN(F("DDP WiFiUDP.endPacket returned an error"));
|
||||
return 1; // problem
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user