Switch between Banks with a ON/OFF Switch #1050
Replies: 1 comment
-
I figured it out! 🎉By using a SwitchSelector instead of a IncrementDecrementSelector it can be used as a Switch. 👍 I discovered it by looking into the MIDI-Controller-Finished-Example For those who wonder what type of selectors are available. Here my finished Code:#include <Control_Surface.h> // Include the Control Surface library
// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;
// Define MIDI control change numbers for custom CC commands
constexpr uint8_t CC_SWITCH_2 = 21;
constexpr uint8_t CC_BUTTON_1 = 24;
constexpr uint8_t CC_BUTTON_2 = 25;
constexpr uint8_t CC_BUTTON_3 = 26;
constexpr uint8_t CC_BUTTON_4 = 27;
Bank<2> bank(5);
// Switching between Bank 1 and 2
SwitchSelector selector {
bank, // Bank to manage
35 // Switch PIN
};
// // Instantiate CCButton objects for the On/Off switches
PCButton ononSwitch1 {36, {MIDI_PC::Acoustic_Grand_Piano, CHANNEL_1}};
PCButton ononSwitch2 {37, {MIDI_PC::Bright_Acoustic_Piano, CHANNEL_1}};
Bankable::CCButton switch4 {{bank, BankType::ChangeChannel}, 38, {CC_SWITCH_2, CHANNEL_1}, };
// // Instantiate CCButton objects for the buttons
Bankable::CCButton button1 {{bank, BankType::ChangeChannel}, 15, {CC_BUTTON_1, CHANNEL_1}};
Bankable::CCButton button2 {{bank, BankType::ChangeChannel}, 16, {CC_BUTTON_2, CHANNEL_1}};
Bankable::CCButton button3 {{bank, BankType::ChangeChannel}, 17, {CC_BUTTON_3, CHANNEL_1}};
Bankable::CCButton button4 {{bank, BankType::ChangeChannel}, 18, {CC_BUTTON_4, CHANNEL_1}};
void setup() {
Control_Surface.begin(); // Initialize Control Surface
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone! ✌
I want to switch between 2 Banks in my Midi Controller with a On/Off Switch.
Currently, my code makes the pin 35 switch between 2 Banks but I have to switch it on and off to switch to one Bank. 🥺
Is there something like a Latch Mode for Banks so as long the Switch is set to ON it stays on Bank 2 and when the Switch is turned OFF its sets to Bank 1?
My current Code:
I also saw the Bankable CCButtons with Latched Increment Selector Switch Question in the Q&A but I didn't understand quite how it works, because I am not so familiar with C / ino Coding. 😅
Is there no way in Control Surface to indicate if the switch is down?
Thanks in advance for any help 😊
Beta Was this translation helpful? Give feedback.
All reactions