- 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:
Blaz Kristan 2023-02-11 18:41:30 +01:00
parent 8dd1f89225
commit eee9274098
5 changed files with 17 additions and 17 deletions

View File

@ -727,8 +727,7 @@ class WS2812FX { // 96 bytes
fixInvalidSegments(), fixInvalidSegments(),
setPixelColor(int n, uint32_t c), setPixelColor(int n, uint32_t c),
show(void), show(void),
setTargetFps(uint8_t fps), setTargetFps(uint8_t fps);
deserializeMap(uint8_t n=0);
void fill(uint32_t c) { for (int i = 0; i < _length; i++) setPixelColor(i, c); } // fill whole strip with color (inline) 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 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), hasCCTBus(void),
// return true if the strip is being sent pixel updates // return true if the strip is being sent pixel updates
isUpdating(void), isUpdating(void),
deserializeMap(uint8_t n=0),
useLedsArray = false; useLedsArray = false;
inline bool isServicing(void) { return _isServicing; } inline bool isServicing(void) { return _isServicing; }

View File

@ -87,7 +87,7 @@ void WS2812FX::setUpMatrix() {
// allowed values are: -1 (missing pixel/no LED attached), 0 (inactive/unused pixel), 1 (active/used pixel) // 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 char fileName[32]; strcpy_P(fileName, PSTR("/2d-gaps.json")); // reduce flash footprint
bool isFile = WLED_FS.exists(fileName); bool isFile = WLED_FS.exists(fileName);
int gapSize = 0; size_t gapSize = 0;
int8_t *gapTable = nullptr; int8_t *gapTable = nullptr;
if (isFile && requestJSONBufferLock(20)) { if (isFile && requestJSONBufferLock(20)) {
@ -108,6 +108,7 @@ void WS2812FX::setUpMatrix() {
} }
} }
} }
DEBUG_PRINTLN(F("Gaps loaded."));
releaseJSONBufferLock(); releaseJSONBufferLock();
} }
@ -147,7 +148,6 @@ void WS2812FX::setUpMatrix() {
Segment::maxWidth = _length; Segment::maxWidth = _length;
Segment::maxHeight = 1; Segment::maxHeight = 1;
} }
resetSegments();
} }
#else #else
isMatrix = false; // no matter what config says isMatrix = false; // no matter what config says

View File

@ -1417,7 +1417,7 @@ void WS2812FX::makeAutoSegments(bool forceReset) {
} }
// do we have LEDs after the matrix? (ignore buses) // do we have LEDs after the matrix? (ignore buses)
if (autoSegments && _length > Segment::maxWidth*Segment::maxHeight /*&& getActiveSegmentsNum() == 2*/) { 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)); _segments.push_back(Segment(Segment::maxWidth*Segment::maxHeight, _length));
else { else {
size_t i = getLastActiveSegmentId() + 1; 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 //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 WS2812FX::checkSegmentAlignment() {
bool aligned = false; bool aligned = false;
for (segment &seg : _segments) { for (segment &seg : _segments) {
@ -1583,7 +1584,7 @@ void WS2812FX::loadCustomPalettes() {
} }
//load custom mapping table from JSON file (called from finalizeInit() or deserializeState()) //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. // 2D support creates its own ledmap (on the fly) if a ledmap.json exists it will overwrite built one.
char fileName[32]; char fileName[32];
@ -1599,19 +1600,19 @@ void WS2812FX::deserializeMap(uint8_t n) {
delete[] customMappingTable; delete[] customMappingTable;
customMappingTable = nullptr; customMappingTable = nullptr;
} }
return; return false;
} }
if (!requestJSONBufferLock(7)) return; if (!requestJSONBufferLock(7)) return false;
DEBUG_PRINT(F("Reading LED map from "));
DEBUG_PRINTLN(fileName);
if (!readObjectFromFile(fileName, nullptr, &doc)) { if (!readObjectFromFile(fileName, nullptr, &doc)) {
releaseJSONBufferLock(); 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 // erase old custom ledmap
if (customMappingTable != nullptr) { if (customMappingTable != nullptr) {
customMappingSize = 0; customMappingSize = 0;
@ -1629,6 +1630,7 @@ void WS2812FX::deserializeMap(uint8_t n) {
} }
releaseJSONBufferLock(); releaseJSONBufferLock();
return true;
} }

View File

@ -645,8 +645,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
if (subPage == 10) if (subPage == 10)
{ {
strip.isMatrix = request->arg(F("SOMP")).toInt(); 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 strip.panel.clear(); // release memory if allocated
if (strip.isMatrix) { if (strip.isMatrix) {
strip.panels = MAX(1,MIN(WLED_MAX_PANELS,request->arg(F("MPC")).toInt())); 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.panel.push_back(p);
} }
strip.setUpMatrix(); // will check limits strip.setUpMatrix(); // will check limits
strip.makeAutoSegments(true);
} else { } else {
Segment::maxWidth = strip.getLengthTotal(); Segment::maxWidth = strip.getLengthTotal();
Segment::maxHeight = 1; Segment::maxHeight = 1;

View File

@ -171,15 +171,14 @@ void WLED::loop()
} }
delete busConfigs[i]; busConfigs[i] = nullptr; delete busConfigs[i]; busConfigs[i] = nullptr;
} }
strip.finalizeInit(); strip.finalizeInit(); // also loads default ledmap if present
loadLedmap = 0;
if (aligned) strip.makeAutoSegments(); if (aligned) strip.makeAutoSegments();
else strip.fixInvalidSegments(); else strip.fixInvalidSegments();
yield(); yield();
serializeConfig(); serializeConfig();
} }
if (loadLedmap >= 0) { if (loadLedmap >= 0) {
strip.deserializeMap(loadLedmap); if (!strip.deserializeMap(loadLedmap) && strip.isMatrix && loadLedmap == 0) strip.setUpMatrix();
loadLedmap = -1; loadLedmap = -1;
} }