From 96d275e2b9d301bca715d86b8be11cda6fde2224 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 23 Feb 2024 12:34:14 +0100 Subject: [PATCH] minor optimization for PinWheel mapping use "float" math functions. These are slightly faster. By avoiding to pull in "double" math we also save some flash space. --- wled00/FX_fcn.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 1f7733f6..84e0b5ef 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -942,11 +942,11 @@ void IRAM_ATTR_YN Segment::setPixelColor(int i, uint32_t col) //WLEDMM: IRAM_ATT // int maxDistance = sqrt(centerX * centerX + centerY * centerY) + 1; int distance = 0; - float cosVal = cos(i * DEG_TO_RAD); // i = current angle - float sinVal = sin(i * DEG_TO_RAD); + float cosVal = cosf((float)i * (float)DEG_TO_RAD); // i = current angle + float sinVal = sinf((float)i * (float)DEG_TO_RAD); while (true) { - int x = round(centerX + distance * cosVal); - int y = round(centerY + distance * sinVal); + int x = roundf(centerX + distance * cosVal); + int y = roundf(centerY + distance * sinVal); // Check bounds if (x < 0 || x >= vW || y < 0 || y >= vH) { break;