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:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user