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.
This commit is contained in:
Frank
2024-02-23 12:34:14 +01:00
committed by GitHub
parent 07b770958f
commit 96d275e2b9

View File

@@ -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 maxDistance = sqrt(centerX * centerX + centerY * centerY) + 1;
int distance = 0; int distance = 0;
float cosVal = cos(i * DEG_TO_RAD); // i = current angle float cosVal = cosf((float)i * (float)DEG_TO_RAD); // i = current angle
float sinVal = sin(i * DEG_TO_RAD); float sinVal = sinf((float)i * (float)DEG_TO_RAD);
while (true) { while (true) {
int x = round(centerX + distance * cosVal); int x = roundf(centerX + distance * cosVal);
int y = round(centerY + distance * sinVal); int y = roundf(centerY + distance * sinVal);
// Check bounds // Check bounds
if (x < 0 || x >= vW || y < 0 || y >= vH) { if (x < 0 || x >= vW || y < 0 || y >= vH) {
break; break;