Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Selectors
ManyButtonsSelector.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Selector.hpp
"
4
#include <
AH/Containers/ArrayHelpers.hpp
>
5
#include <
AH/Hardware/Button.hpp
>
6
#include <
Def/Def.hpp
>
7
8
BEGIN_CS_NAMESPACE
9
10
template
<setting_t N,
class
Callback = EmptySelectorCallback>
11
class
GenericManyButtonsSelector
:
public
GenericSelector
<N, Callback> {
12
using
Parent
=
GenericSelector<N, Callback>
;
13
14
public
:
15
GenericManyButtonsSelector
(
Selectable<N>
&
selectable
,
16
const
Callback &
callback
,
17
const
PinList<N>
&buttonPins)
18
:
GenericSelector
<N, Callback> {
selectable
,
callback
},
19
buttons
(
AH::copyAs<AH::Button>
(buttonPins)) {}
20
21
void
begin
()
override
{
22
Parent::begin
();
23
for
(
auto
&btn :
buttons
)
24
btn.begin();
25
}
26
27
void
update
()
override
{
28
Parent::update
();
29
for
(
setting_t
i = 0; i < N; i++)
30
if
(
buttons
[i].
update
() ==
AH::Button::Falling
&&
31
buttons
[this->
get
()].getState() !=
AH::Button::Pressed
)
32
this->
set
(i);
33
}
34
35
void
invert
() {
36
for
(
auto
&btn :
buttons
)
37
btn.invert();
38
}
39
40
private
:
41
AH::Array<AH::Button, N>
buttons
;
42
};
43
44
// -------------------------------------------------------------------------- //
45
60
template
<setting_t N>
61
class
ManyButtonsSelector
:
public
GenericManyButtonsSelector
<N> {
62
public
:
63
ManyButtonsSelector
(
Selectable<N>
&
selectable
,
const
PinList<N>
&buttonPins)
64
:
GenericManyButtonsSelector
<N> {
65
selectable
,
66
{},
67
buttonPins,
68
} {}
69
};
70
71
END_CS_NAMESPACE
ArrayHelpers.hpp
Button.hpp
Def.hpp
setting_t
uint8_t setting_t
The type used for Selectors.
Definition
Def.hpp:53
Selector.hpp
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::Pressed
@ Pressed
Input went from low to low (0,0).
Definition
Button.hpp:48
AH::Button::Falling
@ Falling
Input went from high to low (1,0).
Definition
Button.hpp:50
GenericManyButtonsSelector::update
void update() override
Update this updatable.
Definition
ManyButtonsSelector.hpp:27
GenericManyButtonsSelector::buttons
AH::Array< AH::Button, N > buttons
Definition
ManyButtonsSelector.hpp:41
GenericManyButtonsSelector::GenericManyButtonsSelector
GenericManyButtonsSelector(Selectable< N > &selectable, const Callback &callback, const PinList< N > &buttonPins)
Definition
ManyButtonsSelector.hpp:15
GenericManyButtonsSelector::begin
void begin() override
Initialize this updatable.
Definition
ManyButtonsSelector.hpp:21
GenericManyButtonsSelector::invert
void invert()
Definition
ManyButtonsSelector.hpp:35
GenericManyButtonsSelector::Parent
GenericSelector< N, Callback > Parent
Definition
ManyButtonsSelector.hpp:12
GenericSelector< N, EmptySelectorCallback >::set
void set(setting_t newSetting)
Definition
Selector.hpp:93
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
ManyButtonsSelector::ManyButtonsSelector
ManyButtonsSelector(Selectable< N > &selectable, const PinList< N > &buttonPins)
Definition
ManyButtonsSelector.hpp:63
Selectable
Definition
Selectable.hpp:11
GenericSelector< N, EmptySelectorCallback >::get
setting_t get() const
Definition
Selector.hpp:46
AH::copyAs
Array< T, N > copyAs(const Array< U, N > &src)
Copy an Array to an Array of a different type.
Definition
ArrayHelpers.hpp:105
AH::PinList
Array< pin_t, N > PinList
An easy alias for arrays of pins.
Definition
Hardware-Types.hpp:100
AH::Array
An array wrapper for easy copying, comparing, and iterating.
Definition
Array.hpp:32
Generated by
1.17.0