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 = mButton.clicked();
110 bool val = Read() || mButton.clicked();
111 bool changed = val != on_;
112
113 if (clicked) {
114 ++curr_val_;
115 debounce_timestamp_ = time_now;
116 return;
117 }
118
119 if (changed) { // Has the toggle switch changed?
120 on_ = 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 - debounce_timestamp_) > 16) {
124 if (on_) {
125 ++curr_val_; // ... and increment the value.
126 }
127 debounce_timestamp_ = time_now;
128 }
129 }
130 }
bool Read()
Definition buttons.h:135
UIButton mButton
Definition buttons.h:143
unsigned long debounce_timestamp_
Definition buttons.h:142

References curr_val_, debounce_timestamp_, mButton, on_, and Read().

+ Here is the call graph for this function: