Skip to content

Commit

Permalink
Added optional third parameter for deactivating pullup.
Browse files Browse the repository at this point in the history
  • Loading branch information
PheiPheiPhei committed Jun 25, 2018
1 parent def11ac commit 172c296
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=OneButton
version=1.2.0
version=1.3.0
author=Matthias Hertel, mathertel@hotmail.com
maintainer=Matthias Hertel <http://www.mathertel.de>
sentence=Arduino libary for improving the usage of a singe input button.
Expand Down
7 changes: 5 additions & 2 deletions src/OneButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// ----- Initialization and Default Values -----

OneButton::OneButton(int pin, int activeLow)
OneButton::OneButton(int pin, int activeLow, bool pullupActive)
{
_pin = pin;

Expand All @@ -29,7 +29,10 @@ OneButton::OneButton(int pin, int activeLow)
_buttonPressed = LOW;

// use the given pin as input and activate internal PULLUP resistor.
pinMode( pin, INPUT_PULLUP );
if(pullupActive)
pinMode( pin, INPUT_PULLUP );
else
pinMode( pin, INPUT );

} else {
// the button connects the input pin to VCC when pressed.
Expand Down
3 changes: 2 additions & 1 deletion src/OneButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 23.03.2014 Enhanced long press functionalities by adding longPressStart and longPressStop callbacks
// 21.09.2015 A simple way for debounce detection added.
// 14.05.2017 Debouncing improvements.
// 25.06.2018 Optional third parameter for deactivating pullup.
// -----

#ifndef OneButton_h
Expand All @@ -29,7 +30,7 @@ class OneButton
{
public:
// ----- Constructor -----
OneButton(int pin, int active);
OneButton(int pin, int active, bool pullupActive = true);

// ----- Set runtime parameters -----

Expand Down

0 comments on commit 172c296

Please sign in to comment.