Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
IncrementDecrementButtons.hpp
Go to the documentation of this file.
1/* ✔ */
2
3#pragma once
4
5#include "Button.hpp"
6
8
23 public:
34 IncrementDecrementButtons(const Button &incrementButton,
35 const Button &decrementButton)
36 : incrementButton(incrementButton), decrementButton(decrementButton) {}
37
39 void begin() {
40 incrementButton.begin();
41 decrementButton.begin();
42 }
43
59
63 State update() { return state = updateImplementation(); }
64
71 State getState() const { return state; }
72
74 void invert() {
75 incrementButton.invert();
76 decrementButton.invert();
77 }
78
79 protected:
80 State updateImplementation();
81
82 private:
85
86 enum {
90 } longPressState = Initial;
91 unsigned long longPressRepeat;
92 State state = Nothing;
93};
94
#define END_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
A class for reading and debouncing buttons and switches.
Definition Button.hpp:15
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.
T * begin()
Get a pointer to the first element.
Definition Array.hpp:74