small improvements

* optimized fadeToBlackBy() - don't repaint unchanged pixels
* made MIN_HEAP_SIZE configurable by build_flags
* specific error message when not enough memory for LEDs buffer
This commit is contained in:
Frank
2024-08-05 17:06:38 +02:00
parent 18f9d64e24
commit 5f4834dec4
3 changed files with 11 additions and 3 deletions

View File

@@ -132,7 +132,7 @@ void Segment::allocLeds() {
ledsrgbSize = ledsrgb?size:0;
if (ledsrgb == nullptr) {
USER_PRINTLN("allocLeds failed!!");
errorFlag = ERR_LOW_MEM; // WLEDMM raise errorflag
errorFlag = ERR_LOW_BUF; // WLEDMM raise errorflag
}
}
else {
@@ -1442,8 +1442,10 @@ void Segment::fadeToBlackBy(uint8_t fadeBy) {
// WLEDMM minor optimization
if(is2D()) {
for (uint_fast16_t y = 0; y < rows; y++) for (uint_fast16_t x = 0; x < cols; x++) {
setPixelColorXY((uint16_t)x, (uint16_t)y, CRGB(getPixelColorXY(x,y)).nscale8(scaledown));
for (int y = 0; y < rows; y++) for (int x = 0; x < cols; x++) {
uint32_t cc = getPixelColorXY(x,y); // WLEDMM avoid RGBW32 -> CRGB -> RGBW32 conversion
uint32_t cc2 = color_fade(cc, scaledown); // fade
if (cc2 != cc) setPixelColorXY((uint16_t)x, (uint16_t)y, cc2); // WLEDMM only re-paint if faded color is different
}
} else {
for (uint_fast16_t x = 0; x < cols; x++) {

View File

@@ -352,6 +352,7 @@
#define ERR_LOW_SEG_MEM 34 // WLEDMM: low memory (segment data RAM)
#define ERR_LOW_WS_MEM 35 // WLEDMM: low memory (ws)
#define ERR_LOW_AJAX_MEM 36 // WLEDMM: low memory (oappend)
#define ERR_LOW_BUF 37 // WLEDMM: low memory (LED buffer from allocLEDs)
// Timer mode types
#define NL_MODE_SET 0 //After nightlight time elapsed, set to target brightness
@@ -480,7 +481,9 @@
#endif
//#define MIN_HEAP_SIZE (8k for AsyncWebServer)
#if !defined(MIN_HEAP_SIZE)
#define MIN_HEAP_SIZE 8192
#endif
// Maximum size of node map (list of other WLED instances)
#ifdef ESP8266

View File

@@ -2008,6 +2008,9 @@ function readState(s,command=false)
case 36:
errstr = "Low Memory (oappend buffer).";
break;
case 37:
errstr = "no memory for LEDs buffer.";
break;
}
showToast('Error ' + s.error + ": " + errstr, true);
}