FastLED 3.9.15
Loading...
Searching...
No Matches

◆ Circle()

ScreenMap fl::ScreenMap::Circle ( int numLeds,
float cm_between_leds = 1.5f,
float cm_led_diameter = 0.5f,
float completion = 1.0f )
static

Definition at line 52 of file screenmap.cpp.

53 {
54 ScreenMap screenMap(numLeds);
55
56 // radius from LED spacing
57 float circumference = numLeds * cm_between_leds;
58 float radius = circumference / (2 * PI);
59
60 // how big an arc we light vs leave dark
61 float totalAngle = completion * 2 * PI;
62 float gapAngle = 2 * PI - totalAngle;
63
64 // shift so the dark gap is centered at the bottom (–π/2)
65 float startAngle = -PI / 2 + gapAngle / 2.0f;
66
67 // if partial, land last LED exactly at startAngle+totalAngle
68 float divisor =
69 (completion < 1.0f && numLeds > 1) ? (numLeds - 1) : numLeds;
70
71 for (int i = 0; i < numLeds; ++i) {
72 float angle = startAngle + (i * totalAngle) / divisor;
73 float x = radius * cos(angle) * 2;
74 float y = radius * sin(angle) * 2;
75 screenMap[i] = {x, y};
76 }
77
78 screenMap.setDiameter(cm_led_diameter);
79 return screenMap;
80}
int y
Definition simple.h:93
int x
Definition simple.h:92
void setDiameter(float diameter)
ScreenMap()=default
fl::ScreenMap screenMap
Definition Corkscrew.h:103
#define PI
Definition math_macros.h:89

References ScreenMap(), PI, screenMap, x, and y.

Referenced by DefaultStrip(), and setup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: