FastLED 3.9.15
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages

◆ 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 21 of file screenmap.cpp.

22 {
23 ScreenMap screenMap(numLeds);
24
25 // radius from LED spacing
26 float circumference = numLeds * cm_between_leds;
27 float radius = circumference / (2 * PI);
28
29 // how big an arc we light vs leave dark
30 float totalAngle = completion * 2 * PI;
31 float gapAngle = 2 * PI - totalAngle;
32
33 // shift so the dark gap is centered at the bottom (–π/2)
34 float startAngle = -PI / 2 + gapAngle / 2.0f;
35
36 // if partial, land last LED exactly at startAngle+totalAngle
37 float divisor =
38 (completion < 1.0f && numLeds > 1) ? (numLeds - 1) : numLeds;
39
40 for (int i = 0; i < numLeds; ++i) {
41 float angle = startAngle + (i * totalAngle) / divisor;
42 float x = radius * cos(angle) * 2;
43 float y = radius * sin(angle) * 2;
44 screenMap[i] = {x, y};
45 }
46
47 screenMap.setDiameter(cm_led_diameter);
48 return screenMap;
49}
int y
Definition Audio.ino:72
int x
Definition Audio.ino:71
void setDiameter(float diameter)
ScreenMap()=default
fl::ScreenMap screenMap
Definition curr.h:119
#define PI
Definition math_macros.h:63

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: