FastLED 3.9.15
Loading...
Searching...
No Matches
time.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/stdint.h"
4
6#include "fl/stl/shared_ptr.h" // For FASTLED_SHARED_PTR macros
7#include "fl/stl/noexcept.h"
8
9namespace fl {
10
13
14// Interface for time generation and time manipulation.
16 public:
18 virtual fl::u32
19 update(fl::u32 timeNow) = 0; // Inputs the real clock time and outputs the
20 // virtual time.
21 virtual fl::u32 time() const = 0;
22 virtual void reset(fl::u32 realTimeNow) = 0;
23};
24
25// Time clock. Use this to gracefully handle time manipulation. You can input a
26// float value representing the current time scale and this will adjust a the
27// clock smoothly. Updating requires inputing the real clock from the millis()
28// function. HANDLES NEGATIVE TIME SCALES!!! Use this to control viusualizers
29// back and forth motion which draw according to a clock value. Clock will never
30// go below 0.
31class TimeWarp : public TimeFunction {
32 public:
33 TimeWarp(fl::u32 realTimeNow = 0, float initialTimeScale = 1.0f);
35 void setSpeed(float speedScale);
36 void setScale(float speed)
37 FASTLED_DEPRECATED("Use setSpeed(...) instead."); // Deprecated
38 float scale() const;
39 fl::u32 update(fl::u32 timeNow) override;
40 fl::u32 time() const override;
41 void reset(fl::u32 realTimeNow) override;
42 void pause(fl::u32 now);
43 void resume(fl::u32 now);
44
45 private:
46 void applyExact(fl::u32 timeNow);
47 fl::u32 mLastRealTime = 0;
48 fl::u32 mStartTime = 0;
49 fl::u32 mRelativeTime = 0;
50 float mTimeScale = 1.0f;
51 fl::u32 mPauseTime = 0;
52};
53
54} // namespace fl
uint16_t speed
Definition Noise.ino:66
virtual void reset(fl::u32 realTimeNow)=0
virtual fl::u32 update(fl::u32 timeNow)=0
virtual ~TimeFunction() FL_NOEXCEPT
Definition time.h:17
virtual fl::u32 time() const =0
void pause(fl::u32 now)
Definition time.cpp.hpp:21
void resume(fl::u32 now)
Definition time.cpp.hpp:28
fl::u32 mPauseTime
Definition time.h:51
void applyExact(fl::u32 timeNow)
Definition time.cpp.hpp:52
float scale() const
Definition time.cpp.hpp:19
void reset(fl::u32 realTimeNow) override
Definition time.cpp.hpp:46
~TimeWarp() FL_NOEXCEPT
Definition time.cpp.hpp:15
float mTimeScale
Definition time.h:50
fl::u32 time() const override
Definition time.cpp.hpp:44
fl::u32 update(fl::u32 timeNow) override
Definition time.cpp.hpp:39
void setSpeed(float speedScale)
Definition time.cpp.hpp:17
fl::u32 mLastRealTime
Definition time.h:47
void setScale(float speed) FASTLED_DEPRECATED("Use setSpeed(...) instead.")
Definition time.cpp.hpp:95
fl::u32 mStartTime
Definition time.h:48
fl::u32 mRelativeTime
Definition time.h:49
TimeWarp(fl::u32 realTimeNow=0, float initialTimeScale=1.0f)
Definition time.cpp.hpp:11
Base definition for an LED controller.
Definition crgb.hpp:179
#define FASTLED_DEPRECATED(msg)
#define FL_NOEXCEPT
#define FASTLED_SHARED_PTR(type)
Definition shared_ptr.h:535