Control Surface pin-t-adl
MIDI Control Surface library for Arduino
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
IncrementButton Class Reference

#include <AH/Hardware/IncrementButton.hpp>

Detailed Description

A class for buttons that increment some counter or setting.

It behaves the same way as a computer keyboard: when you press the button, it increments the counter once. If you keep on pressing it for longer than a certain threshold, it keeps on incrementing at a faster rate, until you release it.

Definition at line 22 of file IncrementButton.hpp.

+ Collaboration diagram for IncrementButton:

Public Types

enum  State {
  Nothing = 0 , IncrementShort , IncrementLong , IncrementHold ,
  ReleasedShort , ReleasedLong
}
 An enumeration of the different actions to be performed by the counter. More...
 

Public Member Functions

 IncrementButton (const Button &button)
 Create a IncrementButton. More...
 
void begin ()
 
State update ()
 Update and return the state of the increment button. More...
 
State getState () const
 Return the state of the increment button without updating it. More...
 
void invert ()
 

Protected Member Functions

State updateImplementation ()
 

Private Types

enum  { Initial , LongPress }
 

Private Attributes

Button button
 
enum AH::IncrementButton:: { ... }  longPressState = Initial
 
unsigned long longPressRepeat
 
State state = Nothing
 

Member Enumeration Documentation

◆ State

enum State

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

Enumerator
Nothing 

The counter must not be incremented.

IncrementShort 

The counter must be incremented (after short press).

IncrementLong 

The counter must be incremented (after long press).

IncrementHold 

The counter must be incremented (still pressed).

ReleasedShort 

The button was released after a short press.

ReleasedLong 

The button was released after a long press.

Definition at line 41 of file IncrementButton.hpp.

◆ anonymous enum

anonymous enum
private
Enumerator
Initial 
LongPress 

Definition at line 71 of file IncrementButton.hpp.

Constructor & Destructor Documentation

◆ IncrementButton()

IncrementButton ( const Button button)
inline

Create a IncrementButton.

Parameters
buttonThe button to read from.
The button is copied.

Definition at line 31 of file IncrementButton.hpp.

Member Function Documentation

◆ begin()

void begin ( )
inline
See also
Button::begin

Definition at line 34 of file IncrementButton.hpp.

◆ update()

State update ( )
inline

Update and return the state of the increment button.

Definition at line 53 of file IncrementButton.hpp.

◆ getState()

State getState ( ) const
inline

Return the state of the increment button without updating it.

Returns the same value as the last update call.

Definition at line 60 of file IncrementButton.hpp.

◆ invert()

void invert ( )
inline
See also
Button::invert

Definition at line 63 of file IncrementButton.hpp.

◆ updateImplementation()

IncrementButton::State updateImplementation ( )
protected

Definition at line 7 of file IncrementButton.cpp.

Member Data Documentation

◆ button

Button button
private

Definition at line 69 of file IncrementButton.hpp.

◆ 

enum { ... } longPressState

◆ longPressRepeat

unsigned long longPressRepeat
private

Definition at line 75 of file IncrementButton.hpp.

◆ state

State state = Nothing
private

Definition at line 77 of file IncrementButton.hpp.


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