Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
Public Member Functions | Protected Attributes | List of all members
DigitalInputButton Class Reference

#include <DigitalInputButton.h>

Inheritance diagram for DigitalInputButton:
Inheritance graph

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DigitalInputButton()

DigitalInputButton::DigitalInputButton ( const uint8_t  pin,
const bool  pullup = true 
)

Constructor.

Parameters
pinthe pin which he button is connected to.
pullupsets 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.

Member Function Documentation

◆ begin()

void DigitalInputButton::begin ( )
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.

Here is the caller graph for this function:

◆ on()

bool DigitalInputButton::on ( )
virtual

Test instantaneous input state.

Returns
true if the button is pushed, else false.

Implements AbstractButton.

Definition at line 19 of file DigitalInputButton.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: