Control Surface main
MIDI Control Surface library for Arduino
IncrementButton.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
23 public:
31 IncrementButton(const Button &button) : button(button) {}
32
34 void begin() { button.begin(); }
35
41 enum State {
42 Nothing = 0,
48 };
49
53 State update() { return state = updateImplementation(); }
54
60 State getState() const { return state; }
61
63 void invert() { button.invert(); }
64
65 protected:
66 State updateImplementation();
67
68 private:
70
71 enum {
74 } longPressState = Initial;
75 unsigned long longPressRepeat;
76
77 State state = Nothing;
78};
79
81
#define END_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
#define AH_DIAGNOSTIC_POP()
Definition: Warnings.hpp:53
#define AH_DIAGNOSTIC_WERROR()
Definition: Warnings.hpp:52
A class for reading and debouncing buttons and switches.
Definition: Button.hpp:18
A class for buttons that increment some counter or setting.
IncrementButton(const Button &button)
Create a IncrementButton.
State
An enumeration of the different actions to be performed by the counter.
@ IncrementShort
The counter must be incremented (after short press).
@ IncrementHold
The counter must be incremented (still pressed).
@ ReleasedLong
The button was released after a long press.
@ IncrementLong
The counter must be incremented (after long press).
@ ReleasedShort
The button was released after a short press.
unsigned long longPressRepeat
State getState() const
Return the state of the increment button without updating it.
State update()
Update and return the state of the increment button.