Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Selectors
SwitchSelector.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Selector.hpp
"
4
#include <
AH/Hardware/Button.hpp
>
5
6
BEGIN_CS_NAMESPACE
7
8
template
<
class
Callback = EmptySelectorCallback>
9
class
GenericSwitchSelector
:
public
GenericSelector
<2, Callback> {
10
using
Parent
=
GenericSelector<2, Callback>
;
11
12
public
:
13
GenericSwitchSelector
(
Selectable<2>
&
selectable
,
const
Callback &
callback
,
14
const
AH::Button
&
button
)
15
:
GenericSelector
<2, Callback>(
selectable
,
callback
),
button
(
button
) {}
16
17
void
begin
()
override
{
18
Parent::begin
();
19
button
.begin();
20
}
21
22
void
update
()
override
{
23
Parent::update
();
24
AH::Button::State
state =
button
.update();
25
if
(state ==
AH::Button::Falling
)
26
this->
set
(1);
27
else
if
(state ==
AH::Button::Rising
)
28
this->
set
(0);
29
}
30
31
AH::Button::State
getButtonState
()
const
{
return
button
.getState(); }
32
34
void
invert
() {
button
.invert(); }
35
36
private
:
37
AH::Button
button
;
38
};
39
50
class
SwitchSelector
:
public
GenericSwitchSelector
<> {
51
public
:
52
SwitchSelector
(
Selectable<2>
&
selectable
,
const
AH::Button
&
button
)
53
:
GenericSwitchSelector
<> {
54
selectable
,
55
{},
56
button
,
57
} {}
58
};
59
60
END_CS_NAMESPACE
Button.hpp
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
A class for reading and debouncing buttons and switches.
Definition
Button.hpp:15
AH::Button::State
State
An enumeration of the different states a button can be in.
Definition
Button.hpp:47
AH::Button::Rising
@ Rising
Input went from low to high (0,1).
Definition
Button.hpp:51
AH::Button::Falling
@ Falling
Input went from high to low (1,0).
Definition
Button.hpp:50
GenericSelector< 2, EmptySelectorCallback >::set
void set(setting_t newSetting)
Definition
Selector.hpp:93
GenericSelector< 2, EmptySelectorCallback >::callback
EmptySelectorCallback callback
Definition
Selector.hpp:144
GenericSelector< 2, Callback >::update
void update() override
Definition
Selector.hpp:77
GenericSelector< 2, EmptySelectorCallback >::selectable
Selectable< N > & selectable
Definition
Selector.hpp:141
GenericSelector< 2, Callback >::begin
void begin() override
Definition
Selector.hpp:72
GenericSelector< 2, EmptySelectorCallback >::GenericSelector
GenericSelector(Selectable< N > &selectable, const EmptySelectorCallback &callback)
Definition
Selector.hpp:69
GenericSwitchSelector::button
AH::Button button
Definition
SwitchSelector.hpp:37
GenericSwitchSelector::getButtonState
AH::Button::State getButtonState() const
Definition
SwitchSelector.hpp:31
GenericSwitchSelector::update
void update() override
Update this updatable.
Definition
SwitchSelector.hpp:22
GenericSwitchSelector::begin
void begin() override
Initialize this updatable.
Definition
SwitchSelector.hpp:17
GenericSwitchSelector::invert
void invert()
Definition
SwitchSelector.hpp:34
GenericSwitchSelector::GenericSwitchSelector
GenericSwitchSelector(Selectable< 2 > &selectable, const Callback &callback, const AH::Button &button)
Definition
SwitchSelector.hpp:13
GenericSwitchSelector::Parent
GenericSelector< 2, Callback > Parent
Definition
SwitchSelector.hpp:10
Selectable
Definition
Selectable.hpp:11
SwitchSelector::SwitchSelector
SwitchSelector(Selectable< 2 > &selectable, const AH::Button &button)
Definition
SwitchSelector.hpp:52
Generated by
1.17.0