Control Surface  1.2.0
MIDI Control Surface library for Arduino
Abstract/MIDIButtonMatrix.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <Def/Def.hpp>
6 
8 
14 template <class Sender, uint8_t nb_rows, uint8_t nb_cols>
16  public AH::ButtonMatrix<nb_rows, nb_cols> {
17 
18  protected:
38  MIDIButtonMatrix(const PinList<nb_rows> &rowPins,
39  const PinList<nb_cols> &colPins,
41  MIDIChannelCN channelCN, const Sender &sender)
42  : AH::ButtonMatrix<nb_rows, nb_cols>(rowPins, colPins),
44 
45  public:
46  void begin() final override { AH::ButtonMatrix<nb_rows, nb_cols>::begin(); }
47 
48  void update() final override {
50  }
51 
52  private:
53  void onButtonChanged(uint8_t row, uint8_t col, bool state) final override {
54  int8_t address = addresses[row][col];
55  if (state == LOW)
56  sender.sendOn({address, baseChannelCN});
57  else
58  sender.sendOff({address, baseChannelCN});
59  }
60 
63 
64  public:
65  Sender sender;
66 };
67 
LOW
const PinStatus_t LOW
Definition: ExtendedInputOutput.hpp:57
AH::Updatable<>
MIDIOutputElement.hpp
MIDIButtonMatrix::begin
void begin() final override
Initialize this updatable.
Definition: Abstract/MIDIButtonMatrix.hpp:46
Def.hpp
MIDIChannelCN
A class for saving a MIDI channel and cable number.
Definition: MIDIAddress.hpp:19
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
AH::ButtonMatrix::colPins
const PinList< nb_cols > colPins
Definition: ButtonMatrix.hpp:86
MIDIButtonMatrix::addresses
AddressMatrix< nb_rows, nb_cols > addresses
Definition: Abstract/MIDIButtonMatrix.hpp:61
MIDIButtonMatrix::onButtonChanged
void onButtonChanged(uint8_t row, uint8_t col, bool state) final override
The callback function that is called whenever a button changes state.
Definition: Abstract/MIDIButtonMatrix.hpp:53
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
MIDIButtonMatrix::update
void update() final override
Update this updatable.
Definition: Abstract/MIDIButtonMatrix.hpp:48
MIDIButtonMatrix::MIDIButtonMatrix
MIDIButtonMatrix(const PinList< nb_rows > &rowPins, const PinList< nb_cols > &colPins, const AddressMatrix< nb_rows, nb_cols > &addresses, MIDIChannelCN channelCN, const Sender &sender)
Construct a new MIDIButtonMatrix.
Definition: Abstract/MIDIButtonMatrix.hpp:38
MIDIButtonMatrix
MIDIButtonMatrix.
Definition: Abstract/MIDIButtonMatrix.hpp:16
AH::ButtonMatrix::begin
void begin()
Initialize (enable internal pull-up resistors on column pins).
Definition: ButtonMatrix.ipp:41
AddressMatrix
Array2D< uint8_t, nb_rows, nb_cols > AddressMatrix
Definition: Def.hpp:27
ButtonMatrix.hpp
AH
PrintStream library
Definition: Array.hpp:14
AH::ButtonMatrix::rowPins
const PinList< nb_rows > rowPins
Definition: ButtonMatrix.hpp:85
AH::ButtonMatrix::ButtonMatrix
ButtonMatrix(const PinList< nb_rows > &rowPins, const PinList< nb_cols > &colPins)
Construct a new ButtonMatrix object.
Definition: ButtonMatrix.ipp:10
MIDIButtonMatrix::sender
Sender sender
Definition: Abstract/MIDIButtonMatrix.hpp:65
AH::ButtonMatrix
A class that reads the states of a button matrix.
Definition: ButtonMatrix.hpp:23
MIDIButtonMatrix::baseChannelCN
MIDIChannelCN baseChannelCN
Definition: Abstract/MIDIButtonMatrix.hpp:62
AH::ButtonMatrix::update
void update()
Scan the matrix, read all button states, and call the onButtonChanged callback.
Definition: ButtonMatrix.ipp:17