MCPcopy Create free account
hub / github.com/FastLED/FastLED / Circle

Method Circle

src/fl/math/screenmap.cpp.hpp:63–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63ScreenMap ScreenMap::Circle(int numLeds, float cm_between_leds,
64 float cm_led_diameter, float completion) {
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}
92
93ScreenMap ScreenMap::DefaultStrip(int numLeds, float cm_between_leds,
94 float cm_led_diameter, float completion) {

Callers

nothing calls this directly

Calls 3

setDiameterMethod · 0.80
cosFunction · 0.70
sinFunction · 0.70

Tested by

no test coverage detected