Control Surface  1.1.1
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:
23  MIDIButtonMatrix(const PinList<nb_rows> &rowPins,
24  const PinList<nb_cols> &colPins,
26  MIDICNChannel channelCN, const Sender &sender)
27  : AH::ButtonMatrix<nb_rows, nb_cols>(rowPins, colPins),
29 
30  public:
31  void begin() final override { AH::ButtonMatrix<nb_rows, nb_cols>::begin(); }
32 
33  void update() final override {
35  }
36 
37  private:
38  void onButtonChanged(uint8_t row, uint8_t col, bool state) final override {
39  int8_t address = addresses[row][col];
40  if (state == LOW)
41  sender.sendOn({address, baseChannelCN});
42  else
43  sender.sendOff({address, baseChannelCN});
44  }
45 
48 
49  public:
50  Sender sender;
51 };
52 
AH::Updatable
A super class for object that have to be updated regularly.
Definition: Updatable.hpp:25
MIDIOutputElement.hpp
MIDIButtonMatrix::begin
void begin() final override
Initialize this updatable.
Definition: Abstract/MIDIButtonMatrix.hpp:31
Def.hpp
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:46
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:38
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:33
MIDIButtonMatrix
MIDIButtonMatrix.
Definition: Abstract/MIDIButtonMatrix.hpp:15
MIDIButtonMatrix::MIDIButtonMatrix
MIDIButtonMatrix(const PinList< nb_rows > &rowPins, const PinList< nb_cols > &colPins, const AddressMatrix< nb_rows, nb_cols > &addresses, MIDICNChannel channelCN, const Sender &sender)
Definition: Abstract/MIDIButtonMatrix.hpp:23
AH::ButtonMatrix::begin
void begin()
Initialize (enable internal pull-up resistors on column pins).
Definition: ButtonMatrix.ipp:41
LOW
const uint8_t LOW
Definition: ExtendedInputOutput.hpp:47
MIDICNChannel
A class for saving a MIDI channel and cable number.
Definition: MIDICNChannelAddress.hpp:19
AddressMatrix
Array2D< uint8_t, nb_rows, nb_cols > AddressMatrix
Definition: Def.hpp:26
ButtonMatrix.hpp
AH
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:50
AH::ButtonMatrix
A class that reads the states of a button matrix.
Definition: ButtonMatrix.hpp:23
AH::ButtonMatrix::update
void update()
Scan the matrix, read all button states, and call the onButtonChanged callback.
Definition: ButtonMatrix.ipp:17
MIDIButtonMatrix::baseChannelCN
const MIDICNChannel baseChannelCN
Definition: Abstract/MIDIButtonMatrix.hpp:47