Control Surface
2.1.2
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
MIDI_Outputs
Bankable
Abstract
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
AH/Hardware/IncrementDecrementButtons.hpp
>
4
#include <
Banks/BankableAddresses.hpp
>
5
#include <
Def/Def.hpp
>
6
#include <
MIDI_Outputs/Abstract/MIDIOutputElement.hpp
>
7
#include <
MIDI_Senders/DigitalNoteSender.hpp
>
8
9
BEGIN_CS_NAMESPACE
10
11
namespace
Bankable
{
12
18
template
<
class
BankAddress,
class
RelativeSender,
class
ResetSender>
19
class
MIDIIncrementDecrementButtons
:
public
MIDIOutputElement
{
20
protected
:
26
MIDIIncrementDecrementButtons
(BankAddress
addresses
,
27
const
AH::IncrementDecrementButtons
&
buttons
,
28
uint8_t
multiplier
,
29
const
RelativeSender &
relativeSender
,
30
const
ResetSender &
resetSender
)
31
:
addresses
(
addresses
),
buttons
(
buttons
),
multiplier
(
multiplier
),
32
relativeSender
(
relativeSender
),
resetSender
(
resetSender
) {}
33
34
public
:
35
void
begin
()
override
{
buttons
.begin(); }
36
37
void
update
()
override
{
38
using
IncrDecrButtons =
AH::IncrementDecrementButtons
;
39
MIDIAddress
address =
addresses
.getFirstActiveAddress();
40
switch
(
buttons
.update()) {
41
case
IncrDecrButtons::Nothing:
break
;
42
case
IncrDecrButtons::IncrementShort:
// fallthrough
43
case
IncrDecrButtons::IncrementLong:
// fallthrough
44
case
IncrDecrButtons::IncrementHold:
45
send
(
multiplier
, address);
46
break
;
47
case
IncrDecrButtons::DecrementShort:
// fallthrough
48
case
IncrDecrButtons::DecrementLong:
// fallthrough
49
case
IncrDecrButtons::DecrementHold:
50
send
(-
multiplier
, address);
51
break
;
52
case
IncrDecrButtons::Reset:
reset
();
break
;
53
default
:
break
;
54
}
55
}
56
57
void
send
(
long
delta,
MIDIAddress
address) {
58
relativeSender
.send(delta, address);
59
}
60
61
void
reset
() {
62
MIDIAddress
address =
addresses
.getSecondActiveAddress();
63
if
(address) {
64
resetSender
.sendOn(address);
65
resetSender
.sendOff(address);
66
}
67
}
68
70
void
invert
() {
buttons
.invert(); }
71
72
AH::IncrementDecrementButtons::State
getButtonsState
()
const
{
73
return
buttons
.getState();
74
}
75
76
protected
:
77
BankAddress
addresses
;
78
AH::IncrementDecrementButtons
buttons
;
79
const
uint8_t
multiplier
;
80
81
public
:
82
RelativeSender
relativeSender
;
83
ResetSender
resetSender
;
84
};
85
86
}
// namespace Bankable
87
88
END_CS_NAMESPACE
BankableAddresses.hpp
Def.hpp
DigitalNoteSender.hpp
IncrementDecrementButtons.hpp
MIDIOutputElement.hpp
MIDIOutputElement
AH::Updatable<> MIDIOutputElement
Definition
MIDIOutputElement.hpp:9
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::IncrementDecrementButtons
A class for buttons that increment and decrement some counter or setting.
Definition
IncrementDecrementButtons.hpp:22
AH::IncrementDecrementButtons::State
State
An enumeration of the different actions to be performed by the counter.
Definition
IncrementDecrementButtons.hpp:49
Bankable::MIDIIncrementDecrementButtons::resetSender
ResetSender resetSender
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:83
Bankable::MIDIIncrementDecrementButtons::getButtonsState
AH::IncrementDecrementButtons::State getButtonsState() const
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:72
Bankable::MIDIIncrementDecrementButtons::update
void update() override
Update this updatable.
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:37
Bankable::MIDIIncrementDecrementButtons::multiplier
const uint8_t multiplier
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:79
Bankable::MIDIIncrementDecrementButtons::begin
void begin() override
Initialize this updatable.
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:35
Bankable::MIDIIncrementDecrementButtons::invert
void invert()
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:70
Bankable::MIDIIncrementDecrementButtons::buttons
AH::IncrementDecrementButtons buttons
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:78
Bankable::MIDIIncrementDecrementButtons::MIDIIncrementDecrementButtons
MIDIIncrementDecrementButtons(BankAddress addresses, const AH::IncrementDecrementButtons &buttons, uint8_t multiplier, const RelativeSender &relativeSender, const ResetSender &resetSender)
Construct a new MIDIIncrementDecrementButtons.
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:26
Bankable::MIDIIncrementDecrementButtons::send
void send(long delta, MIDIAddress address)
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:57
Bankable::MIDIIncrementDecrementButtons::reset
void reset()
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:61
Bankable::MIDIIncrementDecrementButtons::addresses
BankAddress addresses
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:77
Bankable::MIDIIncrementDecrementButtons::relativeSender
RelativeSender relativeSender
Definition
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:82
MIDIAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition
MIDIAddress.hpp:145
Bankable
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Definition
BankAddresses.hpp:7
Generated by
1.17.0