Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f87ba5ba9f | ||
|
|
246096ae96 | ||
|
|
1ce882f949 | ||
|
|
a132f4ab43 | ||
|
|
e89801c2dd | ||
|
|
744a957b76 | ||
|
|
cd87a100be |
@@ -96,7 +96,7 @@ void loop() {
|
||||
The Button class matches an electrical state to a physical action.
|
||||
Use .setPressedState(LOW or HIGH) to set the detection state for when the button is pressed.
|
||||
|
||||
INSCRUCTIONS
|
||||
INSTRUCTIONS
|
||||
====================
|
||||
Set BUTTON_PIN to the pin attached to the button.
|
||||
Set LED_PIN to the pin attached to a LED.
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/thomasfredericks/Bounce2.git"
|
||||
},
|
||||
"version": "2.56",
|
||||
"version": "2.57",
|
||||
"exclude": [
|
||||
"*.png",
|
||||
"*.zip"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
name=Bounce2
|
||||
version=2.56
|
||||
version=2.57
|
||||
author=Thomas O Fredericks <tof@t-o-f.info> with contributions from Eric Lowry, Jim Schimpf, Tom Harkaway, Joachim Krüger and MrGradgrind.
|
||||
maintainer=Thomas O Fredericks <tof@t-o-f.info>
|
||||
sentence=Debouncing library for Arduino and Wiring.
|
||||
|
||||
+5
-5
@@ -100,11 +100,11 @@ bool Debouncer::update()
|
||||
}
|
||||
|
||||
// WIP HELD
|
||||
unsigned long Debouncer::previousDuration() {
|
||||
unsigned long Debouncer::previousDuration() const {
|
||||
return durationOfPreviousState;
|
||||
}
|
||||
|
||||
unsigned long Debouncer::duration() {
|
||||
unsigned long Debouncer::duration() const {
|
||||
return (millis() - stateChangeLastTime);
|
||||
}
|
||||
|
||||
@@ -115,17 +115,17 @@ inline void Debouncer::changeState() {
|
||||
stateChangeLastTime = millis();
|
||||
}
|
||||
|
||||
bool Debouncer::read()
|
||||
bool Debouncer::read() const
|
||||
{
|
||||
return getStateFlag(DEBOUNCED_STATE);
|
||||
}
|
||||
|
||||
bool Debouncer::rose()
|
||||
bool Debouncer::rose() const
|
||||
{
|
||||
return getStateFlag(DEBOUNCED_STATE) && getStateFlag(CHANGED_STATE);
|
||||
}
|
||||
|
||||
bool Debouncer::fell()
|
||||
bool Debouncer::fell() const
|
||||
{
|
||||
return !getStateFlag(DEBOUNCED_STATE) && getStateFlag(CHANGED_STATE);
|
||||
}
|
||||
|
||||
+16
-16
@@ -69,10 +69,10 @@ private:
|
||||
|
||||
private:
|
||||
inline void changeState();
|
||||
inline void setStateFlag(const uint8_t flag) {state |= flag;}
|
||||
inline void unsetStateFlag(const uint8_t flag) {state &= ~flag;}
|
||||
inline void toggleStateFlag(const uint8_t flag) {state ^= flag;}
|
||||
inline bool getStateFlag(const uint8_t flag) {return((state & flag) != 0);}
|
||||
inline void setStateFlag(const uint8_t flag) {state |= flag;}
|
||||
inline void unsetStateFlag(const uint8_t flag) {state &= ~flag;}
|
||||
inline void toggleStateFlag(const uint8_t flag) {state ^= flag;}
|
||||
inline bool getStateFlag(const uint8_t flag) const {return((state & flag) != 0);}
|
||||
|
||||
public:
|
||||
/*!
|
||||
@@ -106,17 +106,17 @@ public:
|
||||
|
||||
@return HIGH or LOW.
|
||||
*/
|
||||
bool read();
|
||||
bool read() const;
|
||||
|
||||
/**
|
||||
@brief Returns true if pin signal transitions from high to low.
|
||||
*/
|
||||
bool fell();
|
||||
bool fell() const;
|
||||
|
||||
/**
|
||||
@brief Returns true if pin signal transitions from low to high.
|
||||
*/
|
||||
bool rose();
|
||||
bool rose() const;
|
||||
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
|
||||
@return True if the state changed on last update. Otherwise, returns false.
|
||||
*/
|
||||
bool changed( ) { return getStateFlag(CHANGED_STATE); }
|
||||
bool changed( ) const { return getStateFlag(CHANGED_STATE); }
|
||||
|
||||
/**
|
||||
@brief Returns the duration in milliseconds of the current state.
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
@return The duration in milliseconds (unsigned long) of the current state.
|
||||
*/
|
||||
|
||||
unsigned long duration();
|
||||
unsigned long duration() const;
|
||||
|
||||
/**
|
||||
@brief Returns the duration in milliseconds of the previous state.
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
|
||||
@return The duration in milliseconds (unsigned long) of the previous state.
|
||||
*/
|
||||
unsigned long previousDuration();
|
||||
unsigned long previousDuration() const;
|
||||
|
||||
protected:
|
||||
void begin();
|
||||
@@ -209,11 +209,11 @@ public:
|
||||
/**
|
||||
@brief Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce version 1
|
||||
*/
|
||||
bool risingEdge() { return rose(); }
|
||||
bool risingEdge() const { return rose(); }
|
||||
/**
|
||||
@brief Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce version 1
|
||||
*/
|
||||
bool fallingEdge() { return fell(); }
|
||||
bool fallingEdge() const { return fell(); }
|
||||
/**
|
||||
@brief Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce version 1
|
||||
*/
|
||||
@@ -273,28 +273,28 @@ protected:
|
||||
/*!
|
||||
@brief Get the electrical state (HIGH/LOW) that corresponds to a physical press.
|
||||
*/
|
||||
inline bool getPressedState() {
|
||||
inline bool getPressedState() const {
|
||||
return stateForPressed;
|
||||
};
|
||||
|
||||
/*!
|
||||
@brief Returns true if the button is currently physically pressed.
|
||||
*/
|
||||
inline bool isPressed() {
|
||||
inline bool isPressed() const {
|
||||
return read() == getPressedState();
|
||||
};
|
||||
|
||||
/*!
|
||||
@brief Returns true if the button was physically pressed
|
||||
*/
|
||||
inline bool pressed() {
|
||||
inline bool pressed() const {
|
||||
return changed() && isPressed();
|
||||
};
|
||||
|
||||
/*!
|
||||
@brief Returns true if the button was physically released
|
||||
*/
|
||||
inline bool released() {
|
||||
inline bool released() const {
|
||||
return changed() && !isPressed();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 thomasfredericks
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
Main code by Thomas O Fredericks (tof@t-o-f.info)
|
||||
Previous contributions by Eric Lowry, Jim Schimpf and Tom Harkaway
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
using namespace Bounce2;
|
||||
Reference in New Issue
Block a user