Control Surface pin-t-adl
MIDI Control Surface library for Arduino
Control_Surface_Class.hpp
Go to the documentation of this file.
1/* ✔ */
2
3#pragma once
4
11#include <Settings/SettingsWrapper.hpp>
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:
52 void begin();
53
55 void loop();
56
59
62
64 void updateMidiInput();
66 void updateInputs();
68 void beginDisplays();
71 void updateDisplays();
72
73 private:
84 void sendNowImpl() { /* TODO */ }
85
86 private:
87 void sinkMIDIfromPipe(ChannelMessage msg) override;
88 void sinkMIDIfromPipe(SysExMessage msg) override;
89 void sinkMIDIfromPipe(SysCommonMessage msg) override;
90 void sinkMIDIfromPipe(RealTimeMessage msg) override;
91
92 private:
95
96 public:
99
116
118 void
123 this->channelMessageCallback = channelMessageCallback;
124 this->sysExMessageCallback = sysExMessageCallback;
125 this->sysCommonMessageCallback = sysCommonMessageCallback;
126 this->realTimeMessageCallback = realTimeMessageCallback;
127 }
128
130
131 private:
137};
138
139#if CS_TRUE_CONTROL_SURFACE_INSTANCE || defined(DOXYGEN)
142#else
143// This is not a clean solution, but it's the only way to get the linker to
144// optimize away all Control Surface-related code if the `Control_Surface`
145// instance is never used.
146// Even if it isn't used, and even though it's a global, the compiler has to
147// generate the constructor and destructor, which pulls in variables and vtables
148// from throughout the library, using a significant amount of memory.
149// By using a macro here, Control_Surface is only constructed (and destructed)
150// if it is used in user code.
151#define Control_Surface (Control_Surface_::getInstance())
152#endif
153
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.
Definition: Updatable.hpp:173
This class ensures initialization, updating, and interaction between all other classes,...
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.
Class that routes MIDI messages from a MIDI_Source to a MIDI_Sink.
Definition: MIDI_Pipes.hpp:326
Statically polymorphic template for classes that send MIDI messages.
Definition: MIDI_Sender.hpp:11
A struct that is both a TrueMIDI_Sink and a TrueMIDI_Source.
Definition: MIDI_Pipes.hpp:586