Bugfix.
- compiler warnings - loading nonexistent default ledmap in 2D will revert to built ledmap - making autosements after 2D set up change
This commit is contained in:
parent
8dd1f89225
commit
eee9274098
@ -727,8 +727,7 @@ class WS2812FX { // 96 bytes
|
||||
fixInvalidSegments(),
|
||||
setPixelColor(int n, uint32_t c),
|
||||
show(void),
|
||||
setTargetFps(uint8_t fps),
|
||||
deserializeMap(uint8_t n=0);
|
||||
setTargetFps(uint8_t fps);
|
||||
|
||||
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
|
||||
@ -748,6 +747,7 @@ class WS2812FX { // 96 bytes
|
||||
hasCCTBus(void),
|
||||
// return true if the strip is being sent pixel updates
|
||||
isUpdating(void),
|
||||
deserializeMap(uint8_t n=0),
|
||||
useLedsArray = false;
|
||||
|
||||
inline bool isServicing(void) { return _isServicing; }
|
||||
|
@ -87,7 +87,7 @@ void WS2812FX::setUpMatrix() {
|
||||
// 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 @@ void WS2812FX::setUpMatrix() {
|
||||
}
|
||||
}
|
||||
}
|
||||
DEBUG_PRINTLN(F("Gaps loaded."));
|
||||
releaseJSONBufferLock();
|
||||
}
|
||||
|
||||
@ -147,7 +148,6 @@ void WS2812FX::setUpMatrix() {
|
||||
Segment::maxWidth = _length;
|
||||
Segment::maxHeight = 1;
|
||||
}
|
||||
resetSegments();
|
||||
}
|
||||
#else
|
||||
isMatrix = false; // no matter what config says
|
||||
|
@ -1417,7 +1417,7 @@ void WS2812FX::makeAutoSegments(bool forceReset) {
|
||||
}
|
||||
// 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 @@ void WS2812FX::fixInvalidSegments() {
|
||||
}
|
||||
|
||||
//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) {
|
||||
@ -1583,7 +1584,7 @@ void WS2812FX::loadCustomPalettes() {
|
||||
}
|
||||
|
||||
//load custom mapping table from JSON file (called from finalizeInit() or deserializeState())
|
||||
void WS2812FX::deserializeMap(uint8_t n) {
|
||||
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.
|
||||
|
||||
char fileName[32];
|
||||
@ -1599,19 +1600,19 @@ void WS2812FX::deserializeMap(uint8_t n) {
|
||||
delete[] customMappingTable;
|
||||
customMappingTable = nullptr;
|
||||
}
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!requestJSONBufferLock(7)) return;
|
||||
|
||||
DEBUG_PRINT(F("Reading LED map from "));
|
||||
DEBUG_PRINTLN(fileName);
|
||||
if (!requestJSONBufferLock(7)) return false;
|
||||
|
||||
if (!readObjectFromFile(fileName, nullptr, &doc)) {
|
||||
releaseJSONBufferLock();
|
||||
return; //if file does not exist just exit
|
||||
return false; //if file does not exist just exit
|
||||
}
|
||||
|
||||
DEBUG_PRINT(F("Reading LED map from "));
|
||||
DEBUG_PRINTLN(fileName);
|
||||
|
||||
// erase old custom ledmap
|
||||
if (customMappingTable != nullptr) {
|
||||
customMappingSize = 0;
|
||||
@ -1629,6 +1630,7 @@ void WS2812FX::deserializeMap(uint8_t n) {
|
||||
}
|
||||
|
||||
releaseJSONBufferLock();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -645,8 +645,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
if (subPage == 10)
|
||||
{
|
||||
strip.isMatrix = request->arg(F("SOMP")).toInt();
|
||||
// strip.panelH = MAX(1,MIN(128,request->arg(F("PH")).toInt()));
|
||||
// strip.panelW = MAX(1,MIN(128,request->arg(F("PW")).toInt()));
|
||||
strip.panel.clear(); // release memory if allocated
|
||||
if (strip.isMatrix) {
|
||||
strip.panels = MAX(1,MIN(WLED_MAX_PANELS,request->arg(F("MPC")).toInt()));
|
||||
@ -674,6 +672,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
strip.panel.push_back(p);
|
||||
}
|
||||
strip.setUpMatrix(); // will check limits
|
||||
strip.makeAutoSegments(true);
|
||||
} else {
|
||||
Segment::maxWidth = strip.getLengthTotal();
|
||||
Segment::maxHeight = 1;
|
||||
|
@ -171,15 +171,14 @@ void WLED::loop()
|
||||
}
|
||||
delete busConfigs[i]; busConfigs[i] = nullptr;
|
||||
}
|
||||
strip.finalizeInit();
|
||||
loadLedmap = 0;
|
||||
strip.finalizeInit(); // also loads default ledmap if present
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user