Segment name for ledmap names
index.js: - add ledmapFileNames array and fill with lm.segmentname.json names - use name in dropdowns and in loadmap fcn_declare and util.cpp: move enumerateLedmaps to FX.h and FX_fcn.cpp FX_fcn.cpp: deserializemap: use segment name lednames
This commit is contained in:
@@ -737,7 +737,8 @@ class WS2812FX { // 96 bytes
|
||||
setPixelColor(int n, uint32_t c),
|
||||
show(void),
|
||||
setTargetFps(uint8_t fps),
|
||||
deserializeMap(uint8_t n=0);
|
||||
deserializeMap(uint8_t n=0),
|
||||
enumerateLedmaps(); //WLEDMM (from fcn_declare)
|
||||
|
||||
void fill(uint32_t c) { for (int i = 0; i < _length; i++) setPixelColor(i, c); } // fill whole strip with color (inline)
|
||||
void addEffect(uint8_t id, mode_ptr mode_fn, const char *mode_name); // add effect to the list; defined in FX.cpp
|
||||
|
||||
@@ -1289,6 +1289,29 @@ uint8_t * Segment::getAudioPalette(int pal) {
|
||||
// WS2812FX class implementation
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//WLEDMM from
|
||||
void WS2812FX::enumerateLedmaps() {
|
||||
ledMaps = 1;
|
||||
for (size_t i=1; i<10; i++) {
|
||||
char fileName[16];
|
||||
sprintf_P(fileName, PSTR("/ledmap%d.json"), i);
|
||||
bool isFile = WLED_FS.exists(fileName);
|
||||
if (isFile) ledMaps |= 1 << i;
|
||||
}
|
||||
uint8_t segment_index = 0;
|
||||
for (segment &seg : _segments) {
|
||||
if (strcmp(seg.name, "") != 0) {
|
||||
char fileName[32];
|
||||
sprintf_P(fileName, PSTR("/lm%s.json"), seg.name);
|
||||
Serial.printf("Filename %s\n", fileName);
|
||||
bool isFile = WLED_FS.exists(fileName);
|
||||
if (isFile) ledMaps |= 1 << (10+segment_index);
|
||||
}
|
||||
segment_index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//do not call this method from system context (network callback)
|
||||
void WS2812FX::finalizeInit(void)
|
||||
{
|
||||
@@ -1915,10 +1938,26 @@ void WS2812FX::deserializeMap(uint8_t n) {
|
||||
// WLEDMM: also supports isMatrix
|
||||
|
||||
char fileName[32];
|
||||
strcpy_P(fileName, PSTR("/ledmap"));
|
||||
if (n) sprintf(fileName +7, "%d", n);
|
||||
strcat(fileName, ".json");
|
||||
bool isFile = WLED_FS.exists(fileName);
|
||||
//WLEDMM: als support segment name ledmaps
|
||||
bool isFile = false;;
|
||||
if (n<10) {
|
||||
strcpy_P(fileName, PSTR("/ledmap"));
|
||||
if (n) sprintf(fileName +7, "%d", n);
|
||||
strcat(fileName, ".json");
|
||||
isFile = WLED_FS.exists(fileName);
|
||||
} else {
|
||||
Serial.printf("deserializeMap Filename search %d\n", n);
|
||||
uint8_t segment_index = 0;
|
||||
for (segment &seg : _segments) {
|
||||
if (n == 10 + segment_index && !isFile) {
|
||||
sprintf_P(fileName, PSTR("/lm%s.json"), seg.name);
|
||||
isFile = WLED_FS.exists(fileName);
|
||||
Serial.printf("deserializeMap Filename %s %d\n", fileName, isFile);
|
||||
}
|
||||
if (isFile) break;
|
||||
segment_index++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isFile) {
|
||||
// erase custom mapping if selecting nonexistent ledmap.json (n==0)
|
||||
|
||||
@@ -37,7 +37,8 @@ var hol = [
|
||||
[0,0,1,1,"https://initiate.alphacoders.com/download/wallpaper/1198800/images/jpg/2522807481585600"] // new year
|
||||
];
|
||||
var ctx = null; // WLEDMM
|
||||
var ledmap = -1; //WLEDMM
|
||||
var ledmapNr = -1; //WLEDMM
|
||||
var ledmapFileNames = []; //WLEDMM
|
||||
|
||||
function handleVisibilityChange() {if (!d.hidden && new Date () - lastUpdate > 3000) requestJson();}
|
||||
function sCol(na, col) {d.documentElement.style.setProperty(na, col);}
|
||||
@@ -709,6 +710,8 @@ function populateSegments(s)
|
||||
let li = lastinfo;
|
||||
segCount = 0; lowestUnused = 0; lSeg = 0;
|
||||
|
||||
ledmapFileNames = [];
|
||||
|
||||
for (var inst of (s.seg||[])) {
|
||||
segCount++;
|
||||
|
||||
@@ -719,6 +722,8 @@ function populateSegments(s)
|
||||
let sg = gId(`seg${i}`);
|
||||
let exp = sg ? (sg.classList.contains('expanded') || (i===0 && cfg.comp.segexp)) : false;
|
||||
|
||||
ledmapFileNames.push("lm" + (inst.n?inst.n:"default") + ".json"); //WLEDMM
|
||||
|
||||
let segp = `<div id="segp${i}" class="sbs">
|
||||
<i class="icons e-icon pwr ${inst.on ? "act":""}" id="seg${i}pwr" onclick="setSegPwr(${i})"></i>
|
||||
<div class="sliderwrap il">
|
||||
@@ -839,7 +844,7 @@ function populateSegments(s)
|
||||
|
||||
if (Array.isArray(li.maps) && li.maps.length>0) { //WLEDMM >0 instead of 1 to show also first ledmap. Attention: WLED AC has isM check, in MM Matrices are supported so do not check on isM
|
||||
let cont = `Ledmap: <select class="sel-sg" onchange="requestJson({'ledmap':parseInt(this.value)})">`; //WLEDMM remove <option value="" selected>Unchanged</option>
|
||||
for (const k of (li.maps||[])) cont += `<option value="${k}"${(i>0 && ledmap==k)?" selected":""}>${k==0?'Default':'ledmap'+k+'.json'}</option>`; //WLEDMM set ledmap selected
|
||||
for (const k of (li.maps||[])) cont += `<option value="${k}"${(i>0 && ledmapNr==k)?" selected":""}>${k==0?'Default':(k<10?'ledmap'+k+'.json':ledmapFileNames[k-10])}</option>`; //WLEDMM set ledmap selected, use ledmapFileNames
|
||||
cont += "</select></div>";
|
||||
gId("ledmap").innerHTML = cont;
|
||||
gId("ledmap").classList.remove('hide');
|
||||
@@ -1300,11 +1305,16 @@ function drawSegments() {
|
||||
}
|
||||
|
||||
//draw the ledmap
|
||||
if (ledmap>0 && ctx) {
|
||||
if (ledmapNr>0 && ctx) {
|
||||
// console.log("Before fetch ledmap ", lastinfo.ledmap);
|
||||
fetchAndExecute((loc?`http://${locip}`:'.') + "/", "ledmap"+ledmap+".json" , function(text) {
|
||||
var fileName;
|
||||
if (ledmapNr<10)
|
||||
fileName = "ledmap"+ledmapNr+".json";
|
||||
else
|
||||
fileName = ledmapFileNames[ledmapNr-10];
|
||||
fetchAndExecute((loc?`http://${locip}`:'.') + "/", fileName , function(text) {
|
||||
var noMap = [];
|
||||
ledmapJson = JSON.parse(text);
|
||||
var ledmapJson = JSON.parse(text);
|
||||
var counter = 0;
|
||||
for (let i=0;i<ledmapJson["map"].length;i++) {
|
||||
let mapIndex = ledmapJson["map"][i];
|
||||
@@ -1522,7 +1532,7 @@ function readState(s,command=false)
|
||||
tr = s.transition;
|
||||
gId('tt').value = tr/10;
|
||||
|
||||
ledmap = s.ledmap; //WLEDMM
|
||||
ledmapNr = s.ledmap; //WLEDMM
|
||||
|
||||
populateSegments(s);
|
||||
var selc=0;
|
||||
@@ -2100,7 +2110,7 @@ ${makePlSel(plJson[i].end?plJson[i].end:0, true)}
|
||||
</label>`;
|
||||
if (Array.isArray(lastinfo.maps) && lastinfo.maps.length>0) { //WLEDMM >0 instead of 1 to show also first ledmap. Attention: WLED AC has isM check, in MM Matrices are supported so do not check on isM
|
||||
content += `<div class="lbl-l">Ledmap: <div class="sel-p"><select class="sel-p" id="p${i}lmp"><option value="">Unchanged</option>`;
|
||||
for (const k of (lastinfo.maps||[])) content += `<option value="${k}"${(i>0 && pJson[i].ledmap==k)?" selected":""}>${k==0?'Default':'ledmap'+k+'.json'}</option>`;
|
||||
for (const k of (lastinfo.maps||[])) content += `<option value="${k}"${(i>0 && pJson[i].ledmap==k)?" selected":""}>${k==0?'Default':(k<10?'ledmap'+k+'.json':ledmapFileNames[k-10])}</option>`;
|
||||
content += "</select></div></div>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxL
|
||||
int16_t extractModeDefaults(uint8_t mode, const char *segVar);
|
||||
uint16_t crc16(const unsigned char* data_p, size_t length);
|
||||
um_data_t* simulateSound(uint8_t simulationId);
|
||||
void enumerateLedmaps();
|
||||
// WLEDMM enumerateLedmaps(); moved to FX.h
|
||||
CRGB getCRGBForBand(int x, uint8_t *fftResult, int pal); //WLEDMM netmindz ar palette
|
||||
|
||||
#ifdef WLED_ADD_EEPROM_SUPPORT
|
||||
|
||||
4291
wled00/html_ui.h
4291
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@@ -767,7 +767,7 @@ void serializeInfo(JsonObject root)
|
||||
root[F("cpalcount")] = strip.customPalettes.size(); //number of custom palettes
|
||||
|
||||
JsonArray ledmaps = root.createNestedArray(F("maps"));
|
||||
for (size_t i=0; i<10; i++) {
|
||||
for (size_t i=0; i<16; i++) { //WLEDMM include segment name ledmaps
|
||||
if ((ledMaps>>i) & 0x0001) ledmaps.add(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -505,15 +505,7 @@ um_data_t* simulateSound(uint8_t simulationId)
|
||||
}
|
||||
|
||||
|
||||
void enumerateLedmaps() {
|
||||
ledMaps = 1;
|
||||
for (size_t i=1; i<10; i++) {
|
||||
char fileName[16];
|
||||
sprintf_P(fileName, PSTR("/ledmap%d.json"), i);
|
||||
bool isFile = WLED_FS.exists(fileName);
|
||||
if (isFile) ledMaps |= 1 << i;
|
||||
}
|
||||
}
|
||||
//WLEDMM enumerateLedmaps moved to FX_fcn.cpp
|
||||
|
||||
//WLEDMM netmindz ar palette
|
||||
CRGB getCRGBForBand(int x, uint8_t *fftResult, int pal) {
|
||||
|
||||
@@ -183,8 +183,10 @@ void WLED::loop()
|
||||
yield();
|
||||
serializeConfig();
|
||||
}
|
||||
//WLEDMM refactored
|
||||
if (loadLedmap) {
|
||||
strip.deserializeMap(loadedLedmap);
|
||||
strip.enumerateLedmaps(); //WLEDMM
|
||||
loadLedmap = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2302110
|
||||
#define VERSION 2302120
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
|
||||
Reference in New Issue
Block a user