FastLED 3.9.15
Loading...
Searching...
No Matches

◆ Update()

void CountingButton::Update ( uint32_t time_now)
inline

Definition at line 108 of file buttons.h.

108 {
109 bool clicked = mUIButton.clicked();
110 bool val = Read() || mUIButton.clicked();
111 bool changed = val != mOn;
112
113 if (clicked) {
114 ++mCurrVal;
115 mDebounceTimestamp = time_now;
116 return;
117 }
118
119 if (changed) { // Has the toggle switch changed?
120 mOn = val; // Set the new toggle switch value.
121 // Protect against debouncing artifacts by putting a 200ms delay from the
122 // last time the value changed.
123 if ((time_now - mDebounceTimestamp) > 16) {
124 if (mOn) {
125 ++mCurrVal; // ... and increment the value.
126 }
127 mDebounceTimestamp = time_now;
128 }
129 }
130 }
fl::UIButton mUIButton
Definition buttons.h:143
bool Read()
Definition buttons.h:135
unsigned long mDebounceTimestamp
Definition buttons.h:142

References mCurrVal, mDebounceTimestamp, mOn, mUIButton, and Read().

+ Here is the call graph for this function: