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

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

64 {
65 ScreenMap screenMap(numLeds);
66
67 // radius from LED spacing
68 float circumference = numLeds * cm_between_leds;
69 float radius = circumference / (2 * FL_PI);
70
71 // how big an arc we light vs leave dark
72 float totalAngle = completion * 2 * FL_PI;
73 float gapAngle = 2 * FL_PI - totalAngle;
74
75 // shift so the dark gap is centered at the bottom (–π/2)
76 float startAngle = -FL_PI / 2 + gapAngle / 2.0f;
77
78 // if partial, land last LED exactly at startAngle+totalAngle
79 float divisor =
80 (completion < 1.0f && numLeds > 1) ? (numLeds - 1) : numLeds;
81
82 for (int i = 0; i < numLeds; ++i) {
83 float angle = startAngle + (i * totalAngle) / divisor;
84 float x = radius * cos(angle) * 2;
85 float y = radius * sin(angle) * 2;
86 screenMap[i] = {x, y};
87 }
88
89 screenMap.setDiameter(cm_led_diameter);
90 return screenMap;
91}
ScreenMap() FL_NOEXCEPT
void setDiameter(float diameter) FL_NOEXCEPT
fl::ScreenMap screenMap
Definition Corkscrew.h:101
#define FL_PI
Definition math.h:26
enable_if< is_fixed_point< T >::value, T >::type cos(T angle) FL_NOEXCEPT
enable_if< is_fixed_point< T >::value, T >::type sin(T angle) FL_NOEXCEPT

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: