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

Function makeScreenMap

examples/FestivalStick/old.h:102–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101
102fl::ScreenMap makeScreenMap(corkscrew_args args = corkscrew_args()) {
103 // Create a fl::ScreenMap for the corkscrew
104 fl::vector<vec2f> points(args.num_leds);
105
106 int num_leds = args.num_leds;
107 float leds_per_turn = args.leds_per_turn;
108 float width_cm = args.width_cm;
109
110
111 const float circumference = leds_per_turn;
112 const float radius = circumference / (2.0 * FL_PI); // radius in mm
113 const float angle_per_led = 2.0 * FL_PI / leds_per_turn; // degrees per LED
114 const float height_per_turn_cm = width_cm; // 10cm height per turn
115 const float height_per_led =
116 height_per_turn_cm /
117 leds_per_turn * 1.3; // this is the changing height per led.
118
119
120
121 for (int i = 0; i < num_leds; i++) {
122 float angle = i * angle_per_led; // angle in radians
123 float r = radius + 10 + i * height_per_led; // height in cm
124
125 // Calculate the x, y coordinates for the corkscrew
126 float x = r * fl::cos(angle); // x coordinate
127 float y = r * fl::sin(angle); // y coordinate
128
129 // Store the 2D coordinates in the fl::vector
130 points[i] = vec2f(x, y);
131 }
132
133 FL_WARN("Creating fl::ScreenMap with:\n" << points);
134
135 // Create a fl::ScreenMap from the points
136 fl::ScreenMap screenMap(points.data(), num_leds, .5);
137 return screenMap;
138}
139
140
141// Create a corkscrew with:

Callers 1

setupFunction · 0.70

Calls 4

corkscrew_argsClass · 0.85
cosFunction · 0.50
sinFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected