Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
MIDI_Outputs
Abstract
Abstract/MIDIButtonMatrix.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
AH/Hardware/ButtonMatrix.hpp
>
4
#include <
Def/Def.hpp
>
5
#include <
MIDI_Outputs/Abstract/MIDIOutputElement.hpp
>
6
7
BEGIN_CS_NAMESPACE
8
14
template
<
class
Sender, u
int
8_t NumRows, u
int
8_t NumCols>
15
class
MIDIButtonMatrix
16
:
public
MIDIOutputElement
,
17
public
AH::ButtonMatrix
<MIDIButtonMatrix<Sender, NumRows, NumCols>,
18
NumRows, NumCols> {
19
using
ButtonMatrix
=
AH::ButtonMatrix<MIDIButtonMatrix, NumRows, NumCols>
;
20
friend
class
AH::ButtonMatrix
<
MIDIButtonMatrix
, NumRows, NumCols>;
21
22
protected
:
42
MIDIButtonMatrix
(
const
PinList<NumRows>
&
rowPins
,
43
const
PinList<NumCols>
&
colPins
,
44
const
AddressMatrix<NumRows, NumCols>
&
addresses
,
45
MIDIChannelCable
channelCN,
const
Sender &
sender
)
46
:
ButtonMatrix
(
rowPins
,
colPins
),
addresses
(
addresses
),
47
baseChannelCN
(channelCN),
sender
(
sender
) {}
48
49
public
:
50
void
begin
() final
override
{
ButtonMatrix::begin
(); }
51
52
void
update
() final
override
{
ButtonMatrix::update
(); }
53
55
MIDIAddress
getAddress
(uint8_t row, uint8_t col)
const
{
56
return
{this->
addresses
[row][col],
baseChannelCN
};
57
}
58
61
void
setAddressUnsafe
(uint8_t row, uint8_t col, uint8_t address) {
62
this->
addresses
[row][col] = address;
63
}
64
65
MIDIChannelCable
getChannelCable
()
const
{
return
this->
baseChannelCN
; }
69
void
setChannelCableUnsafe
(
MIDIChannelCable
bccn) {
70
this->
baseChannelCN
= bccn;
71
}
72
73
private
:
74
void
onButtonChanged
(uint8_t row, uint8_t col,
bool
state) {
75
int8_t address =
addresses
[row][col];
76
if
(state ==
LOW
)
77
sender
.sendOn({address,
baseChannelCN
});
78
else
79
sender
.sendOff({address,
baseChannelCN
});
80
}
81
82
AddressMatrix<NumRows, NumCols>
addresses
;
83
MIDIChannelCable
baseChannelCN
;
84
85
public
:
86
Sender
sender
;
87
};
88
89
END_CS_NAMESPACE
LOW
constexpr PinStatus_t LOW
Definition
Arduino-Hardware-Types.hpp:63
ButtonMatrix.hpp
Def.hpp
AddressMatrix
Array2D< uint8_t, NumRows, NumCols > AddressMatrix
Definition
Def.hpp:30
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< Sender, NumRows, NumCols >, NumRows, NumCols >::rowPins
const PinList< NumRows > rowPins
Definition
ButtonMatrix.hpp:88
AH::ButtonMatrix< MIDIButtonMatrix< Sender, NumRows, NumCols >, NumRows, NumCols >::colPins
const PinList< NumCols > colPins
Definition
ButtonMatrix.hpp:89
MIDIAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition
MIDIAddress.hpp:145
MIDIButtonMatrix::setAddressUnsafe
void setAddressUnsafe(uint8_t row, uint8_t col, uint8_t address)
Set the MIDI address of button at the given row and column.
Definition
Abstract/MIDIButtonMatrix.hpp:61
MIDIButtonMatrix::onButtonChanged
void onButtonChanged(uint8_t row, uint8_t col, bool state)
Definition
Abstract/MIDIButtonMatrix.hpp:74
MIDIButtonMatrix::sender
Sender sender
Definition
Abstract/MIDIButtonMatrix.hpp:86
MIDIButtonMatrix::addresses
AddressMatrix< NumRows, NumCols > addresses
Definition
Abstract/MIDIButtonMatrix.hpp:82
MIDIButtonMatrix::getChannelCable
MIDIChannelCable getChannelCable() const
Get the MIDI channel and cable number.
Definition
Abstract/MIDIButtonMatrix.hpp:65
MIDIButtonMatrix::begin
void begin() final override
Initialize this updatable.
Definition
Abstract/MIDIButtonMatrix.hpp:50
MIDIButtonMatrix::getAddress
MIDIAddress getAddress(uint8_t row, uint8_t col) const
Get the MIDI address of the button at the given row and column.
Definition
Abstract/MIDIButtonMatrix.hpp:55
MIDIButtonMatrix::setChannelCableUnsafe
void setChannelCableUnsafe(MIDIChannelCable bccn)
Set the MIDI channel and cable number of all buttons.
Definition
Abstract/MIDIButtonMatrix.hpp:69
MIDIButtonMatrix::baseChannelCN
MIDIChannelCable baseChannelCN
Definition
Abstract/MIDIButtonMatrix.hpp:83
MIDIButtonMatrix::MIDIButtonMatrix
MIDIButtonMatrix(const PinList< NumRows > &rowPins, const PinList< NumCols > &colPins, const AddressMatrix< NumRows, NumCols > &addresses, MIDIChannelCable channelCN, const Sender &sender)
Construct a new MIDIButtonMatrix.
Definition
Abstract/MIDIButtonMatrix.hpp:42
MIDIButtonMatrix::ButtonMatrix
AH::ButtonMatrix< MIDIButtonMatrix, NumRows, NumCols > ButtonMatrix
Definition
Abstract/MIDIButtonMatrix.hpp:19
MIDIButtonMatrix::update
void update() final override
Update this updatable.
Definition
Abstract/MIDIButtonMatrix.hpp:52
MIDIChannelCable
A class for saving a MIDI channel and cable number.
Definition
MIDIAddress.hpp:24
AH::PinList
Array< pin_t, N > PinList
An easy alias for arrays of pins.
Definition
Hardware-Types.hpp:100
Generated by
1.17.0