report out-of-memory situations to the user

This commit is contained in:
Frank
2024-04-16 19:10:46 +02:00
parent b27686bd2b
commit 019cafc5e0
6 changed files with 42 additions and 11 deletions

View File

@@ -80,7 +80,10 @@ void WS2812FX::setUpMatrix() {
if ((size > 0) && (customMappingTable == nullptr)) { // second try
DEBUG_PRINTLN("setUpMatrix: trying to get fresh memory block.");
customMappingTable = (uint16_t*) calloc(size, sizeof(uint16_t));
if (customMappingTable == nullptr) USER_PRINTLN("setUpMatrix: alloc failed");
if (customMappingTable == nullptr) {
USER_PRINTLN("setUpMatrix: alloc failed");
errorFlag = ERR_LOW_MEM; // WLEDMM raise errorflag
}
}
if (customMappingTable != nullptr) customMappingTableSize = size;
}
@@ -159,6 +162,7 @@ void WS2812FX::setUpMatrix() {
} else { // memory allocation error
customMappingTableSize = 0;
USER_PRINTLN(F("Ledmap alloc error."));
errorFlag = ERR_LOW_MEM; // WLEDMM raise errorflag
isMatrix = false; //WLEDMM does not like this done in teh background while end users are confused whats happened...
panels = 0;
panel.clear();