Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Control_Surface_Class.hpp
Go to the documentation of this file.
1/* ✔ */
2
3#pragma once
4
12
14
17using AH::Timer;
18using AH::Updatable;
19
26class Control_Surface_ : public MIDI_Sender<Control_Surface_>,
27 public TrueMIDI_SinkSource {
28
29 friend class MIDI_Sender<Control_Surface_>;
30
33
34 public:
39
43
44 private:
46 Control_Surface_() = default;
47
49
50 public:
53 void begin();
54
57 void loop();
58
61
64
66 void updateMidiInput();
68 void updateInputs();
70 void beginDisplays();
73 void updateDisplays();
74
75 private:
86 void sendNowImpl() { /* TODO */
87 }
88
89 private:
90#if !DISABLE_PIPES
91 void sinkMIDIfromPipe(ChannelMessage msg) override;
92 void sinkMIDIfromPipe(SysExMessage msg) override;
93 void sinkMIDIfromPipe(SysCommonMessage msg) override;
94 void sinkMIDIfromPipe(RealTimeMessage msg) override;
95#else
100#endif
101
102 private:
105
106 public:
109
126
128 void
138
140
141 private:
146#if !DISABLE_PIPES
148#endif
149};
150
151#if CS_TRUE_CONTROL_SURFACE_INSTANCE || defined(DOXYGEN)
154#else
155// This is not a clean solution, but it's the only way to get the linker to
156// optimize away all Control Surface-related code if the `Control_Surface`
157// instance is never used.
158// Even if it isn't used, and even though it's a global, the compiler has to
159// generate the constructor and destructor, which pulls in variables and vtables
160// from throughout the library, using a significant amount of memory.
161// By using a macro here, Control_Surface is only constructed (and destructed)
162// if it is used in user code.
163#define Control_Surface (Control_Surface_::getInstance())
164#endif
165
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
constexpr uint8_t MAX_FPS
The maximum frame rate of the displays.
A class that reads and filters an analog input.
A class for easily managing timed events.
A super class for object that have to be updated regularly.
void updateDisplays()
Clear, draw and display all displays that contain display elements that have changed.
Timer< micros > displayTimer
A timer to know when to refresh the displays.
bool connectDefaultMIDI_Interface()
Connect Control Surface to the default MIDI interface.
void disconnectMIDI_Interfaces()
Disconnect Control Surface from the MIDI interfaces it's connected to.
void sendNowImpl()
Low-level function for sending any buffered outgoing MIDI messages.
void updateInputs()
Update all MIDIInputElements.
ChannelMessageCallback channelMessageCallback
Control_Surface_(Control_Surface_ const &)=delete
Copying is not allowed.
void setMIDIInputCallbacks(ChannelMessageCallback channelMessageCallback, SysExMessageCallback sysExMessageCallback, SysCommonMessageCallback sysCommonMessageCallback, RealTimeMessageCallback realTimeMessageCallback)
Set the MIDI input callbacks.
Control_Surface_()=default
Control_Surface_ is a singleton, so the constructor is private.
bool(*)(SysExMessage) SysExMessageCallback
Callback function type for SysEx messages.
bool(*)(ChannelMessage) ChannelMessageCallback
Callback function type for channel messages.
bool(*)(RealTimeMessage) RealTimeMessageCallback
Callback function type for Real-Time messages.
static Control_Surface_ & getInstance()
Return the static Control_Surface_ instance (Control_Surface_ is a singleton.).
void updateMidiInput()
Update all MIDI interfaces to receive new MIDI events.
Control_Surface_ & operator=(Control_Surface_ const &)=delete
Copying is not allowed.
void sendSysExImpl(SysExMessage)
Low-level function for sending a system exclusive MIDI message.
bool(*)(SysCommonMessage) SysCommonMessageCallback
Callback function type for System Common messages.
void sinkMIDIfromPipe(ChannelMessage msg) override
Accept an incoming MIDI Channel message.
SysCommonMessageCallback sysCommonMessageCallback
void begin()
Initialize the Control_Surface.
RealTimeMessageCallback realTimeMessageCallback
void beginDisplays()
Initialize all displays that have at least one display element.
SysExMessageCallback sysExMessageCallback
void sendSysCommonImpl(SysCommonMessage)
Low-level function for sending a MIDI system common message.
void sendChannelMessageImpl(ChannelMessage)
Low-level function for sending a MIDI channel voice message.
void sendRealTimeImpl(RealTimeMessage)
Low-level function for sending a MIDI real-time message.
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Statically polymorphic template for classes that send MIDI messages.
friend class MIDI_Pipe
A struct that is both a TrueMIDI_Sink and a TrueMIDI_Source.