FastLED 3.10.6
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
Examples
FxNoiseRing.ino.

Definition at line 86 of file screenmap.cpp.hpp.

87 {
88 ScreenMap screenMap(numLeds);
89
90 // radius from LED spacing
91 float circumference = numLeds * cm_between_leds;
92 float radius = circumference / (2 * FL_PI);
93
94 // how big an arc we light vs leave dark
95 float totalAngle = completion * 2 * FL_PI;
96 float gapAngle = 2 * FL_PI - totalAngle;
97
98 // shift so the dark gap is centered at the bottom (–π/2)
99 float startAngle = -FL_PI / 2 + gapAngle / 2.0f;
100
101 // if partial, land last LED exactly at startAngle+totalAngle
102 float divisor =
103 (completion < 1.0f && numLeds > 1) ? (numLeds - 1) : numLeds;
104
105 for (int i = 0; i < numLeds; ++i) {
106 float angle = startAngle + (i * totalAngle) / divisor;
107 float x = radius * cos(angle) * 2;
108 float y = radius * sin(angle) * 2;
109 screenMap[i] = {x, y};
110 }
111
112 screenMap.setDiameter(cm_led_diameter);
113 return screenMap;
114}
ScreenMap() FL_NO_EXCEPT
void setDiameter(float diameter) FL_NO_EXCEPT
fl::ScreenMap screenMap
Definition Corkscrew.h:101
#define FL_PI
Definition math.h:26
enable_if< is_fixed_point< T >::value, T >::type sin(T angle) FL_NO_EXCEPT
enable_if< is_fixed_point< T >::value, T >::type cos(T angle) FL_NO_EXCEPT

References ScreenMap(), fl::cos(), FL_PI, screenMap, fl::sin(), fl::x, and fl::y.

Referenced by DefaultStrip(), and setup().

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