Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
MIDI_Outputs
Bankable
Abstract
Bankable/Abstract/MIDIButtonMatrix.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
AH/Containers/Array.hpp
>
4
#include <
AH/Hardware/ButtonMatrix.hpp
>
5
#include <
Banks/BankableAddresses.hpp
>
6
#include <
Def/Def.hpp
>
7
#include <
MIDI_Outputs/Abstract/MIDIOutputElement.hpp
>
8
9
BEGIN_CS_NAMESPACE
10
11
namespace
Bankable
{
12
28
template
<
class
BankAddress,
class
Sender, u
int
8_t NumRows, u
int
8_t NumCols>
29
class
MIDIButtonMatrix
30
:
public
MIDIOutputElement
,
31
public
AH::ButtonMatrix
<
32
MIDIButtonMatrix<BankAddress, Sender, NumRows, NumCols>, NumRows,
33
NumCols> {
34
using
ButtonMatrix
=
AH::ButtonMatrix<MIDIButtonMatrix, NumRows, NumCols>
;
35
friend
class
AH::ButtonMatrix
<
MIDIButtonMatrix
, NumRows, NumCols>;
36
37
protected
:
55
MIDIButtonMatrix
(BankAddress bankAddress,
const
PinList<NumRows>
&
rowPins
,
56
const
PinList<NumCols>
&
colPins
,
const
Sender &
sender
)
57
:
ButtonMatrix
(
rowPins
,
colPins
),
address
(bankAddress),
sender
(
sender
) {
58
}
59
60
public
:
61
void
begin
()
override
{
ButtonMatrix::begin
(); }
62
63
void
update
()
override
{
ButtonMatrix::update
(); }
64
65
private
:
66
void
onButtonChanged
(uint8_t row, uint8_t col,
bool
state) {
67
if
(state ==
LOW
) {
68
if
(!
activeButtons
)
69
address
.lock();
// Don't allow changing of the bank setting
70
activeButtons
++;
71
sender
.sendOn(
address
.getActiveAddress(row, col));
72
}
else
{
73
sender
.sendOff(
address
.getActiveAddress(row, col));
74
activeButtons
--;
75
if
(!
activeButtons
)
76
address
.unlock();
77
}
78
}
79
80
protected
:
81
BankAddress
address
;
82
uint16_t
activeButtons
= 0;
83
84
public
:
85
Sender
sender
;
86
};
87
88
}
// namespace Bankable
89
90
END_CS_NAMESPACE
LOW
constexpr PinStatus_t LOW
Definition
Arduino-Hardware-Types.hpp:63
Array.hpp
BankableAddresses.hpp
ButtonMatrix.hpp
Def.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::ButtonMatrix
A class that reads the states of a button matrix.
Definition
ButtonMatrix.hpp:20
AH::ButtonMatrix< MIDIButtonMatrix, NumRows, NumCols >::begin
void begin()
AH::ButtonMatrix< MIDIButtonMatrix, NumRows, NumCols >::update
void update()
AH::ButtonMatrix< MIDIButtonMatrix< BankAddress, Sender, NumRows, NumCols >, NumRows, NumCols >::rowPins
const PinList< NumRows > rowPins
Definition
ButtonMatrix.hpp:88
AH::ButtonMatrix< MIDIButtonMatrix< BankAddress, Sender, NumRows, NumCols >, NumRows, NumCols >::colPins
const PinList< NumCols > colPins
Definition
ButtonMatrix.hpp:89
Bankable::MIDIButtonMatrix::address
BankAddress address
Definition
Bankable/Abstract/MIDIButtonMatrix.hpp:81
Bankable::MIDIButtonMatrix::activeButtons
uint16_t activeButtons
Definition
Bankable/Abstract/MIDIButtonMatrix.hpp:82
Bankable::MIDIButtonMatrix::onButtonChanged
void onButtonChanged(uint8_t row, uint8_t col, bool state)
Definition
Bankable/Abstract/MIDIButtonMatrix.hpp:66
Bankable::MIDIButtonMatrix::sender
Sender sender
Definition
Bankable/Abstract/MIDIButtonMatrix.hpp:85
Bankable::MIDIButtonMatrix::MIDIButtonMatrix
MIDIButtonMatrix(BankAddress bankAddress, const PinList< NumRows > &rowPins, const PinList< NumCols > &colPins, const Sender &sender)
Create a new Bankable MIDIButtonMatrix.
Definition
Bankable/Abstract/MIDIButtonMatrix.hpp:55
Bankable::MIDIButtonMatrix::update
void update() override
Update this updatable.
Definition
Bankable/Abstract/MIDIButtonMatrix.hpp:63
Bankable::MIDIButtonMatrix::begin
void begin() override
Initialize this updatable.
Definition
Bankable/Abstract/MIDIButtonMatrix.hpp:61
Bankable::MIDIButtonMatrix::ButtonMatrix
AH::ButtonMatrix< MIDIButtonMatrix, NumRows, NumCols > ButtonMatrix
Definition
Bankable/Abstract/MIDIButtonMatrix.hpp:34
AH::PinList
Array< pin_t, N > PinList
An easy alias for arrays of pins.
Definition
Hardware-Types.hpp:100
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