From 4034f1693e37e25630ea37959d575edebc2d326a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Pohl?= Date: Tue, 16 Dec 2014 19:47:11 +0100 Subject: [PATCH 1/4] fixed int long bug --- Button.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Button.h b/Button.h index c1528d9..5e00f0a 100755 --- a/Button.h +++ b/Button.h @@ -56,7 +56,7 @@ class Button { uint8_t pin; uint8_t mode; uint8_t state; - unsigned int pressedStartTime; + unsigned long pressedStartTime; unsigned int holdEventThreshold; buttonEventHandler cb_onPress; buttonEventHandler cb_onRelease; @@ -66,4 +66,4 @@ class Button { bool triggeredHoldEvent; }; -#endif \ No newline at end of file +#endif From 75b8149239b5b35d24d108f1bb16ad707aa2a71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Pohl?= Date: Tue, 16 Dec 2014 19:48:53 +0100 Subject: [PATCH 2/4] fixed docu --- Examples/Button/Button.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Button/Button.ino b/Examples/Button/Button.ino index faf3c25..33f48ca 100644 --- a/Examples/Button/Button.ino +++ b/Examples/Button/Button.ino @@ -24,7 +24,7 @@ || Wiring: || GND -----/ ------ pin 12 */ -Button button = Button(12,PULLUP); +Button button = Button(12,BUTTON_PULLUP); void setup(){ pinMode(13,OUTPUT); //debug to led 13 From 80b13d0b0bd1274f0157bcc78e251ea2c0a92e2f Mon Sep 17 00:00:00 2001 From: Beanow Date: Sun, 20 Sep 2015 15:10:35 +0200 Subject: [PATCH 3/4] OCD! --- Button.cpp | 7 ++++--- Button.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Button.cpp b/Button.cpp index f6174c1..ec541eb 100755 --- a/Button.cpp +++ b/Button.cpp @@ -29,7 +29,7 @@ || @parameter buttonMode indicates BUTTON_PULLUP or BUTTON_PULLDOWN resistor */ Button::Button(uint8_t buttonPin, uint8_t buttonMode){ - pin=buttonPin; + pin=buttonPin; pinMode(pin,INPUT); buttonMode==BUTTON_PULLDOWN ? pulldown() : pullup(buttonMode); @@ -78,7 +78,8 @@ void Button::pulldown(void) || @return true if button is pressed */ bool Button::isPressed(void) -{ +{ + //save the previous value bitWrite(state,PREVIOUS,bitRead(state,CURRENT)); @@ -282,4 +283,4 @@ unsigned int Button::holdTime() const { if (pressedStartTime!=-1) { return milli bool Button::operator==(Button &rhs) { return (this==&rhs); -} \ No newline at end of file +} diff --git a/Button.h b/Button.h index 5e00f0a..6cb2497 100755 --- a/Button.h +++ b/Button.h @@ -6,7 +6,7 @@ || || @description || | This is a Hardware Abstraction Library for Buttons -|| | It providea an easy way of handling buttons +|| | It provides an easy way of handling buttons || # || || @license LICENSE_REPLACE From c681543ad165459eaa63d5940a61dad91ce3aab7 Mon Sep 17 00:00:00 2001 From: Beanow Date: Sun, 20 Sep 2015 15:11:20 +0200 Subject: [PATCH 4/4] Use INPUT_PULLUP for modern arduino API. --- Button.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Button.cpp b/Button.cpp index ec541eb..d4a11ea 100755 --- a/Button.cpp +++ b/Button.cpp @@ -56,7 +56,7 @@ void Button::pullup(uint8_t buttonMode) mode=BUTTON_PULLUP; if (buttonMode == BUTTON_PULLUP_INTERNAL) { - digitalWrite(pin,HIGH); + pinMode(pin,INPUT_PULLUP); } }