Control Surface  1.1.0
MIDI Control Surface library for Arduino
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
AH::IncrementDecrementButtons Class Reference

A class for buttons that increment and decrement some counter or setting. More...

#include <IncrementDecrementButtons.hpp>

Collaboration diagram for AH::IncrementDecrementButtons:

Public Types

enum  State { Nothing = 0, Increment, Decrement, Reset }
 An enumeration of the different actions to be performed by the counter. More...
 

Public Member Functions

 IncrementDecrementButtons (const Button &incrementButton, const Button &decrementButton)
 Create a IncrementDecrementButtons object. More...
 
void begin ()
 
State update ()
 Update and return the state of the increment/decrement button. More...
 
State getState () const
 Return the state of the increment/decrement button without updating it. More...
 

Protected Member Functions

State updateImplementation ()
 

Private Types

enum  { Initial, LongPress, AfterReset }
 

Private Attributes

Button incrementButton
 
Button decrementButton
 
enum AH::IncrementDecrementButtons:: { ... }  longPressState = Initial
 
unsigned long longPressRepeat
 
State state = Nothing
 

Detailed Description

A class for buttons that increment and decrement some counter or setting.

It behaves the same way as a computer keyboard: when you press the increment (decrement) button, it increments (decrements) the counter once. If you keep on pressing it for longer than a certain threshold, it keeps on incrementing (decrementing) at a faster rate, until you release it.
If both the increment and the decrement button are pressed at once, it resets the counter.

Definition at line 25 of file IncrementDecrementButtons.hpp.

Member Enumeration Documentation

◆ State

An enumeration of the different actions to be performed by the counter.

Todo:
Add states for initial press.
Enumerator
Nothing 

The counter should not be incremented.

Increment 

The counter should be incremented.

Decrement 

The counter should be decremented.

Reset 

The counter should be reset to the initial value.

Definition at line 52 of file IncrementDecrementButtons.hpp.

◆ anonymous enum

anonymous enum
private
Enumerator
Initial 
LongPress 
AfterReset 

Definition at line 87 of file IncrementDecrementButtons.hpp.

Constructor & Destructor Documentation

◆ IncrementDecrementButtons()

AH::IncrementDecrementButtons::IncrementDecrementButtons ( const Button incrementButton,
const Button decrementButton 
)
inline

Create a IncrementDecrementButtons object.

Parameters
incrementButtonThe button to increment the counter.
The button is copied.
decrementButtonThe button to decrement the counter.
The button is copied.

Definition at line 37 of file IncrementDecrementButtons.hpp.

Member Function Documentation

◆ begin()

void AH::IncrementDecrementButtons::begin ( )
inline
See also
Button::begin

Definition at line 42 of file IncrementDecrementButtons.hpp.

◆ update()

State AH::IncrementDecrementButtons::update ( )
inline

Update and return the state of the increment/decrement button.

Definition at line 62 of file IncrementDecrementButtons.hpp.

◆ getState()

State AH::IncrementDecrementButtons::getState ( ) const
inline

Return the state of the increment/decrement button without updating it.

Returns the same value as the last update call.

Definition at line 70 of file IncrementDecrementButtons.hpp.

◆ updateImplementation()

IncrementDecrementButtons::State AH::IncrementDecrementButtons::updateImplementation ( )
protected

Definition at line 8 of file IncrementDecrementButtons.cpp.

Member Data Documentation

◆ incrementButton

Button AH::IncrementDecrementButtons::incrementButton
private

Definition at line 84 of file IncrementDecrementButtons.hpp.

◆ decrementButton

Button AH::IncrementDecrementButtons::decrementButton
private

Definition at line 85 of file IncrementDecrementButtons.hpp.

◆ longPressState

enum { ... } AH::IncrementDecrementButtons::longPressState

◆ longPressRepeat

unsigned long AH::IncrementDecrementButtons::longPressRepeat
private

Definition at line 92 of file IncrementDecrementButtons.hpp.

◆ state

State AH::IncrementDecrementButtons::state = Nothing
private

Definition at line 93 of file IncrementDecrementButtons.hpp.


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