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 FASTLED_DBG("clicked: " << clicked);
111 bool val = Read() || mButton.clicked();
112 bool changed = val != on_;
113
114 if (clicked) {
115 ++curr_val_;
116 debounce_timestamp_ = time_now;
117 return;
118 }
119
120 if (changed) { // Has the toggle switch changed?
121 on_ = val; // Set the new toggle switch value.
122 // Protect against debouncing artifacts by putting a 200ms delay from the
123 // last time the value changed.
124 if ((time_now - debounce_timestamp_) > 16) {
125 if (on_) {
126 ++curr_val_; // ... and increment the value.
127 }
128 debounce_timestamp_ = time_now;
129 }
130 }
131 }
bool Read()
Definition buttons.h:136
UIButton mButton
Definition buttons.h:144
unsigned long debounce_timestamp_
Definition buttons.h:143
#define FASTLED_DBG(X)
Definition dbg.h:60

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

+ Here is the call graph for this function: