Hello there. I have built a Midi Foot Controller and would like to use banks with the Control Surface library, which is really great. Here is my current code with 4 CC Buttons and 4 PC Buttons, each with LED. Two LCD screens are also there to show static text (effects or presets).
//LCD
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
//hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
hd44780_I2Cexp lcd1(0x26);
hd44780_I2Cexp lcd2(0x27);
const int LCD_COLS = 16;
const int LCD_ROWS = 4;
//Control Surface Buttons
#include <Control_Surface.h> // Include the Control Surface library
// Instantiate a MIDI over USB interface
USBMIDI_Interface midi;
// Instantiate a program changer with 8 programs
ProgramChanger<4> programChanger = {
{
MIDI_PC::program_1, // list of programs
MIDI_PC::program_2,
MIDI_PC::program_3,
MIDI_PC::program_4,
},
CHANNEL_1, // MIDI channel to use
};
// Instantiate a selector that reads eight buttons and controls the program
// changer. {Button PINs} {LED PINs}
ManyButtonsSelectorLEDs<4> programSelector = {
programChanger,
{{0, 1, 2, 3}},
{{11, 12, 13, 14}},
};
// Instantiate an array of CCButton objects that send MIDI control
// change messages whenever the button is pressed/released
CCButton buttons[] {
{4, 89},
{8, 90},
{9, 91},
{10, 92},
};
// Create an array of CCValueLED objects that turn on/off an LED
// depending on the MIDI control change messages they receive
CCValueLED leds[] {
{15, 89},
{16, 90},
{17, 91},
{18, 92},
};
// Ignore the name “increment” button, it's simply a button
// class that can detect long and short presses.
IncrementButton btn { 0 }; // pin number of button
void setup() {
Control_Surface.begin(); // Initialize Control Surface
int status;
// initialize LCD with number of columns and rows:
status = lcd1.begin(LCD_COLS, LCD_ROWS);
status = lcd2.begin(LCD_COLS, LCD_ROWS);
// Print a message to the LCD
lcd1.print("DELAY OD(Tuner) Preset1 Preset2");
lcd2.print("CHORUS PHASER Preset3 Preset4");
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
//Longpress Button CC
switch (btn.update()) {
case IncrementButton::IncrementLong: // If button is still pressed after some time
Control_Surface.sendCC(93, 127); break;
}
}
Next thing I wanted to implement are banks (for example 4). I tried a lot with the current examples of the library, but did not get it how to integrate it.
The banks should be use increment decrement with the pins 3 and 10. They are already in use, so I would like to change banks by holding a button long (2 sec.).
And the LCD screen should show another text when switching to bank 2, 3 and 4.
Maybe someone can help. The builder of the library helped me a lot in the past and I was very thankful. Have a good day.