Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Selectors
IncrementSelector.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Selector.hpp
"
4
#include <
AH/Hardware/IncrementButton.hpp
>
5
6
BEGIN_CS_NAMESPACE
7
8
template
<setting_t N,
class
Callback = EmptySelectorCallback>
9
class
GenericIncrementSelector
:
public
GenericSelector
<N, Callback> {
10
using
Parent
=
GenericSelector<N, Callback>
;
11
12
public
:
13
GenericIncrementSelector
(
Selectable<N>
&
selectable
,
14
const
Callback &
callback
,
15
const
AH::IncrementButton
&
button
)
16
:
GenericSelector
<N, Callback> {
selectable
,
callback
},
button
(
button
) {}
17
18
void
begin
()
override
{
19
Parent::begin
();
20
button
.begin();
21
}
22
23
void
update
()
override
{
24
Parent::update
();
25
switch
(
button
.update()) {
26
case
AH::IncrementButton::Nothing
:
break
;
27
case
AH::IncrementButton::IncrementShort
:
// fallthrough
28
case
AH::IncrementButton::IncrementLong
:
// fallthrough
29
case
AH::IncrementButton::IncrementHold
:
30
this->
increment
(
Wrap::Wrap
);
31
break
;
32
case
AH::IncrementButton::ReleasedShort
:
break
;
33
case
AH::IncrementButton::ReleasedLong
:
break
;
34
default
:
break
;
35
}
36
}
37
38
AH::IncrementButton::State
getButtonState
()
const
{
39
return
button
.getState();
40
}
41
43
void
invert
() {
button
.invert(); }
44
45
private
:
46
AH::IncrementButton
button
;
47
};
48
49
// -------------------------------------------------------------------------- //
50
63
template
<setting_t N>
64
class
IncrementSelector
:
virtual
public
GenericIncrementSelector
<N> {
65
public
:
66
IncrementSelector
(
Selectable<N>
&
selectable
,
67
const
AH::IncrementButton
&
button
)
68
:
GenericIncrementSelector
<N> {
selectable
, {},
button
} {}
69
70
IncrementSelector
(
Selectable<N>
&
selectable
,
const
AH::Button
&
button
)
71
:
GenericIncrementSelector
<N> {
selectable
, {},
button
} {}
72
};
73
74
END_CS_NAMESPACE
IncrementButton.hpp
Selector.hpp
Wrap::Wrap
@ Wrap
When the maximum (minimum) setting is reached, wrap around to the minimum (maximum) setting.
Definition
Selector.hpp:17
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:14
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:11
AH::Button
A class for reading and debouncing buttons and switches.
Definition
Button.hpp:15
AH::IncrementButton
A class for buttons that increment some counter or setting.
Definition
IncrementButton.hpp:19
AH::IncrementButton::State
State
An enumeration of the different actions to be performed by the counter.
Definition
IncrementButton.hpp:38
AH::IncrementButton::Nothing
@ Nothing
The counter must not be incremented.
Definition
IncrementButton.hpp:39
AH::IncrementButton::IncrementShort
@ IncrementShort
The counter must be incremented (after short press).
Definition
IncrementButton.hpp:40
AH::IncrementButton::IncrementHold
@ IncrementHold
The counter must be incremented (still pressed).
Definition
IncrementButton.hpp:42
AH::IncrementButton::ReleasedLong
@ ReleasedLong
The button was released after a long press.
Definition
IncrementButton.hpp:44
AH::IncrementButton::IncrementLong
@ IncrementLong
The counter must be incremented (after long press).
Definition
IncrementButton.hpp:41
AH::IncrementButton::ReleasedShort
@ ReleasedShort
The button was released after a short press.
Definition
IncrementButton.hpp:43
GenericIncrementSelector::getButtonState
AH::IncrementButton::State getButtonState() const
Definition
IncrementSelector.hpp:38
GenericIncrementSelector::button
AH::IncrementButton button
Definition
IncrementSelector.hpp:46
GenericIncrementSelector::update
void update() override
Update this updatable.
Definition
IncrementSelector.hpp:23
GenericIncrementSelector::begin
void begin() override
Initialize this updatable.
Definition
IncrementSelector.hpp:18
GenericIncrementSelector::invert
void invert()
Definition
IncrementSelector.hpp:43
GenericIncrementSelector::GenericIncrementSelector
GenericIncrementSelector(Selectable< N > &selectable, const Callback &callback, const AH::IncrementButton &button)
Definition
IncrementSelector.hpp:13
GenericIncrementSelector::Parent
GenericSelector< N, Callback > Parent
Definition
IncrementSelector.hpp:10
GenericSelector< N, EmptySelectorCallback >::increment
void increment(Wrap wrap)
Definition
Selector.hpp:109
GenericSelector< N, EmptySelectorCallback >::callback
EmptySelectorCallback callback
Definition
Selector.hpp:144
GenericSelector< N, Callback >::update
void update() override
Definition
Selector.hpp:77
GenericSelector< N, EmptySelectorCallback >::selectable
Selectable< N > & selectable
Definition
Selector.hpp:141
GenericSelector< N, Callback >::begin
void begin() override
Definition
Selector.hpp:72
GenericSelector< N, EmptySelectorCallback >::GenericSelector
GenericSelector(Selectable< N > &selectable, const EmptySelectorCallback &callback)
Definition
Selector.hpp:69
IncrementSelector::IncrementSelector
IncrementSelector(Selectable< N > &selectable, const AH::Button &button)
Definition
IncrementSelector.hpp:70
IncrementSelector::IncrementSelector
IncrementSelector(Selectable< N > &selectable, const AH::IncrementButton &button)
Definition
IncrementSelector.hpp:66
Selectable
Definition
Selectable.hpp:11
Generated by
1.17.0