From 79db9f00168eaad226d37b72adb80a66c0f98ef8 Mon Sep 17 00:00:00 2001 From: Thomas O Fredericks Date: Mon, 21 Mar 2022 10:04:38 -0400 Subject: [PATCH] Added back duration but as deprecated and updated documentation --- docs/files/_bounce2_8h_source.html | 223 +++++++++--------- docs/files/class_bounce-members.html | 35 +-- docs/files/class_bounce.html | 3 + .../class_bounce2_1_1_button-members.html | 47 ++-- docs/files/class_bounce2_1_1_button.html | 5 +- docs/files/class_debouncer-members.html | 25 +- docs/files/class_debouncer.html | 34 ++- docs/files/functions.html | 3 + docs/files/functions_func.html | 3 + docs/files/index.html | 8 +- docs/files/search/all_3.js | 3 +- docs/files/search/all_4.js | 4 +- docs/files/search/all_5.js | 4 +- docs/files/search/all_6.js | 4 +- docs/files/search/all_7.js | 6 +- docs/files/search/all_8.js | 8 +- docs/files/search/all_9.js | 2 +- docs/files/search/all_a.js | 2 +- docs/files/search/classes_0.js | 4 +- docs/files/search/classes_1.js | 2 +- docs/files/search/functions_0.js | 2 +- docs/files/search/functions_1.js | 4 +- docs/files/search/functions_2.js | 4 +- docs/files/search/functions_3.js | 3 +- docs/files/search/functions_4.js | 4 +- docs/files/search/functions_5.js | 4 +- docs/files/search/functions_6.js | 4 +- docs/files/search/functions_7.js | 4 +- docs/files/search/functions_8.js | 8 +- docs/files/search/functions_9.js | 2 +- docs/files/search/functions_a.js | 2 +- docs/files/search/namespaces_0.js | 2 +- docs/files/search/pages_0.js | 2 +- docs/files/search/variables_0.js | 2 +- library.json | 2 +- library.properties | 2 +- src/Bounce2.h | 18 ++ 37 files changed, 286 insertions(+), 208 deletions(-) diff --git a/docs/files/_bounce2_8h_source.html b/docs/files/_bounce2_8h_source.html index c1decaf..c70e78d 100644 --- a/docs/files/_bounce2_8h_source.html +++ b/docs/files/_bounce2_8h_source.html @@ -148,127 +148,138 @@ $(function() {
123 
124 public:
130  bool changed( ) const { return getStateFlag(CHANGED_STATE); }
-
131 
-
140  unsigned long currentDuration() const;
-
141 
-
142 
-
150  unsigned long previousDuration() const;
-
151 
-
152 protected:
-
153  void begin();
-
154  virtual bool readCurrentState() =0;
-
155  unsigned long previous_millis;
-
156  uint16_t interval_millis;
-
157  uint8_t state;
-
158  unsigned long stateChangeLastTime;
-
159  unsigned long durationOfPreviousState;
-
160 
-
161 };
-
162 
-
163 
-
168 class Bounce : public Debouncer
-
169 {
-
170 
-
171 
-
172 public:
-
173 
-
184  Bounce();
-
185 
+
131 
+
132 
+
133 
+
134 
+
143  unsigned long currentDuration() const;
+
144 
+
145 
+
153  unsigned long previousDuration() const;
+
154 
+
163  [[deprecated]]
+
164  unsigned long duration() {
+
165  return currentDuration();
+
166  };
+
167 
+
168 protected:
+
169  void begin();
+
170  virtual bool readCurrentState() =0;
+
171  unsigned long previous_millis;
+
172  uint16_t interval_millis;
+
173  uint8_t state;
+
174  unsigned long stateChangeLastTime;
+
175  unsigned long durationOfPreviousState;
+
176 
+
177 };
+
178 
+
179 
+
184 class Bounce : public Debouncer
+
185 {
186 
-
195  void attach(int pin, int mode);
-
196 
-
200  void attach(int pin);
+
187 
+
188 public:
+
189 
+
200  Bounce();
201 
-
202  Bounce(uint8_t pin, unsigned long interval_millis ) : Bounce() {
-
203  attach(pin);
-
204  interval(interval_millis);
-
205  }
-
206 
-
207 
-
213  inline int getPin() const {
-
214  return this->pin;
-
215  };
-
216 
-
218  // Deprecated //
-
220 
-
224  bool risingEdge() const { return rose(); }
-
228  bool fallingEdge() const { return fell(); }
-
234 protected:
-
235 
-
236 
-
237  uint8_t pin;
-
238 
-
239  virtual bool readCurrentState() { return digitalRead(pin); }
-
240  virtual void setPinMode(int pin, int mode) {
-
241 #if defined(ARDUINO_ARCH_STM32F1)
-
242  pinMode(pin, (WiringPinMode)mode);
-
243 #else
-
244  pinMode(pin, mode);
-
245 #endif
-
246  }
-
247 
-
248 
-
249 
-
250 };
-
251 
-
255 namespace Bounce2 {
-
256  // code declarations
-
257 
-
258 class Button : public Bounce{
-
259 protected:
-
260  bool stateForPressed = 1; //
-
261  public:
-
272  Button(){ }
-
273 
-
281  void setPressedState(bool state){
-
282  stateForPressed = state;
-
283  }
-
284 
-
288  inline bool getPressedState() const {
-
289  return stateForPressed;
-
290  };
+
202 
+
211  void attach(int pin, int mode);
+
212 
+
216  void attach(int pin);
+
217 
+
218  Bounce(uint8_t pin, unsigned long interval_millis ) : Bounce() {
+
219  attach(pin);
+
220  interval(interval_millis);
+
221  }
+
222 
+
223 
+
229  inline int getPin() const {
+
230  return this->pin;
+
231  };
+
232 
+
234  // Deprecated //
+
236 
+
240  [[deprecated]]
+
241  bool risingEdge() const { return rose(); }
+
245  [[deprecated]]
+
246  bool fallingEdge() const { return fell(); }
+
252 protected:
+
253 
+
254 
+
255  uint8_t pin;
+
256 
+
257  virtual bool readCurrentState() { return digitalRead(pin); }
+
258  virtual void setPinMode(int pin, int mode) {
+
259 #if defined(ARDUINO_ARCH_STM32F1)
+
260  pinMode(pin, (WiringPinMode)mode);
+
261 #else
+
262  pinMode(pin, mode);
+
263 #endif
+
264  }
+
265 
+
266 
+
267 
+
268 };
+
269 
+
273 namespace Bounce2 {
+
274  // code declarations
+
275 
+
276 class Button : public Bounce{
+
277 protected:
+
278  bool stateForPressed = 1; //
+
279  public:
+
290  Button(){ }
291 
-
295  inline bool isPressed() const {
-
296  return read() == getPressedState();
-
297  };
-
298 
-
302  inline bool pressed() const {
-
303  return changed() && isPressed();
-
304  };
-
305 
-
309  inline bool released() const {
-
310  return changed() && !isPressed();
-
311  };
-
312 
-
313 };
-
314 };
-
315 
-
316 #endif
+
299  void setPressedState(bool state){
+
300  stateForPressed = state;
+
301  }
+
302 
+
306  inline bool getPressedState() const {
+
307  return stateForPressed;
+
308  };
+
309 
+
313  inline bool isPressed() const {
+
314  return read() == getPressedState();
+
315  };
+
316 
+
320  inline bool pressed() const {
+
321  return changed() && isPressed();
+
322  };
+
323 
+
327  inline bool released() const {
+
328  return changed() && !isPressed();
+
329  };
+
330 
+
331 };
+
332 };
+
333 
+
334 #endif
-
Definition: Bounce2.h:258
+
Definition: Bounce2.h:276
void interval(uint16_t interval_millis)
Sets the debounce interval in milliseconds.
Definition: Bounce2.cpp:14
unsigned long previousDuration() const
Returns the duration in milliseconds of the previous state.
Definition: Bounce2.cpp:103
-
bool getPressedState() const
Get the electrical state (HIGH/LOW) that corresponds to a physical press.
Definition: Bounce2.h:288
+
bool getPressedState() const
Get the electrical state (HIGH/LOW) that corresponds to a physical press.
Definition: Bounce2.h:306
Bounce()
Create an instance of the Bounce class.
Definition: Bounce2.cpp:138
-
bool fallingEdge() const
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:228
+
unsigned long duration()
DEPRECATED (i.e. do not use). Renamed currentDuration().
Definition: Bounce2.h:164
+
bool fallingEdge() const
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:246
bool rose() const
Returns true if pin signal transitions from low to high.
Definition: Bounce2.cpp:123
-
uint8_t pin
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:237
-
bool pressed() const
Returns true if the button was physically pressed
Definition: Bounce2.h:302
+
uint8_t pin
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:255
+
bool pressed() const
Returns true if the button was physically pressed
Definition: Bounce2.h:320
unsigned long currentDuration() const
Returns the duration in milliseconds of the current state.
Definition: Bounce2.cpp:107
bool update()
Updates the pin's state.
Definition: Bounce2.cpp:32
-
Button()
Create an instance of the Button class. By default, the pressed state is matched to a HIGH electrical...
Definition: Bounce2.h:272
-
The Debouncer:Bounce class. Links the Deboucing class to a hardware pin. This class is odly named,...
Definition: Bounce2.h:168
-
int getPin() const
Return pin that this Bounce is attached to.
Definition: Bounce2.h:213
+
Button()
Create an instance of the Button class. By default, the pressed state is matched to a HIGH electrical...
Definition: Bounce2.h:290
+
The Debouncer:Bounce class. Links the Deboucing class to a hardware pin. This class is odly named,...
Definition: Bounce2.h:184
+
int getPin() const
Return pin that this Bounce is attached to.
Definition: Bounce2.h:229
The Debouce class. Just the deboucing code separated from all harware.
Definition: Bounce2.h:62
-
void setPressedState(bool state)
Set the electrical state (HIGH/LOW) that corresponds to a physical press. By default,...
Definition: Bounce2.h:281
+
void setPressedState(bool state)
Set the electrical state (HIGH/LOW) that corresponds to a physical press. By default,...
Definition: Bounce2.h:299
bool fell() const
Returns true if pin signal transitions from high to low.
Definition: Bounce2.cpp:128
-
bool released() const
Returns true if the button was physically released
Definition: Bounce2.h:309
+
bool released() const
Returns true if the button was physically released
Definition: Bounce2.h:327
void attach(int pin, int mode)
Attach to a pin and sets that pin's mode (INPUT, INPUT_PULLUP or OUTPUT).
Definition: Bounce2.cpp:149
-
bool isPressed() const
Returns true if the button is currently physically pressed.
Definition: Bounce2.h:295
+
bool isPressed() const
Returns true if the button is currently physically pressed.
Definition: Bounce2.h:313
bool read() const
Returns the pin's state (HIGH or LOW).
Definition: Bounce2.cpp:118
-
bool risingEdge() const
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:224
+
bool risingEdge() const
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:241
bool changed() const
Returns true if the state changed on last update.
Definition: Bounce2.h:130
-
The Debouncer:Bounce:Button class. The Button class matches an electrical state to a physical action.
Definition: Bounce2.h:255
+
The Debouncer:Bounce:Button class. The Button class matches an electrical state to a physical action.
Definition: Bounce2.h:273
Debouncer()
Create an instance of the Debounce class.
Definition: Bounce2.cpp:10