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

#include <DualButton.h>

Public Member Functions

 DualButton (DebouncedButton *b1, DebouncedButton *b2)
 
void begin (uint8_t threshold=AbstractDebouncedButton::DefaultThreshold, uint8_t delay=AbstractDebouncedButton::DefaultButtonDelay)
 
void update ()
 
bool on ()
 
bool pushed ()
 
bool tapped ()
 
bool held (uint16_t ms=AbstractDebouncedButton::DefaultHeldMs)
 
bool repeat (uint16_t initialMs=AbstractDebouncedButton::DefaultButtonRepeatInitialMs, uint16_t repeatMs=AbstractDebouncedButton::DefaultButtonRepeatMs)
 

Detailed Description

Single button object responding to two inputs

Deprecated:
This class is now deprecated and will be removed from Mutile in the near future. Please consider using DualInputButton for instantaneous buttons, and DebouncedDualButton for a version with tapped() and other debounced features.

DualButton acts like a single button, but will respond to input from one of two separate DebouncedButtons on different pins and potentially with different pin logic. This makes it easy to have a second input (e.g. wired button and FM button) whilst maintaining the clean syntax of a single button object in your sketch.

Definition at line 20 of file DualButton.h.

Constructor & Destructor Documentation

◆ DualButton()

DualButton::DualButton ( DebouncedButton b1,
DebouncedButton b2 
)

Constructor

Parameters
b1A pointer to a DebouncedButton object
v2A pointer to a DebouncedButton object

Definition at line 3 of file DualButton.cpp.

Member Function Documentation

◆ begin()

void DualButton::begin ( uint8_t  threshold = AbstractDebouncedButton::DefaultThreshold,
uint8_t  delay = AbstractDebouncedButton::DefaultButtonDelay 
)

Initialization

Parameters
thresholdhow many tests of the pin must match for a state change
delaynumber of ms between tests of pin state

Should be called from setup(), or at any rate, before other members are called. This will call the begin() method in both of the linked DebouncedButtons.

Definition at line 9 of file DualButton.cpp.

Here is the call graph for this function:

◆ held()

bool DualButton::held ( uint16_t  ms = AbstractDebouncedButton::DefaultHeldMs)

Test if either button is held on for extended period

Parameters
mstime in ms the button has to have been on for to be considered held
Returns
true if either button is pushed and has been for longer than specified time.

Definition at line 36 of file DualButton.cpp.

Here is the call graph for this function:

◆ on()

bool DualButton::on ( )

Test instantaneous input state (with debouncing)

Returns
true if the button is pushed, else false.

Definition at line 21 of file DualButton.cpp.

Here is the call graph for this function:

◆ pushed()

bool DualButton::pushed ( )

Test if either button has been pushed since the last time it was off.

The idea is that you can called pushed lots of times ina tight loop and only get one true return pre press of the button regardless of how many times you test.

Definition at line 26 of file DualButton.cpp.

Here is the call graph for this function:

◆ repeat()

bool DualButton::repeat ( uint16_t  initialMs = AbstractDebouncedButton::DefaultButtonRepeatInitialMs,
uint16_t  repeatMs = AbstractDebouncedButton::DefaultButtonRepeatMs 
)

Get periodic press results when either button is held.

Parameters
initialMstime between first press and first repeat in ms
repeatMstime between subsequent releats
Returns
true when either button is pushed, but only every so often...

Definition at line 41 of file DualButton.cpp.

Here is the call graph for this function:

◆ tapped()

bool DualButton::tapped ( )

Test if either button has been pushed and released.

Returns
true if either button has been tapped, else false.

Definition at line 31 of file DualButton.cpp.

Here is the call graph for this function:

◆ update()

void DualButton::update ( )

Allocate Timeslice

This method must be called frequently - usually from loop()

Definition at line 15 of file DualButton.cpp.

Here is the call graph for this function:

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