FastLED 3.9.15
Loading...
Searching...
No Matches
ui.cpp
Go to the documentation of this file.
1
2
3#include "fl/ui.h"
4#include <stdint.h>
5
6#pragma GCC diagnostic push
7#pragma GCC diagnostic ignored "-Wfloat-equal"
8
9namespace fl {
10
12
13 if (value != Super::value()) {
14 Super::setValue(value);
15 }
16}
17
19 UISlider &owner = *mOwner;
20 if (!owner.mLastFramevalueValid) {
21 owner.mLastFrameValue = owner.value();
22 owner.mLastFramevalueValid = true;
23 return;
24 }
25 float value = owner.value();
26 if (value != owner.mLastFrameValue) {
27 owner.mCallbacks.invoke(*mOwner, value);
28 owner.mLastFrameValue = value;
29 }
30}
31
33 const bool clicked_this_frame = mOwner->clicked();
34 const bool clicked_changed = (clicked_this_frame != mClickedLastFrame);
35 mClickedLastFrame = clicked_this_frame;
36 if (clicked_changed) {
37 // FASTLED_WARN("Button: " << mOwner->name() << " clicked: " <<
38 // mOwner->clicked());
39 mOwner->mCallbacks.invoke(*mOwner);
40 }
41 // mOwner->mCallbacks.invoke(*mOwner);
42}
43
45 UICheckbox &owner = *mOwner;
46 if (!owner.mLastFrameValueValid) {
47 owner.mLastFrameValue = owner.value();
48 owner.mLastFrameValueValid = true;
49 return;
50 }
51 bool value = owner.value();
52 if (value != owner.mLastFrameValue) {
53 owner.mCallbacks.invoke(owner, value);
54 owner.mLastFrameValue = value;
55 }
56}
57
59 UINumberField &owner = *mOwner;
60 if (!owner.mLastFrameValueValid) {
61 owner.mLastFrameValue = owner.value();
62 owner.mLastFrameValueValid = true;
63 return;
64 }
65 double value = owner.value();
66 if (value != owner.mLastFrameValue) {
67 owner.mCallbacks.invoke(owner, value);
68 owner.mLastFrameValue = value;
69 }
70}
71
72} // end namespace fl
73
74#pragma GCC diagnostic pop
FunctionList< UICheckbox &, bool > mCallbacks
Definition ui.h:232
bool mLastFrameValue
Definition ui.h:233
bool mLastFrameValueValid
Definition ui.h:234
UICheckbox(const char *name, bool value=false)
Definition ui.h:179
bool value() const
Definition ui_impl.h:132
double value() const
Definition ui.h:246
FunctionList< UINumberField &, double > mCallbacks
Definition ui.h:302
UINumberField(const char *name, double value, double min=0, double max=100)
Definition ui.h:242
bool mLastFrameValueValid
Definition ui.h:301
double mLastFrameValue
Definition ui.h:300
bool mLastFramevalueValid
Definition ui.h:107
FunctionList< UISlider &, float > mCallbacks
Definition ui.h:105
UISlider(const char *name, float value=128.0f, float min=1, float max=255, float step=-1.f)
Definition ui.h:29
float mLastFrameValue
Definition ui.h:106
void setValue(float value)
Definition ui.cpp:11
float value() const
Definition ui.h:32
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
bool mClickedLastFrame
Definition ui.h:167
UIButton * mOwner
Definition ui.h:165
void onBeginFrame() override
Definition ui.cpp:32
UICheckbox * mOwner
Definition ui.h:226
void onBeginFrame() override
Definition ui.cpp:44
UINumberField * mOwner
Definition ui.h:295
void onBeginFrame() override
Definition ui.cpp:58
void onBeginFrame() override
Definition ui.cpp:18
UISlider * mOwner
Definition ui.h:100