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

◆ makeScreenMap()

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

Definition at line 102 of file old.h.

102 {
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}
int y
Definition simple.h:93
int x
Definition simple.h:92
fl::ScreenMap screenMap
Definition Corkscrew.h:101
#define FL_WARN(X)
Definition log.h:276
#define FL_PI
Definition math.h:26
vec2< float > vec2f
Definition geometry.h:333
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
fl::ScreenMap screenMap
Definition old.h:151
corkscrew_args args
Definition old.h:149

References args, fl::cos(), fl::vector< T >::data(), FL_PI, FL_WARN, screenMap, fl::sin(), x, and y.

+ Here is the call graph for this function: