From 4984c578cc1365c84a611bacf0945a2410e3b504 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 21 Jul 2023 15:59:32 +0200 Subject: [PATCH] minor speedups * added IRAM_ATTR_YN to some frequently used color functions * small optimization for fade_out: pixel already has "target color" --- wled00/FX_fcn.cpp | 1 + wled00/colors.cpp | 4 ++-- wled00/led.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index b9938517..04007120 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1216,6 +1216,7 @@ void Segment::fade_out(uint8_t rate) { for (uint_fast16_t y = 0; y < rows; y++) for (uint_fast16_t x = 0; x < cols; x++) { uint32_t color = is2D() ? getPixelColorXY(x, y) : getPixelColor(x); + if (color == color2) continue; // WLEDMM speedup - pixel color = target color, so nothing to do int w1 = W(color); int r1 = R(color); int g1 = G(color); diff --git a/wled00/colors.cpp b/wled00/colors.cpp index 323edd03..c7620a71 100644 --- a/wled00/colors.cpp +++ b/wled00/colors.cpp @@ -35,7 +35,7 @@ IRAM_ATTR_YN uint32_t color_blend(uint32_t color1, uint32_t color2, uint_fast16_ * color add function that preserves ratio * idea: https://github.com/Aircoookie/WLED/pull/2465 by https://github.com/Proto-molecule */ -uint32_t color_add(uint32_t c1, uint32_t c2) +IRAM_ATTR_YN uint32_t color_add(uint32_t c1, uint32_t c2) // WLEDMM added IRAM_ATTR_YN { uint32_t r = R(c1) + R(c2); uint32_t g = G(c1) + G(c2); @@ -362,7 +362,7 @@ void calcGammaTable(float gamma) } // used for individual channel or brightness gamma correction -uint8_t gamma8(uint8_t b) +IRAM_ATTR_YN uint8_t gamma8(uint8_t b) // WLEDMM added IRAM_ATTR_YN { return gammaT[b]; } diff --git a/wled00/led.cpp b/wled00/led.cpp index 53a252a1..94e438e1 100644 --- a/wled00/led.cpp +++ b/wled00/led.cpp @@ -68,7 +68,7 @@ void toggleOnOff() //scales the brightness with the briMultiplier factor -byte scaledBri(byte in) +IRAM_ATTR_YN byte scaledBri(byte in) // WLEDMM added IRAM_ATTR_YN { if (briMultiplier == 100) return(in); // WLEDMM shortcut uint_fast16_t val = ((uint_fast16_t)in*(uint_fast16_t)briMultiplier)/100; // WLEDMM