Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
|
#include <DigitalInputButton.h>
Public Member Functions | |
DigitalInputButton (const uint8_t pin, const bool pullup=true) | |
void | begin () |
bool | on () |
Public Member Functions inherited from AbstractButton | |
AbstractButton () | |
Protected Attributes | |
const uint8_t | _pin |
const bool | _pullup |
Basic instantaneous button from a digital input.
DigitalInputButton models a digital push button or switch attached to a digital input. The API gives the user a logical pushed state via the on method, which hides inverted level logic from the user of the class (choose logic type in constructor).
Definition at line 14 of file DigitalInputButton.h.
DigitalInputButton::DigitalInputButton | ( | const uint8_t | pin, |
const bool | pullup = true |
||
) |
Constructor.
pin | the pin which he button is connected to. |
pullup | sets the logic type for the button. |
Note: if pullup is true the logic of the button is inverted - i.e. when the pin in pulled to ground, the button is considered to be pushed/on. The default is pullup, meaning that a LOW state on the pin means the button is on. Whilst this is a bit counter-intuitive, it is preferred as a floating pin will revert to off more readily than with non-pullup logic.
Definition at line 4 of file DigitalInputButton.cpp.
|
virtual |
Initialization.
It is typical to call the begin() method from the Arduino sketch's setup() function. This will call pinMode() for you, with arguments appropriate for the button logic type.
Reimplemented from AbstractButton.
Definition at line 10 of file DigitalInputButton.cpp.
|
virtual |
Test instantaneous input state.
Implements AbstractButton.
Definition at line 19 of file DigitalInputButton.cpp.