FastLED 3.10.8
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) FL_NO_EXCEPT = 0; // Inputs the real clock time and outputs the
20 // virtual time.
21 virtual fl::u32 time() const FL_NO_EXCEPT = 0;
22 virtual void reset(fl::u32 realTimeNow) FL_NO_EXCEPT = 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) FL_NO_EXCEPT;
35 void setSpeed(float speedScale) FL_NO_EXCEPT;
36 void setScale(float speed)
37 FL_NO_EXCEPT FASTLED_DEPRECATED("Use setSpeed(...) instead."); // Deprecated
38 float scale() const FL_NO_EXCEPT;
39 fl::u32 update(fl::u32 timeNow) FL_NO_EXCEPT override;
40 fl::u32 time() const FL_NO_EXCEPT override;
41 void reset(fl::u32 realTimeNow) FL_NO_EXCEPT override;
42 void pause(fl::u32 now) FL_NO_EXCEPT;
43 void resume(fl::u32 now) FL_NO_EXCEPT;
44
45 private:
46 void applyExact(fl::u32 timeNow) FL_NO_EXCEPT;
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
fl::UISlider scale("Scale", 4,.1, 4,.1)
uint16_t speed
Definition Noise.ino:72
virtual fl::u32 time() const FL_NO_EXCEPT=0
virtual fl::u32 update(fl::u32 timeNow) FL_NO_EXCEPT=0
virtual ~TimeFunction() FL_NO_EXCEPT
Definition time.h:17
virtual void reset(fl::u32 realTimeNow) FL_NO_EXCEPT=0
void setScale(float speed) FL_NO_EXCEPT FASTLED_DEPRECATED("Use setSpeed(...) instead.")
Definition time.cpp.hpp:95
void applyExact(fl::u32 timeNow) FL_NO_EXCEPT
Definition time.cpp.hpp:52
TimeWarp(fl::u32 realTimeNow=0, float initialTimeScale=1.0f) FL_NO_EXCEPT
Definition time.cpp.hpp:11
fl::u32 mPauseTime
Definition time.h:51
float mTimeScale
Definition time.h:50
void setSpeed(float speedScale) FL_NO_EXCEPT
Definition time.cpp.hpp:17
fl::u32 mLastRealTime
Definition time.h:47
void pause(fl::u32 now) FL_NO_EXCEPT
Definition time.cpp.hpp:21
fl::u32 mStartTime
Definition time.h:48
fl::u32 mRelativeTime
Definition time.h:49
void resume(fl::u32 now) FL_NO_EXCEPT
Definition time.cpp.hpp:28
#define FASTLED_DEPRECATED(msg)
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
Base definition for an LED controller.
Definition crgb.hpp:179
#define FASTLED_SHARED_PTR(type)
Definition shared_ptr.h:577