FastLED 3.9.15
Loading...
Searching...
No Matches
frame_interpolator.cpp.hpp
Go to the documentation of this file.
3#include "fl/math/math.h"
5
6#include "fl/log/log.h"
7
8#include "fl/math/math.h"
9#include "fl/math/math.h"
10
11#define DBG FL_DBG
12
13namespace fl {
14namespace video {
15
16FrameInterpolator::FrameInterpolator(size_t nframes, float fps)
17 : mFrameTracker(fps) {
18 size_t capacity = fl::max(1, nframes);
19 mFrames.reserve(capacity);
20}
21
22bool FrameInterpolator::draw(fl::u32 now, Frame *dst) {
23 bool ok = draw(now, dst->rgb());
24 return ok;
25}
26
28 fl::u32 frameNumber, nextFrameNumber;
29 u8 amountOfNextFrame;
30 // DBG("now: " << now);
31 mFrameTracker.get_interval_frames(now, &frameNumber, &nextFrameNumber,
32 &amountOfNextFrame);
33 if (!has(frameNumber)) {
34 return false;
35 }
36
37 if (has(frameNumber) && !has(nextFrameNumber)) {
38 // just paint the current frame
39 Frame *frame = get(frameNumber).get();
40 frame->draw(leds);
41 return true;
42 }
43
44 Frame *frame1 = get(frameNumber).get();
45 Frame *frame2 = get(nextFrameNumber).get();
46
47 Frame::interpolate(*frame1, *frame2, amountOfNextFrame, leds);
48 return true;
49}
50
51} // namespace video
52} // namespace fl
fl::CRGB leds[NUM_LEDS]
fl::Video video(NUM_LEDS, 2.0f)
void draw(fl::span< CRGB > leds, DrawMode draw_mode=DrawMode::DRAW_MODE_OVERWRITE) const
Definition frame.cpp.hpp:49
void interpolate(const Frame &frame1, const Frame &frame2, u8 amountOfFrame2)
fl::span< CRGB > rgb()
Definition frame.h:42
bool has(fl::u32 frameNum) const
FramePtr get(fl::u32 frameNum) const
FrameInterpolator(size_t nframes, float fpsVideo)
bool draw(fl::u32 adjustable_time, Frame *dst)
Centralized logging categories for FastLED hardware interfaces and subsystems.
unsigned char u8
Definition stdint.h:131
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75
Base definition for an LED controller.
Definition crgb.hpp:179