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

Method get_interval_frames

src/fl/video/frame_tracker.cpp.hpp:13–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13void FrameTracker::get_interval_frames(fl::u32 now, fl::u32 *frameNumber,
14 fl::u32 *nextFrameNumber,
15 u8 *amountOfNextFrame) const {
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
23 *frameNumber = microseconds / mMicrosSecondsPerInterval;
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}
36
37fl::u32 FrameTracker::get_exact_timestamp_ms(fl::u32 frameNumber) const {
38 fl::u64 microseconds = frameNumber * mMicrosSecondsPerInterval;

Callers 3

needsFrameMethod · 0.80
drawMethod · 0.80
FL_TEST_FILEFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected