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

Function calculateDimensions

src/fl/gfx/corkscrew.cpp.hpp:56–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void calculateDimensions(float totalTurns, fl::u16 numLeds, const Gap& gapParams, fl::u16 *width, fl::u16 *height) {
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}
77
78} // namespace
79

Callers 1

CorkscrewMethod · 0.85

Calls 1

ceilFunction · 0.85

Tested by

no test coverage detected