Control Surface  1.2.0
MIDI Control Surface library for Arduino
IncrementDecrementButtons.hpp
Go to the documentation of this file.
1 /* ✔ */
2 
3 #pragma once
4 
6 AH_DIAGNOSTIC_WERROR() // Enable errors on warnings
7 
8 #include "Button.hpp"
9 
11 
26  public:
37  IncrementDecrementButtons(const Button &incrementButton,
38  const Button &decrementButton)
39  : incrementButton(incrementButton), decrementButton(decrementButton) {}
40 
42  void begin() {
43  incrementButton.begin();
44  decrementButton.begin();
45  }
46 
52  enum State {
53  Nothing = 0,
61  };
62 
66  State update() { return state = updateImplementation(); }
67 
74  State getState() const { return state; }
75 
76 #ifdef AH_INDIVIDUAL_BUTTON_INVERT
77  void invert() {
79  incrementButton.invert();
80  decrementButton.invert();
81  }
82 #endif
83 
84  protected:
85  State updateImplementation();
86 
87  private:
90 
91  enum {
95  } longPressState = Initial;
96  unsigned long longPressRepeat;
97  State state = Nothing;
98 };
99 
101 
AH::IncrementDecrementButtons::Reset
@ Reset
The counter should be reset to the initial value.
Definition: IncrementDecrementButtons.hpp:60
AH::IncrementDecrementButtons::longPressRepeat
unsigned long longPressRepeat
Definition: IncrementDecrementButtons.hpp:96
AH::IncrementDecrementButtons::State
State
An enumeration of the different actions to be performed by the counter.
Definition: IncrementDecrementButtons.hpp:52
Warnings.hpp
AH::IncrementDecrementButtons::Initial
@ Initial
Definition: IncrementDecrementButtons.hpp:92
AH::IncrementDecrementButtons::LongPress
@ LongPress
Definition: IncrementDecrementButtons.hpp:93
AH::IncrementDecrementButtons::getState
State getState() const
Return the state of the increment/decrement button without updating it.
Definition: IncrementDecrementButtons.hpp:74
AH::Button
A class for reading and debouncing buttons and switches.
Definition: Button.hpp:18
AH::IncrementDecrementButtons::update
State update()
Update and return the state of the increment/decrement button.
Definition: IncrementDecrementButtons.hpp:66
AH::IncrementDecrementButtons
A class for buttons that increment and decrement some counter or setting.
Definition: IncrementDecrementButtons.hpp:25
AH_DIAGNOSTIC_POP
#define AH_DIAGNOSTIC_POP()
Definition: Warnings.hpp:36
AH::IncrementDecrementButtons::begin
void begin()
Definition: IncrementDecrementButtons.hpp:42
AH::IncrementDecrementButtons::IncrementLong
@ IncrementLong
The counter must be incremented (after long press).
Definition: IncrementDecrementButtons.hpp:55
AH::IncrementDecrementButtons::decrementButton
Button decrementButton
Definition: IncrementDecrementButtons.hpp:89
AH::IncrementDecrementButtons::DecrementLong
@ DecrementLong
The counter must be decremented (after long press).
Definition: IncrementDecrementButtons.hpp:58
AH::IncrementDecrementButtons::AfterReset
@ AfterReset
Definition: IncrementDecrementButtons.hpp:94
AH::IncrementDecrementButtons::IncrementShort
@ IncrementShort
The counter must be incremented (after short press).
Definition: IncrementDecrementButtons.hpp:54
AH_DIAGNOSTIC_WERROR
#define AH_DIAGNOSTIC_WERROR()
Definition: Warnings.hpp:35
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:9
AH::IncrementDecrementButtons::incrementButton
Button incrementButton
Definition: IncrementDecrementButtons.hpp:88
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:10
AH::IncrementDecrementButtons::IncrementHold
@ IncrementHold
The counter must be incremented (still pressed).
Definition: IncrementDecrementButtons.hpp:56
AH::IncrementDecrementButtons::IncrementDecrementButtons
IncrementDecrementButtons(const Button &incrementButton, const Button &decrementButton)
Create a IncrementDecrementButtons object.
Definition: IncrementDecrementButtons.hpp:37
AH::IncrementDecrementButtons::DecrementHold
@ DecrementHold
The counter must be decremented (still pressed).
Definition: IncrementDecrementButtons.hpp:59
AH::IncrementDecrementButtons::DecrementShort
@ DecrementShort
The counter must be decremented (after short press).
Definition: IncrementDecrementButtons.hpp:57