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

◆ calculateDimensions()

void fl::anonymous_namespace{corkscrew.cpp}::calculateDimensions ( float totalTurns,
fl::u16 numLeds,
const Gap & gapParams,
fl::u16 * width,
fl::u16 * height )

Definition at line 56 of file corkscrew.cpp.

56 {
57 FL_UNUSED(gapParams);
58
59 // Calculate optimal width and height
60 float ledsPerTurn = static_cast<float>(numLeds) / totalTurns;
61 fl::u16 calc_width = static_cast<fl::u16>(fl::ceil(ledsPerTurn));
62
63 fl::u16 height_from_turns = static_cast<fl::u16>(fl::ceil(totalTurns));
64 fl::u16 calc_height;
65
66 // If the grid would have more pixels than LEDs, adjust height to better match
67 if (calc_width * height_from_turns > numLeds) {
68 // Calculate height that better matches LED count
69 calc_height = static_cast<fl::u16>(fl::ceil(static_cast<float>(numLeds) / static_cast<float>(calc_width)));
70 } else {
71 calc_height = height_from_turns;
72 }
73
74 *width = calc_width;
75 *height = calc_height;
76}
T ceil(T value)
Definition math.h:39
#define FL_UNUSED(x)
Definition unused.h:8

References calculateDimensions(), fl::ceil(), and FL_UNUSED.

Referenced by calculateDimensions().

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