FastLED 3.9.15
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 13 of file frame_tracker.cpp.hpp.

15 {
16 // Account for any pause time
17 fl::u32 effectiveTime = now;
18
19 // Convert milliseconds to microseconds for precise calculation
20 fl::u64 microseconds = static_cast<fl::u64>(effectiveTime) * 1000ULL;
21
22 // Calculate frame number with proper rounding
24 *nextFrameNumber = *frameNumber + 1;
25
26 // Calculate interpolation amount if requested
27 if (amountOfNextFrame != nullptr) {
28 fl::u64 frame1_start = (*frameNumber * mMicrosSecondsPerInterval);
29 fl::u64 frame2_start = (*nextFrameNumber * mMicrosSecondsPerInterval);
30 fl::u32 rel_time = microseconds - frame1_start;
31 fl::u32 frame_duration = frame2_start - frame1_start;
32 u8 progress = map_range<fl::u32, u8>(rel_time, 0, frame_duration, 0, 255);
33 *amountOfNextFrame = progress;
34 }
35}
duration< fl::i64, fl::micro > microseconds
Microseconds - duration with period of 1/1,000,000 seconds.
Definition chrono.h:100
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_NOEXCEPT
Definition math.h:174
fl::u64 u64
Definition s16x16x4.h:221

References fl::map_range(), and mMicrosSecondsPerInterval.

+ Here is the call graph for this function: