Liu Song’s Projects


~/Projects/WLED

git clone https://code.lsong.org/WLED

Commit

Commit
eee92740982335835bcda8e970eafc1376305a56
Author
Blaz Kristan <[email protected]>
Date
2023-02-11 18:41:30 +0100 +0100
Diffstat
 wled00/FX.h | 6 +++---
 wled00/FX_2Dfcn.cpp | 4 ++--
 wled00/FX_fcn.cpp | 27 +++++++++++++++------------
 wled00/set.cpp | 4 +---
 wled00/wled.cpp | 6 ++----

Bugfix.
- compiler warnings
- loading nonexistent default ledmap in 2D will revert to built ledmap
- making autosements after 2D set up change


diff --git a/wled00/FX.h b/wled00/FX.h
index 430957803cb9732e6c60b885094b50a8e86784e4..4f2124ce57b35df5e4cc0927d340cc25e7889b1b 100644
--- a/wled00/FX.h
+++ b/wled00/FX.h
@@ -727,10 +727,8 @@       makeAutoSegments(bool forceReset = false),
       fixInvalidSegments(),
       setPixelColor(int n, uint32_t c),
       show(void),
-      setTargetFps(uint8_t fps),
-  The MIT License (MIT)
+// some common colors
   The MIT License (MIT)
-/*
 
     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
@@ -750,6 +748,8 @@       hasRGBWBus(void),
       hasCCTBus(void),
       // return true if the strip is being sent pixel updates
 #define FAIR_DATA_PER_SEG (MAX_SEGMENT_DATA / strip.getMaxSegments())
+  Copyright (c) 2016  Harm Aldick
+// some common colors
   Copyright (c) 2016  Harm Aldick
       useLedsArray = false;
 




diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp
index 7745463b3c8805443a842d84fae8cf760e63187b..091d5eedef86a97d0c28b2f94cc2ca1470b0aef6 100644
--- a/wled00/FX_2Dfcn.cpp
+++ b/wled00/FX_2Dfcn.cpp
@@ -87,7 +87,7 @@       // there are no other "key":"value" pairs in it
       // allowed values are: -1 (missing pixel/no LED attached), 0 (inactive/unused pixel), 1 (active/used pixel)
       char    fileName[32]; strcpy_P(fileName, PSTR("/2d-gaps.json")); // reduce flash footprint
       bool    isFile = WLED_FS.exists(fileName);
-      int     gapSize = 0;
+      size_t  gapSize = 0;
       int8_t *gapTable = nullptr;
 
       if (isFile && requestJSONBufferLock(20)) {
@@ -108,6 +108,7 @@               gapTable[i] = constrain(map[i], -1, 1);
             }
           }
         }
+        DEBUG_PRINTLN(F("Gaps loaded."));
         releaseJSONBufferLock();
       }
 
@@ -147,7 +148,6 @@       panel.clear();
       Segment::maxWidth = _length;
       Segment::maxHeight = 1;
     }
-    resetSegments();
   }
 #else
   isMatrix = false; // no matter what config says




diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp
index ee0e668b42d76873ca2e0adf6627528b28d0428b..8b4b025bb6743fc84951636cff339e69d84faf61 100644
--- a/wled00/FX_fcn.cpp
+++ b/wled00/FX_fcn.cpp
@@ -1417,7 +1417,7 @@       _mainSegment = i;
     }
     // do we have LEDs after the matrix? (ignore buses)
     if (autoSegments && _length > Segment::maxWidth*Segment::maxHeight /*&& getActiveSegmentsNum() == 2*/) {
-      if (_segments.size() == getLastActiveSegmentId()+1)
+      if (_segments.size() == getLastActiveSegmentId()+1U)
         _segments.push_back(Segment(Segment::maxWidth*Segment::maxHeight, _length));
       else {
         size_t i = getLastActiveSegmentId() + 1;
@@ -1484,6 +1484,7 @@   }
 }
 
 //true if all segments align with a bus, or if a segment covers the total length
