minor speedups

* added IRAM_ATTR_YN to some frequently used color functions
* small optimization for fade_out: pixel already has "target color"
This commit is contained in:
Frank
2023-07-21 15:59:32 +02:00
parent 5707d85ed5
commit 4984c578cc
3 changed files with 4 additions and 3 deletions

View File

@@ -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);

View File

@@ -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];
}

View File

@@ -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