Code
#include // Include the Encoder library.
#include
#include // std::any_of
USBMIDI_Interface midi; // MIDI Interface to use
Bank<4> bank(20);
IncrementDecrementSelectorLEDs<4> bankSelector = {
bank,
{33, 35}, // button pins
{39, 41, 43, 45}, // LED pins
};
CCRotaryEncoder enc = {{A12, A13}, {MCU::V_POT_1, CHANNEL_1}};
using namespace MIDI_CC;
Bankable::CCPotentiometer potentiometers[] = {
{bank, A0, {0x46, CHANNEL_2}},
{bank, A1, {0x47, CHANNEL_2}},
{bank, A2, {0x48, CHANNEL_2}},
{bank, A3, {0x49, CHANNEL_2}},
{bank, A4, {0x4A, CHANNEL_2}},
{bank, A5, {0x4B, CHANNEL_2}},
{bank, A6, {0x4C, CHANNEL_2}},
{bank, A7, {0x4D, CHANNEL_2}},
{bank, A8, {0x4E, CHANNEL_2}},
{bank, A9, {0x4F, CHANNEL_2}},
{bank, A10, {0x50, CHANNEL_2}},
{bank, A11, {0x51, CHANNEL_2}},
};
Bankable::NoteButton muteButtons[] = {
{bank, 13, 0x14},
{bank, 12, 0x15},
{bank, 11, 0x16},
{bank, 10, 0x17},
{bank, 9, 0x18},
{bank, 8, 0x19},
{bank, 7, 0x1A},
{bank, 6, 0x1B},
{bank, 5, 0x1C},
{bank, 4, 0x1D},
{bank, 3, 0x1E},
{bank, 2, 0x1F},
{bank, 23, 0x20},
{bank, 25, 0x21},
{bank, 27, 0x22},
{bank, 29, 0x23},
{bank, 31, 0x24},
{bank, 14, 0x25},
{bank, 23, 0x2C},
{bank, 25, 0x2D},
{bank, 27, 0x2E},
{bank, 29, 0x2F},
{bank, 31, 0x30},
};
constexpr pin_t ledPin = 47;
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //
void setup() {
Control_Surface.begin();
pinMode(ledPin, OUTPUT);
}
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //
void loop() {
Control_Surface.loop();
// Function that checks if a given button is pressed
auto checkButtonPressed = [](const Bankable::NoteButton &button) {
return button.getButtonState() == Button::Pressed;
};
// If any of the push buttons is pressed
bool pressed = std::any_of(std::begin(muteButtons), std::end(muteButtons),
checkButtonPressed);
// Turn on the LED
digitalWrite(ledPin, pressed);
}