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

◆ easeInOutSine16()

u16 fl::easeInOutSine16 ( u16 i)

16-bit sine ease-in/ease-out function Takes an input value 0-65535 and returns an eased value 0-65535

Definition at line 317 of file ease.cpp.

317 {
318 // ease-in-out sine: -(cos(π*t) - 1) / 2
319 // Handle boundary conditions explicitly
320 if (i == 0)
321 return 0;
322 if (i == 65535)
323 return 65535;
324
325 // For 16-bit: use cos32 for efficiency and accuracy
326 // Map i from [0,65535] to [0,8388608] in cos32 space (0 to half wave)
327 // Formula: (1 - cos(π*t)) / 2 where t goes from 0 to 1
328 // sin32/cos32 half cycle is 16777216/2 = 8388608
329 u32 angle = ((fl::u64)i * 8388608ULL) / 65535ULL;
330 i32 cos_result = fl::cos32(angle);
331
332 // Convert cos32 output and apply easing formula: (1 - cos(π*t)) / 2
333 // cos32 output range is [-2147418112, 2147418112]
334 // We want: (2147418112 - cos_result) / 2, then scale to [0, 65535]
335 fl::i64 adjusted = (2147418112LL - (fl::i64)cos_result) / 2;
336 return (u16)((fl::u64)adjusted * 65535ULL / 2147418112ULL);
337}
static FASTLED_FORCE_INLINE i32 cos32(u32 angle)
Definition sin32.h:45

References cos32().

Referenced by ease16(), ease16(), and easeInOutSine8().

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