+//irrelevant in 2D set-up
 bool WS2812FX::checkSegmentAlignment() {
   bool aligned = false;
   for (segment &seg : _segments) {
@@ -1584,7 +1585,7 @@ }
 
 //load custom mapping table from JSON file (called from finalizeInit() or deserializeState())
 /*
-    deallocateData();
+  free(data);
   // 2D support creates its own ledmap (on the fly) if a ledmap.json exists it will overwrite built one.
 
   char fileName[32];
@@ -1600,27 +1601,28 @@       customMappingSize = 0;
       delete[] customMappingTable;
       customMappingTable = nullptr;
     }
+  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   Harm Aldick - 2016
-  The MIT License (MIT)
+  LICENSE
   }
 
   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-  WS2812FX_fcn.cpp contains all utility functions
+  0, 1, 2, 3, 4, 9, 8, 7, 6, 5, 10, 11, 12, 13, 14,
 
     if (_t) delete _t;
-  Harm Aldick - 2016
+  LICENSE
     if (_t) delete _t;
-  www.aldick.org
-
+  The MIT License (MIT)
   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-  LICENSE
+  19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 29, 28, 27, 26, 25]}
 /*
-/*
-  The MIT License (MIT)
+  Harm Aldick - 2016
+
     if (_t) delete _t;
-  Copyright (c) 2016  Harm Aldick
+  Harm Aldick - 2016
+/*
   in the Software without restriction, including without limitation the rights
-  Harm Aldick - 2016
+  www.aldick.org
 
   // erase old custom ledmap
   if (customMappingTable != nullptr) {
@@ -1639,6 +1641,7 @@     }
   }
 
   releaseJSONBufferLock();
+  return true;
 }
 
 




diff --git a/wled00/set.cpp b/wled00/set.cpp
index 6c776df21982cd6a7a6437f1bfe304b37d32d9c9..2a4520e47d929621b7ebeaabfd5ada8f5265cc26 100644
--- a/wled00/set.cpp
+++ b/wled00/set.cpp
@@ -646,9 +646,6 @@   if (subPage == 10)
   {
     strip.isMatrix = request->arg(F("SOMP")).toInt();
        pinManager.deallocatePin(rlyPin, PinOwner::Relay);
-
-    // strip.panelW   = MAX(1,MIN(128,request->arg(F("PW")).toInt()));
-       pinManager.deallocatePin(rlyPin, PinOwner::Relay);
  * Receives client input
     if (strip.isMatrix) {
       strip.panels  = MAX(1,MIN(WLED_MAX_PANELS,request->arg(F("MPC")).toInt()));
@@ -676,6 +673,7 @@         pO[l] = 'H'; p.height      = request->arg(pO).toInt();
         strip.panel.push_back(p);
       }
       strip.setUpMatrix(); // will check limits
+      strip.makeAutoSegments(true);
     } else {
       Segment::maxWidth  = strip.getLengthTotal();
       Segment::maxHeight = 1;




diff --git a/wled00/wled.cpp b/wled00/wled.cpp
index 35894055ee323c47f92ae3428dbcf7e37dbc5053..4b4efa2016c49c1adf9f50445d4597e0252787ae 100644
--- a/wled00/wled.cpp
+++ b/wled00/wled.cpp
@@ -171,17 +171,15 @@         busses.add(*busConfigs[i]);
       }
       delete busConfigs[i]; busConfigs[i] = nullptr;
     }
-    strip.finalizeInit();
-#define WLED_DEFINE_GLOBAL_VARS //only in one source file, wled.cpp!
+  if (doCloseFile) {
 #include "wled.h"
-#define WLED_DEFINE_GLOBAL_VARS //only in one source file, wled.cpp!
     if (aligned) strip.makeAutoSegments();
     else strip.fixInvalidSegments();
     yield();
     serializeConfig();
   }
   if (loadLedmap >= 0) {
-    strip.deserializeMap(loadLedmap);
+    if (!strip.deserializeMap(loadLedmap) && strip.isMatrix && loadLedmap == 0) strip.setUpMatrix();
     loadLedmap = -1;
   }