Skip to content

Commit 96d275e

Browse files
authored
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.
1 parent 07b7709 commit 96d275e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

wled00/FX_fcn.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -942,11 +942,11 @@ void IRAM_ATTR_YN Segment::setPixelColor(int i, uint32_t col) //WLEDMM: IRAM_ATT
942942
// int maxDistance = sqrt(centerX * centerX + centerY * centerY) + 1;
943943

944944
int distance = 0;
945-
float cosVal = cos(i * DEG_TO_RAD); // i = current angle
946-
float sinVal = sin(i * DEG_TO_RAD);
945+
float cosVal = cosf((float)i * (float)DEG_TO_RAD); // i = current angle
946+
float sinVal = sinf((float)i * (float)DEG_TO_RAD);
947947
while (true) {
948-
int x = round(centerX + distance * cosVal);
949-
int y = round(centerY + distance * sinVal);
948+
int x = roundf(centerX + distance * cosVal);
949+
int y = roundf(centerY + distance * sinVal);
950950
// Check bounds
951951
if (x < 0 || x >= vW || y < 0 || y >= vH) {
952952
break;

0 commit comments

Comments
 (0)