MEGA KEYS V2
✓
#include <Control_Surface.h>
#include <AH/STL/algorithm> // std::any_of
USBMIDI_Interface midi; // MIDI Interface to use
Bank<4> bank(24);
// Create a new bank selector that changes the bank setting of the bank we just
// created.
// It has push buttons connected to pins 21 and 20 that increment or decrement
// the bank setting, and 4 LEDs to pins 46, 48, 50, 52 that display the current
// bank setting.
IncrementDecrementSelectorLEDs<4> bankSelector = {
bank,
{31, 33}, // button pins
{39, 41, 43, 45}, // LED pins
};
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}},
};
Bankable::NoteButton muteButtons[] = {
{bank, 13, 0x20},
{bank, 12, 0x21},
{bank, 11, 0x22},
{bank, 10, 0x23},
{bank, 9, 0x24},
{bank, 8, 0x25},
{bank, 7, 0x26},
{bank, 6, 0x27},
{bank, 5, 0x28},
{bank, 4, 0x29},
{bank, 3, 0x2A},
{bank, 2, 0x2B},
{bank, 14, 0x2C},
{bank, 15, 0x2D},
{bank, 16, 0x2E},
{bank, 17, 0x2F},
{bank, 18, 0x30},
{bank, 19, 0x31},
{bank, 20, 0x32},
{bank, 21, 0x33},
{bank, 23, 0x34},
{bank, 25, 0x35},
{bank, 27, 0x36},
{bank, 29, 0x37},
};
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);
}
MEGA FX V2
✓
#include <Encoder.h> // Include the Encoder library.
#include <Control_Surface.h>
#include <AH/STL/algorithm> // std::any_of
USBMIDI_Interface midi; // MIDI Interface to use
Bank<4> bank(20);
// Create a new bank selector that changes the bank setting of the bank we just
// created.
// It has push buttons connected to pins 21 and 20 that increment or decrement
// the bank setting, and 4 LEDs to pins 46, 48, 50, 52 that display the current
// bank setting.
IncrementDecrementSelectorLEDs<4> bankSelector = {
bank,
{19, 20}, // 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, 0x10},
{bank, 12, 0x11},
{bank, 11, 0x12},
{bank, 10, 0x13},
{bank, 9, 0x14},
{bank, 8, 0x15},
{bank, 7, 0x16},
{bank, 6, 0x17},
{bank, 5, 0x18},
{bank, 4, 0x19},
{bank, 3, 0x1A},
{bank, 2, 0x1B},
{bank, 14, 0x1C},
{bank, 15, 0x1D},
{bank, 16, 0x1E},
{bank, 17, 0x1F},
{bank, 18, 0x20},
{bank, 21, 0x21},
};
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);
}
MEGA SCRATCH V2
✓
#include <Control_Surface.h>
#include <AH/STL/algorithm> // std::any_of
USBMIDI_Interface midi; // MIDI Interface to use
Bank<4> bank(20);
// Create a new bank selector that changes the bank setting of the bank we just
// created.
// It has push buttons connected to pins 21 and 20 that increment or decrement
// the bank setting, and 4 LEDs to pins 46, 48, 50, 52 that display the current
// bank setting.
IncrementDecrementSelectorLEDs<4> bankSelector = {
bank,
{35, 37}, // button pins
{39, 41, 43, 45}, // LED pins
};
using namespace MIDI_CC;
Bankable::CCPotentiometer potentiometers[] = {
{bank, A4, {0x4A, CHANNEL_1}},
{bank, A5, {0x4B, CHANNEL_1}},
{bank, A6, {0x4C, CHANNEL_1}},
{bank, A7, {0x4D, CHANNEL_1}},
{bank, A8, {0x4E, CHANNEL_1}},
{bank, A9, {0x4F, CHANNEL_1}},
{bank, A10, {0x50, CHANNEL_1}},
{bank, A11, {0x51, CHANNEL_1}},
};
Bankable::NoteButton muteButtons[] = {
{bank, 13, 0x14},
{bank, 12, 0x15},
{bank, 11, 0x16},
{bank, 10, 0x17},
{bank, 9, 0x18},
{bank, 8, 0x19},
{bank, 14, 0x1A},
{bank, 15, 0x1B},
{bank, 16, 0x1C},
{bank, 17, 0x1D},
{bank, 18, 0x1E},
{bank, 19, 0x1F},
{bank, 20, 0x20},
{bank, 21, 0x21},
{bank, 23, 0x22},
{bank, 25, 0x23},
{bank, 27, 0x24},
{bank, 29, 0x25},
{bank, 31, 0x26},
{bank, 33, 0x27},
};
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);
}
MEGA CONTROL V2
✓
Content 1