FastLED 3.10.8
Loading...
Searching...
No Matches

◆ get_interval_frames()

void fl::video::FrameTracker::get_interval_frames ( fl::u32 now,
fl::u32 * frameNumber,
fl::u32 * nextFrameNumber,
u8 * amountOfNextFrame = nullptr ) const

Definition at line 14 of file frame_tracker.cpp.hpp.

16 {
17 // Account for any pause time
18 fl::u32 effectiveTime = now;
19
20 // Convert milliseconds to microseconds for precise calculation
21 fl::u64 microseconds = static_cast<fl::u64>(effectiveTime) * 1000ULL;
22
23 // Calculate frame number with proper rounding
25 *nextFrameNumber = *frameNumber + 1;
26
27 // Calculate interpolation amount if requested
28 if (amountOfNextFrame != nullptr) {
29 fl::u64 frame1_start =
30 static_cast<fl::u64>(*frameNumber) * mMicrosSecondsPerInterval;
31 fl::u64 frame2_start =
32 static_cast<fl::u64>(*nextFrameNumber) * mMicrosSecondsPerInterval;
33 fl::u32 rel_time = microseconds - frame1_start;
34 fl::u32 frame_duration = frame2_start - frame1_start;
35 u8 progress = map_range<fl::u32, u8>(rel_time, 0, frame_duration, 0, 255);
36 *amountOfNextFrame = progress;
37 }
38}
duration< fl::i64, fl::micro > microseconds
Microseconds - duration with period of 1/1,000,000 seconds.
Definition chrono.h:103
unsigned char u8
Definition stdint.h:131
FASTLED_FORCE_INLINE U map_range(T value, T in_min, T in_max, U out_min, U out_max) FL_NO_EXCEPT
Definition math.h:182

References fl::FL_NO_EXCEPT, fl::map_range(), and mMicrosSecondsPerInterval.

+ Here is the call graph for this function: