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

◆ makeScreenMap()

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

Definition at line 76 of file curr.h.

76 {
77 // Create a ScreenMap for the corkscrew
78 fl::vector<vec2f> points(args.num_leds);
79
80 int num_leds = args.num_leds;
81 float leds_per_turn = args.leds_per_turn;
82 float width_cm = args.width_cm;
83
84 const float circumference = leds_per_turn;
85 const float radius = circumference / (2.0 * PI); // radius in mm
86 const float angle_per_led = 2.0 * PI / leds_per_turn; // degrees per LED
87 const float height_per_turn_cm = width_cm; // 10cm height per turn
88 const float height_per_led = height_per_turn_cm / leds_per_turn *
89 1.3; // this is the changing height per led.
90
91 for (int i = 0; i < num_leds; i++) {
92 float angle = i * angle_per_led; // angle in radians
93 float r = radius + 10 + i * height_per_led; // height in cm
94
95 // Calculate the x, y coordinates for the corkscrew
96 float x = r * cos(angle); // x coordinate
97 float y = r * sin(angle); // y coordinate
98
99 // Store the 2D coordinates in the vector
100 points[i] = vec2f(x, y);
101 }
102
103 FASTLED_WARN("Creating ScreenMap with:\n" << points);
104
105 // Create a ScreenMap from the points
106 fl::ScreenMap screenMap(points.data(), num_leds, .5);
107 return screenMap;
108}
int y
Definition Audio.ino:72
int x
Definition Audio.ino:71
fl::ScreenMap screenMap
Definition curr.h:119
#define PI
Definition math_macros.h:63
vec2< float > vec2f
Definition geometry.h:318
HeapVector< T, Allocator > vector
Definition vector.h:1074
corkscrew_args args
Definition old.h:142
#define FASTLED_WARN
Definition warn.h:7

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

+ Here is the call graph for this function: