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

◆ makeScreenMap()

fl::ScreenMap makeScreenMap ( corkscrew_args args = corkscrew_args())

Definition at line 86 of file FestivalStick.ino.

86 {
87 // Create a ScreenMap for the corkscrew
88 fl::vector<vec2f> points(args.num_leds);
89
90 int num_leds = args.num_leds;
91 float leds_per_turn = args.leds_per_turn;
92 float width_cm = args.width_cm;
93
94
95 const float circumference = leds_per_turn;
96 const float radius = circumference / (2.0 * PI); // radius in mm
97 const float angle_per_led = 2.0 * PI / leds_per_turn; // degrees per LED
98 const float height_per_turn_cm = width_cm; // 10cm height per turn
99 const float height_per_led =
100 height_per_turn_cm /
101 leds_per_turn * 1.3; // this is the changing height per led.
102
103
104
105 for (int i = 0; i < num_leds; i++) {
106 float angle = i * angle_per_led; // angle in radians
107 float r = radius + 10 + i * height_per_led; // height in cm
108
109 // Calculate the x, y coordinates for the corkscrew
110 float x = r * cos(angle); // x coordinate
111 float y = r * sin(angle); // y coordinate
112
113 // Store the 2D coordinates in the vector
114 points[i] = vec2f(x, y);
115 }
116
117 FASTLED_WARN("Creating ScreenMap with:\n" << points);
118
119 // Create a ScreenMap from the points
120 fl::ScreenMap screenMap(points.data(), num_leds, 1.0);
121 return screenMap;
122}
int y
Definition Audio.ino:72
int x
Definition Audio.ino:71
fl::ScreenMap screenMap
corkscrew_args args
#define PI
Definition math_macros.h:57
vec2< float > vec2f
Definition geometry.h:301
HeapVector< T > vector
Definition vector.h:1028
#define FASTLED_WARN
Definition warn.h:7

References args, fl::HeapVector< T >::data(), FASTLED_WARN, PI, screenMap, x, and y.

+ Here is the call graph for this function: