FastLED 3.9.7
Loading...
Searching...
No Matches
time.h
1#pragma once
2
3#include <stdint.h>
4
5#include "fl/ptr.h"
6#include "fl/callback.h"
7#include "fl/namespace.h"
8
9namespace fl {
10
11FASTLED_SMART_PTR(TimeFunction);
12FASTLED_SMART_PTR(TimeScale);
13
14
15// Interface for time generation and time manipulation.
17 public:
18 virtual ~TimeFunction() {}
19 virtual uint32_t update(uint32_t timeNow) = 0; // Inputs the real clock time and outputs the virtual time.
20 virtual uint32_t time() const = 0;
21 virtual void reset(uint32_t realTimeNow) = 0;
22};
23
24// Time clock, but you can warp time. Scale can go negative for back and
25// forth time based effects. Starts at 0.
26class TimeScale: public TimeFunction {
27 public:
28 TimeScale(uint32_t realTimeNow, float initialTimeScale = 1.0f);
29 ~TimeScale();
30 void setScale(float timeScale);
31 float scale() const;
32 uint32_t update(uint32_t timeNow) override;
33 uint32_t time() const override;
34 void reset(uint32_t realTimeNow) override;
35 void pause(uint32_t now);
36 void resume(uint32_t now);
37 private:
38 void applyExact(uint32_t timeNow);
39 uint32_t mLastRealTime = 0;
40 uint32_t mStartTime = 0;
41 uint32_t mRelativeTime = 0;
42 float mTimeScale = 1.0f;
43 uint32_t mPauseTime = 0;
44};
45
46} // namespace fl
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16