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

◆ calculateLedPositionExtended()

vec2f fl::anonymous_namespace{corkscrew.cpp}::calculateLedPositionExtended ( fl::u16 ledIndex,
fl::u16 numLeds,
float totalTurns,
const Gap & gapParams,
fl::u16 width,
fl::u16 height )

Definition at line 25 of file corkscrew.cpp.

25 {
26 FL_UNUSED(height);
27 FL_UNUSED(totalTurns);
28
29 // Check if gap feature is active AND will actually be triggered
30 bool gapActive = (gapParams.num_leds > 0 && gapParams.gap > 0.0f && numLeds > static_cast<fl::u16>(gapParams.num_leds));
31
32 if (!gapActive) {
33 // Original behavior when no gap or gap never triggers
34 const float ledProgress = static_cast<float>(ledIndex) / static_cast<float>(numLeds - 1);
35 const fl::u16 row = ledIndex / width;
36 const fl::u16 remainder = ledIndex % width;
37 const float alpha = static_cast<float>(remainder) / static_cast<float>(width);
38 const float width_pos = ledProgress * numLeds;
39 const float height_pos = static_cast<float>(row) + alpha;
40 return vec2f(width_pos, height_pos);
41 }
42
43 // Simplified gap calculation based on user expectation
44 // User wants: LED0=0, LED1=3, LED2=6(wraps to 0) with width=3
45 // This suggests they want regular spacing of width units per LED
46
47 // Simple spacing: each LED is separated by exactly width units
48 float width_pos = static_cast<float>(ledIndex) * static_cast<float>(width);
49
50 // For height, divide by width to get turn progress
51 float height_pos = width_pos / static_cast<float>(width);
52
53 return vec2f(width_pos, height_pos);
54}
vec2< float > vec2f
Definition geometry.h:333
int num_leds
Definition corkscrew.h:67
float gap
Definition corkscrew.h:68
#define FL_UNUSED(x)
Definition unused.h:8

References calculateLedPositionExtended(), FL_UNUSED, fl::Gap::gap, and fl::Gap::num_leds.

Referenced by calculateLedPositionExtended().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: