Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Purpose of the Control_Surface singleton

When writing code for a MIDI Control Surface, you'll likely come across the Control_Surface singleton. The program structure usually looks something like this:

// Instantiate MIDI interfaces, ExtIO elements, MIDI elements, etc.
void setup() {
}
void loop() {
}
The main header file that includes all Control-Surface header files.
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
void begin()
Initialize the Control_Surface.
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.

The Control_Surface singleton is responsible for the following important tasks:

Control Surface keeps track of elements that inherit from the AH::UpdatableCRTP base class. Specifically, it keeps a list of all AH::ExtendedIOElements, MIDI_Interfaces, MIDI Output Elements, MIDI Input Elements and Display Elements. If you have certain elements that should not be initialized or updated by Control Surface, you can call AH::UpdatableCRTP::disable() before calling Control_Surface.begin(). It is then your responsibility to call the AH::Updatable::begin() and AH::Updatable::update() functions whenever appropriate. You can also enable these disabled elements again using AH::UpdatableCRTP::enable().