pull/3763/head^2
Blaz Kristan 2024-04-09 08:25:07 +02:00
rodzic ba9ce4adf2
commit 58e8346209
2 zmienionych plików z 17 dodań i 12 usunięć

Wyświetl plik

@ -65,9 +65,10 @@ void WS2812FX::setUpMatrix() {
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();
// fill with empty in case we don't fill the entire matrix
@ -138,7 +139,7 @@ void WS2812FX::setUpMatrix() {
DEBUG_PRINTLN();
#endif
} else { // memory allocation error
DEBUG_PRINTLN(F("Ledmap alloc error."));
DEBUG_PRINTLN(F("ERROR 2D LED map allocation error."));
isMatrix = false;
panels = 0;
panel.clear();

Wyświetl plik

@ -1656,19 +1656,23 @@ bool WS2812FX::deserializeMap(uint8_t n) {
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()];
JsonObject root = pDoc->as<JsonObject>();
JsonArray map = root[F("map")];
if (!map.isNull() && map.size()) { // not an empty map
customMappingSize = min((unsigned)map.size(), (unsigned)getLengthTotal());
for (unsigned i=0; i<customMappingSize; i++) customMappingTable[i] = (uint16_t) (map[i]<0 ? 0xFFFFU : map[i]);
if (customMappingTable) {
DEBUG_PRINT(F("Reading LED map from ")); DEBUG_PRINTLN(fileName);
JsonObject root = pDoc->as<JsonObject>();
JsonArray map = root[F("map")];
if (!map.isNull() && map.size()) { // not an empty map
customMappingSize = min((unsigned)map.size(), (unsigned)getLengthTotal());
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();
return true;
return (customMappingSize > 0);
}
uint16_t IRAM_ATTR WS2812FX::getMappedPixelIndex(uint16_t index) {