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

◆ applyExact()

void fl::TimeScale::applyExact ( uint32_t timeNow)
private

Definition at line 68 of file time.cpp.

68 {
69 uint32_t elapsedRealTime = timeNow - mLastRealTime;
70 mLastRealTime = timeNow;
71 int32_t diff = static_cast<int32_t>(elapsedRealTime * mTimeScale);
72 if (diff == 0) {
73 return;
74 }
75 if (diff >= 0) {
76 mRelativeTime += diff;
77 return;
78 }
79
80 // diff < 0
81 uint32_t abs_diff = -diff;
82 if (abs_diff > mRelativeTime) {
83 // Protection against rollover.
84 mRelativeTime = 0;
85 mLastRealTime = timeNow;
86 return;
87 }
88 mLastRealTime = timeNow;
89 mRelativeTime -= abs_diff;
90}
uint32_t mLastRealTime
Definition time.h:43
float mTimeScale
Definition time.h:46
uint32_t mRelativeTime
Definition time.h:45

References mLastRealTime, mRelativeTime, and mTimeScale.

Referenced by update().

+ Here is the caller graph for this function: