Control Surface pin-t-adl
MIDI Control Surface library for Arduino
IncrementDecrementButtons.hpp
Go to the documentation of this file.
1/* ✔ */
2
3#pragma once
4
6AH_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
77 void invert() {
78 incrementButton.invert();
79 decrementButton.invert();
80 }
81
82 protected:
83 State updateImplementation();
84
85 private:
88
89 enum {
93 } longPressState = Initial;
94 unsigned long longPressRepeat;
95 State state = Nothing;
96};
97
99
#define END_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
#define AH_DIAGNOSTIC_POP()
Definition: Warnings.hpp:36
#define AH_DIAGNOSTIC_WERROR()
Definition: Warnings.hpp:35
A class for reading and debouncing buttons and switches.
Definition: Button.hpp:18
A class for buttons that increment and decrement some counter or setting.
IncrementDecrementButtons(const Button &incrementButton, const Button &decrementButton)
Create a IncrementDecrementButtons object.
State
An enumeration of the different actions to be performed by the counter.
@ DecrementLong
The counter must be decremented (after long press).
@ IncrementShort
The counter must be incremented (after short press).
@ IncrementHold
The counter must be incremented (still pressed).
@ DecrementHold
The counter must be decremented (still pressed).
@ DecrementShort
The counter must be decremented (after short press).
@ Reset
The counter should be reset to the initial value.
@ IncrementLong
The counter must be incremented (after long press).
State getState() const
Return the state of the increment/decrement button without updating it.
State update()
Update and return the state of the increment/decrement button.