small speedup

* currentBri() is called for any setpixelColor(), so we can speed up everything (a bit) by allowing the compiler to inline which saves a few cycles of call/return overhead.
* aligned the function with upstream, and added another optimization by only calling progress() when a transition is active.
This commit is contained in:
Frank
2024-01-26 17:08:37 +01:00
parent f456e065c6
commit 302f18fbfe
2 changed files with 19 additions and 5 deletions

View File

@@ -589,7 +589,18 @@ typedef struct Segment {
void startTransition(uint16_t dur); // transition has to start before actual segment values change
void handleTransition(void);
uint16_t progress(void); //transition progression between 0-65535
uint8_t currentBri(uint8_t briNew, bool useCct = false);
// WLEDMM method inlined for speed (its called at each setPixelColor)
inline uint8_t currentBri(uint8_t briNew, bool useCct = false) {
uint32_t prog = (transitional && _t) ? progress() : 0xFFFFU;
if (transitional && _t && prog < 0xFFFFU) {
if (useCct) return ((briNew * prog) + _t->_cctT * (0xFFFFU - prog)) >> 16;
else return ((briNew * prog) + _t->_briT * (0xFFFFU - prog)) >> 16;
} else {
return (useCct ? briNew : (on ? briNew : 0)); // WLEDMM aligned with upstream
}
}
uint8_t currentMode(uint8_t modeNew);
uint32_t currentColor(uint8_t slot, uint32_t colorNew);
CRGBPalette16 &loadPalette(CRGBPalette16 &tgt, uint8_t pal);