-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V3.3.1 - Avoid mistakenly double press detection after boot.
- Loading branch information
Showing
8 changed files
with
33 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name=EasyButtonAtInt01 | ||
version=3.3.0 | ||
version=3.3.1 | ||
author=Armin Joachimsmeyer | ||
maintainer=Armin Joachimsmeyer <[email protected]> | ||
sentence=Small and easy to use Arduino library for using push buttons at INT0/pin2 and / or any PinChangeInterrupt pin.<br/>Functions for long and double press detection are included.<br/><br/>Just connect buttons between ground and any pin of your Arduino - that's it<br/><br/><b>No call</b> of begin() or polling function like update() required. No blocking debouncing delay.<br/> | ||
paragraph=<br/>Define an EasyButtonIn in you main program and use <i>ButtonStateIsActive</i> or <i>ButtonToggleState</i> to determine your action.<br/>Or use a <b>callback function</b> which will be called once on every button press or release.<br/><br/>Usage:<pre>#define USE_BUTTON_0<br/>#include "EasyButtonAtInt01.hpp"<br/>EasyButton Button0AtPin2;<br/><br/>void setup() {}<br/>void loop() {<br/>...<br/> digitalWrite(LED_BUILTIN, Button0AtPin2.ButtonToggleState);<br/>...<br/>}</pre><br/><br/><b>New: </b>Renamed EasyButtonAtInt01.cpp.h to EasyButtonAtInt01.hpp. => <b>You must change: #include "EasyButtonAtInt01.cpp.h" to: #include "EasyButtonAtInt01.hpp"</b><br/> | ||
paragraph=<br/>Define an EasyButtonIn in you main program and use <i>ButtonStateIsActive</i> or <i>ButtonToggleState</i> to determine your action.<br/>Or use a <b>callback function</b> which will be called once on every button press or release.<br/><br/>Usage:<pre>#define USE_BUTTON_0<br/>#include "EasyButtonAtInt01.hpp"<br/>EasyButton Button0AtPin2;<br/><br/>void setup() {}<br/>void loop() {<br/>...<br/> digitalWrite(LED_BUILTIN, Button0AtPin2.ButtonToggleState);<br/>...<br/>}</pre><br/><br/><b>New: </b>Avoid mistakenly double press detection after boot.</b><br/> | ||
category=Signal Input/Output | ||
url=https://github.com/ArminJo/EasyButtonAtInt01 | ||
architectures=avr | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* #include "EasyButtonAtInt01.h" | ||
* EasyButton Button0AtPin2(true); | ||
* | ||
* Copyright (C) 2018 Armin Joachimsmeyer | ||
* Copyright (C) 2018-2022 Armin Joachimsmeyer | ||
* [email protected] | ||
* | ||
* This file is part of EasyButtonAtInt01 https://github.com/ArminJo/EasyButtonAtInt01. | ||
|
@@ -34,7 +34,7 @@ | |
#ifndef EASY_BUTTON_AT_INT01_H_ | ||
#define EASY_BUTTON_AT_INT01_H_ | ||
|
||
#define VERSION_EASY_BUTTON "3.2.0" | ||
#define VERSION_EASY_BUTTON "3.2.1" | ||
#define VERSION_EASY_BUTTON_MAJOR 3 | ||
#define VERSION_EASY_BUTTON_MINOR 2 | ||
// The change log is at the bottom of the file | ||
|
@@ -62,7 +62,7 @@ | |
/* | ||
* Define USE_ATTACH_INTERRUPT to force use of the arduino function attachInterrupt(). | ||
* It is required if you get the error " multiple definition of `__vector_1'" (or `__vector_2'), because another library uses the attachInterrupt() function. | ||
* For one button it needs additional 160 bytes FLASH, for 2 buttons it needs additional 88 bytes. | ||
* For one button it needs additional 160 bytes program space, for 2 buttons it needs additional 88 bytes. | ||
*/ | ||
//#define USE_ATTACH_INTERRUPT | ||
// | ||
|
@@ -84,7 +84,7 @@ | |
#endif | ||
|
||
/* | ||
* Activate this to save 2 bytes RAM and 64 bytes FLASH | ||
* Activate this to save 2 bytes RAM and 64 bytes program space | ||
*/ | ||
//#define NO_BUTTON_RELEASE_CALLBACK | ||
// | ||
|
@@ -128,7 +128,7 @@ | |
#endif | ||
|
||
/* | ||
* These defines are here to enable saving of 150 bytes FLASH if only one button is needed | ||
* These defines are here to enable saving of 150 bytes program space if only one button is needed | ||
*/ | ||
//#define USE_BUTTON_0 | ||
//#define USE_BUTTON_1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
* #include "EasyButtonAtInt01.hpp" | ||
* EasyButton Button0AtPin2(true); | ||
* | ||
* Copyright (C) 2018 Armin Joachimsmeyer | ||
* Copyright (C) 2018-2022 Armin Joachimsmeyer | ||
* [email protected] | ||
* | ||
* This file is part of EasyButtonAtInt01 https://github.com/ArminJo/EasyButtonAtInt01. | ||
|
@@ -42,7 +42,7 @@ | |
* - USE_BUTTON_1 Enables code for button at INT1 (pin3 on 328P, PA3 on ATtiny167, PCINT0 / PCx for ATtinyX5). | ||
* - BUTTON_IS_ACTIVE_HIGH Enable this if you buttons are active high. | ||
* - USE_ATTACH_INTERRUPT This forces use of the arduino function attachInterrupt(). It is required if you get the error "multiple definition of __vector_1". | ||
* - NO_BUTTON_RELEASE_CALLBACK Disables the code for release callback. This saves 2 bytes RAM and 64 bytes FLASH. | ||
* - NO_BUTTON_RELEASE_CALLBACK Disables the code for release callback. This saves 2 bytes RAM and 64 bytes program space. | ||
* - BUTTON_DEBOUNCING_MILLIS With this you can adapt to the characteristic of your button. | ||
* - ANALYZE_MAX_BOUNCING_PERIOD Analyze the buttons actual debounce value. | ||
* - BUTTON_LED_FEEDBACK This activates LED_BUILTIN as long as button is pressed. | ||
|
@@ -458,13 +458,19 @@ bool EasyButton::checkForLongPressBlocking(uint16_t aLongPressThresholdMillis) { | |
* Double press detection by computing difference between current (active) timestamp ButtonLastChangeMillis | ||
* and last release timestamp ButtonReleaseMillis. | ||
* !!!Works only reliable if called early in ButtonPress callback function!!! | ||
* Be aware, that the first press after booting may be detected as double press! | ||
* This is because ButtonReleaseMillis is initialized with 0 milliseconds, which is interpreted as the first press happened at the beginning of boot. | ||
* @return true if double press detected. | ||
*/ | ||
bool EasyButton::checkForDoublePress(uint16_t aDoublePressDelayMillis) { | ||
unsigned long tReleaseToPressTimeMillis = ButtonLastChangeMillis - ButtonReleaseMillis; | ||
return (tReleaseToPressTimeMillis <= aDoublePressDelayMillis); | ||
/* | ||
* Check if ButtonReleaseMillis is not in initialized state | ||
* otherwise a single press before aDoublePressDelayMillis after boot is mistakenly detected as double press | ||
*/ | ||
if (ButtonReleaseMillis != 0) { | ||
// because ButtonReleaseMillis is initialized with 0 milliseconds, which is interpreted as the first press happened at the beginning of boot. | ||
unsigned long tReleaseToPressTimeMillis = ButtonLastChangeMillis - ButtonReleaseMillis; | ||
return (tReleaseToPressTimeMillis <= aDoublePressDelayMillis); | ||
} | ||
return false; | ||
} | ||
|
||
/* | ||
|