Compare commits

...
7 Commits
Author SHA1 Message Date
Thomas O Fredericks f87ba5ba9f Update library.properties 2021-03-04 15:53:16 -05:00
Thomas O Fredericks 246096ae96 Update library.json 2021-03-04 15:53:02 -05:00
Thomas O Fredericks 1ce882f949 Merge pull request #78 from DanForever/master
Made the bounce2 library const correct
2021-03-04 15:49:53 -05:00
Dan Neve a132f4ab43 Made the bounce2 library const correct 2021-03-04 19:14:11 +01:00
Thomas O Fredericks e89801c2dd Merge pull request #77 from michaelcress/master
Correcting spelling error in README file
2021-03-04 00:18:06 -05:00
Michael Cress 744a957b76 Correcting spelling error 2021-03-03 05:59:07 -05:00
Thomas O Fredericks cd87a100be Delete Bounce2NameSpace.h 2021-01-29 18:45:51 -05:00
6 changed files with 24 additions and 53 deletions
+1 -1
View File
@@ -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
View File
@@ -6,7 +6,7 @@
"type": "git",
"url": "https://github.com/thomasfredericks/Bounce2.git"
},
"version": "2.56",
"version": "2.57",
"exclude": [
"*.png",
"*.zip"
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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();
};
-29
View File
@@ -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;