Control Surface  1.1.1
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,
57  };
58 
62  State update() { return state = updateImplementation(); }
63 
70  State getState() const { return state; }
71 
72 #ifdef AH_INDIVIDUAL_BUTTON_INVERT
73  void invert() {
75  incrementButton.invert();
76  decrementButton.invert();
77  }
78 #endif
79 
80  protected:
81  State updateImplementation();
82 
83  private:
86 
87  enum {
91  } longPressState = Initial;
92  unsigned long longPressRepeat;
93  State state = Nothing;
94 };
95 
97 
AH::IncrementDecrementButtons::Reset
The counter should be reset to the initial value.
Definition: IncrementDecrementButtons.hpp:56
AH::IncrementDecrementButtons::longPressRepeat
unsigned long longPressRepeat
Definition: IncrementDecrementButtons.hpp:92
AH::IncrementDecrementButtons::State
State
An enumeration of the different actions to be performed by the counter.
Definition: IncrementDecrementButtons.hpp:52
Warnings.hpp
AH::IncrementDecrementButtons::getState
State getState() const
Return the state of the increment/decrement button without updating it.
Definition: IncrementDecrementButtons.hpp:70
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:62
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:17
AH::IncrementDecrementButtons::LongPress
Definition: IncrementDecrementButtons.hpp:89
AH::IncrementDecrementButtons::Increment
The counter should be incremented.
Definition: IncrementDecrementButtons.hpp:54
AH::IncrementDecrementButtons::begin
void begin()
Definition: IncrementDecrementButtons.hpp:42
AH::IncrementDecrementButtons::decrementButton
Button decrementButton
Definition: IncrementDecrementButtons.hpp:85
AH::IncrementDecrementButtons::Decrement
The counter should be decremented.
Definition: IncrementDecrementButtons.hpp:55
AH::IncrementDecrementButtons::AfterReset
Definition: IncrementDecrementButtons.hpp:90
AH_DIAGNOSTIC_WERROR
#define AH_DIAGNOSTIC_WERROR()
Definition: Warnings.hpp:16
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:9
AH::IncrementDecrementButtons::incrementButton
Button incrementButton
Definition: IncrementDecrementButtons.hpp:84
AH::IncrementDecrementButtons::Initial
Definition: IncrementDecrementButtons.hpp:88
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:10
AH::IncrementDecrementButtons::IncrementDecrementButtons
IncrementDecrementButtons(const Button &incrementButton, const Button &decrementButton)
Create a IncrementDecrementButtons object.
Definition: IncrementDecrementButtons.hpp:37