mirror of
https://github.com/wled/WLED.git
synced 2025-04-26 15:57:18 +00:00
Fix for #3889
This commit is contained in:
parent
ba9ce4adf2
commit
58e8346209
@ -65,9 +65,10 @@ void WS2812FX::setUpMatrix() {
|
|||||||
|
|
||||||
customMappingSize = 0; // prevent use of mapping if anything goes wrong
|
customMappingSize = 0; // prevent use of mapping if anything goes wrong
|
||||||
|
|
||||||
if (customMappingTable == nullptr) customMappingTable = new uint16_t[getLengthTotal()];
|
if (customMappingTable) delete[] customMappingTable;
|
||||||
|
customMappingTable = new uint16_t[getLengthTotal()];
|
||||||
|
|
||||||
if (customMappingTable != nullptr) {
|
if (customMappingTable) {
|
||||||
customMappingSize = getLengthTotal();
|
customMappingSize = getLengthTotal();
|
||||||
|
|
||||||
// fill with empty in case we don't fill the entire matrix
|
// fill with empty in case we don't fill the entire matrix
|
||||||
@ -138,7 +139,7 @@ void WS2812FX::setUpMatrix() {
|
|||||||
DEBUG_PRINTLN();
|
DEBUG_PRINTLN();
|
||||||
#endif
|
#endif
|
||||||
} else { // memory allocation error
|
} else { // memory allocation error
|
||||||
DEBUG_PRINTLN(F("Ledmap alloc error."));
|
DEBUG_PRINTLN(F("ERROR 2D LED map allocation error."));
|
||||||
isMatrix = false;
|
isMatrix = false;
|
||||||
panels = 0;
|
panels = 0;
|
||||||
panel.clear();
|
panel.clear();
|
||||||
|
@ -1656,19 +1656,23 @@ bool WS2812FX::deserializeMap(uint8_t n) {
|
|||||||
return false; // if file does not load properly then exit
|
return false; // if file does not load properly then exit
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_PRINT(F("Reading LED map from ")); DEBUG_PRINTLN(fileName);
|
if (customMappingTable) delete[] customMappingTable;
|
||||||
|
customMappingTable = new uint16_t[getLengthTotal()];
|
||||||
|
|
||||||
if (customMappingTable == nullptr) customMappingTable = new uint16_t[getLengthTotal()];
|
if (customMappingTable) {
|
||||||
|
DEBUG_PRINT(F("Reading LED map from ")); DEBUG_PRINTLN(fileName);
|
||||||
JsonObject root = pDoc->as<JsonObject>();
|
JsonObject root = pDoc->as<JsonObject>();
|
||||||
JsonArray map = root[F("map")];
|
JsonArray map = root[F("map")];
|
||||||
if (!map.isNull() && map.size()) { // not an empty map
|
if (!map.isNull() && map.size()) { // not an empty map
|
||||||
customMappingSize = min((unsigned)map.size(), (unsigned)getLengthTotal());
|
customMappingSize = min((unsigned)map.size(), (unsigned)getLengthTotal());
|
||||||
for (unsigned i=0; i<customMappingSize; i++) customMappingTable[i] = (uint16_t) (map[i]<0 ? 0xFFFFU : map[i]);
|
for (unsigned i=0; i<customMappingSize; i++) customMappingTable[i] = (uint16_t) (map[i]<0 ? 0xFFFFU : map[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DEBUG_PRINTLN(F("ERROR LED map allocation error."));
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseJSONBufferLock();
|
releaseJSONBufferLock();
|
||||||
return true;
|
return (customMappingSize > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t IRAM_ATTR WS2812FX::getMappedPixelIndex(uint16_t index) {
|
uint16_t IRAM_ATTR WS2812FX::getMappedPixelIndex(uint16_t index) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user