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

◆ get_interval_frames()

void fl::FrameTracker::get_interval_frames ( uint32_t now,
uint32_t * frameNumber,
uint32_t * nextFrameNumber,
uint8_t * amountOfNextFrame = nullptr ) const

Definition at line 22 of file frame_tracker.cpp.

24 {
25 // Account for any pause time
26 uint32_t effectiveTime = now;
27
28 // Convert milliseconds to microseconds for precise calculation
29 uint64_t microseconds = static_cast<uint64_t>(effectiveTime) * 1000ULL;
30
31 // Calculate frame number with proper rounding
32 *frameNumber = microseconds / mMicrosSecondsPerInterval;
33 *nextFrameNumber = *frameNumber + 1;
34
35 // Calculate interpolation amount if requested
36 if (amountOfNextFrame != nullptr) {
37 uint64_t frame1_start = (*frameNumber * mMicrosSecondsPerInterval);
38 uint64_t frame2_start = (*nextFrameNumber * mMicrosSecondsPerInterval);
39 uint32_t rel_time = microseconds - frame1_start;
40 uint32_t frame_duration = frame2_start - frame1_start;
41 uint8_t progress = uint8_t(map(rel_time, 0, frame_duration, 0, 255));
42 *amountOfNextFrame = progress;
43 }
44}
uint32_t mMicrosSecondsPerInterval
long map(long x, long in_min, long in_max, long out_min, long out_max)

References mMicrosSecondsPerInterval.