1.1 KiB
1.1 KiB
Finished Controller
Comprehensive example combining buttons, encoder, potentiometer, and bank switching with bankable input elements.
Original:
MIDI-Controller-Finished-Example.ino(adapted)
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include <cs_midi.h>
using namespace cs;
BluetoothMIDI_Interface midi;
// 4 banks, 2 tracks per bank
Bank<4> bank(2);
// Two buttons to cycle banks
IncrementDecrementSelector<4> bankSelector {bank, {2, 3}, Wrap::Wrap};
// Bankable CC value readers — bank switches the CC address
Bankable::CCValue<4> volume1 {{bank, BankType::ChangeAddress}, {16, Channel_1}};
Bankable::CCValue<4> volume2 {{bank, BankType::ChangeAddress}, {17, Channel_1}};
// Non-bankable output elements
NoteButton button {5, {MIDI_Notes::C[4], Channel_1}};
CCPotentiometer pot {26, {MIDI_CC::Channel_Volume, Channel_1}};
CCRotaryEncoder enc {{0, 1}, {MIDI_CC::Pan, Channel_1}, 1, 4};
int main() {
stdio_init_all();
if (cyw43_arch_init()) return 1;
Control_Surface.begin();
while (true) {
Control_Surface.loop();
sleep_ms(1);
}
}