Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Bankable/Abstract/MIDIButtonMatrix.hpp
Go to the documentation of this file.
1#pragma once
2
6#include <Def/Def.hpp>
8
10
11namespace Bankable {
12
28template <class BankAddress, class Sender, uint8_t NumRows, uint8_t NumCols>
30 : public MIDIOutputElement,
31 public AH::ButtonMatrix<
32 MIDIButtonMatrix<BankAddress, Sender, NumRows, NumCols>, NumRows,
33 NumCols> {
36
37 protected:
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
71 sender.sendOn(address.getActiveAddress(row, col));
72 } else {
73 sender.sendOff(address.getActiveAddress(row, col));
75 if (!activeButtons)
76 address.unlock();
77 }
78 }
79
80 protected:
83
84 public:
85 Sender sender;
86};
87
88} // namespace Bankable
89
constexpr PinStatus_t LOW
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A class that reads the states of a button matrix.
void begin()
Initialize (enable internal pull-up resistors on column pins).
void update()
Scan the matrix, read all button states, and call the onButtonChanged callback.
A super class for object that have to be updated regularly.
void onButtonChanged(uint8_t row, uint8_t col, bool state)
MIDIButtonMatrix(BankAddress bankAddress, const PinList< NumRows > &rowPins, const PinList< NumCols > &colPins, const Sender &sender)
Create a new Bankable MIDIButtonMatrix.
void update() override
Update this updatable.
void begin() override
Initialize this updatable.
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
An array wrapper for easy copying, comparing, and iterating.
Definition Array.hpp:32