Control Surface  1.2.0
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 
15 using AH::FilteredAnalog;
17 using AH::Timer;
18 using AH::Updatable;
19 
26 class Control_Surface_ : public MIDI_Sender<Control_Surface_>,
27  public TrueMIDI_SinkSource {
28 
29  friend class MIDI_Sender<Control_Surface_>;
30 
33 
34  public:
39 
44  static Control_Surface_ &getInstance();
45 
46  private:
50  Control_Surface_() = default;
51 
53 
54  public:
58  void begin();
59 
63  void loop();
64 
69 
75 
82  [[deprecated("Use Control_Surface.send(...) directly, instead of "
83  "Control_Surface.MIDI().send(...)")]] //
85  MIDI() {
86  return *this;
87  }
91  void updateMidiInput();
92 
96  void updateInputs();
97 
101  void updateDisplays();
102 
103  private:
107  void sendImpl(uint8_t header, uint8_t d1, uint8_t d2, uint8_t cn);
111  void sendImpl(uint8_t header, uint8_t d1, uint8_t cn);
112 
116  void sendImpl(const uint8_t *data, size_t length, uint8_t cn);
117 
121  void sendImpl(uint8_t rt, uint8_t cn);
122 
123  private:
124  void sinkMIDIfromPipe(ChannelMessage msg) override;
125  void sinkMIDIfromPipe(SysExMessage msg) override;
126  void sinkMIDIfromPipe(RealTimeMessage msg) override;
127 
128  private:
133 
134  public:
137 
150 
152  void
156  this->channelMessageCallback = channelMessageCallback;
157  this->sysExMessageCallback = sysExMessageCallback;
158  this->realTimeMessageCallback = realTimeMessageCallback;
159  }
160 
162 
163  private:
168 };
169 
172 
Control_Surface
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
Definition: Control_Surface_Class.cpp:203
Control_Surface_::operator=
Control_Surface_ & operator=(Control_Surface_ const &)=delete
Copying is not allowed.
MIDI_Pipe
Class that routes MIDI messages from a MIDI_Source to a MIDI_Sink.
Definition: MIDI_Pipes.hpp:270
AH::Updatable
A super class for object that have to be updated regularly.
Definition: Updatable.hpp:195
Control_Surface_::MIDI
MIDI_Sender< Control_Surface_ > & MIDI()
Get a reference to the MIDI sender.
Definition: Control_Surface_Class.hpp:85
Control_Surface_::updateDisplays
void updateDisplays()
Clear, draw and display all displays.
Definition: Control_Surface_Class.cpp:185
MillisMicrosTimer.hpp
SysExMessage
Definition: MIDI_MessageTypes.hpp:138
Control_Surface_::RealTimeMessageCallback
bool(*)(RealTimeMessage) RealTimeMessageCallback
Callback function type for Real-Time messages.
Definition: Control_Surface_Class.hpp:149
Updatable.hpp
AH::Timer
A class for easily managing timed events.
Definition: MillisMicrosTimer.hpp:28
AH::NormalUpdatable
Definition: Updatable.hpp:184
Control_Surface_::inpipe
MIDI_Pipe inpipe
Definition: Control_Surface_Class.hpp:167
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
AH::FilteredAnalog
A class that reads and filters an analog input.
Definition: FilteredAnalog.hpp:249
Control_Surface_::sysExMessageCallback
SysExMessageCallback sysExMessageCallback
Definition: Control_Surface_Class.hpp:165
Control_Surface_::outpipe
MIDI_Pipe outpipe
Definition: Control_Surface_Class.hpp:167
Control_Surface_::potentiometerTimer
Timer< micros > potentiometerTimer
A timer to know when to update the analog inputs.
Definition: Control_Surface_Class.hpp:130
Control_Surface_::disconnectMIDI_Interfaces
void disconnectMIDI_Interfaces()
Disconnect Control Surface from the MIDI interfaces it's connected to.
Definition: Control_Surface_Class.cpp:63
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
DisplayInterface.hpp
MAX_FPS
constexpr uint8_t MAX_FPS
The maximum frame rate of the displays.
Definition: Settings/Settings.hpp:60
Control_Surface_::updateMidiInput
void updateMidiInput()
Update all MIDI interfaces to receive new MIDI events.
Definition: Control_Surface_Class.cpp:80
TrueMIDI_SinkSource
A struct that is both a TrueMIDI_Sink and a TrueMIDI_Source.
Definition: MIDI_Pipes.hpp:501
Control_Surface_::loop
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Definition: Control_Surface_Class.cpp:68
DisplayElement.hpp
Control_Surface_::getInstance
static Control_Surface_ & getInstance()
Return the static Control_Surface_ instance.
Definition: Control_Surface_Class.cpp:20
Control_Surface_::ChannelMessageCallback
bool(*)(ChannelMessage) ChannelMessageCallback
Callback function type for channel messages.
Definition: Control_Surface_Class.hpp:141
Control_Surface_::sendImpl
void sendImpl(uint8_t header, uint8_t d1, uint8_t d2, uint8_t cn)
Low-level function for sending a 3-byte MIDI message.
Definition: Control_Surface_Class.cpp:84
RealTimeMessage
Definition: MIDI_MessageTypes.hpp:173
Control_Surface_::displayTimer
Timer< micros > displayTimer
A timer to know when to refresh the displays.
Definition: Control_Surface_Class.hpp:132
Control_Surface_::setMIDIInputCallbacks
void setMIDIInputCallbacks(ChannelMessageCallback channelMessageCallback, SysExMessageCallback sysExMessageCallback, RealTimeMessageCallback realTimeMessageCallback)
Set the MIDI input callbacks.
Definition: Control_Surface_Class.hpp:153
Control_Surface_::connectDefaultMIDI_Interface
bool connectDefaultMIDI_Interface()
Connect Control Surface to the default MIDI interface.
Definition: Control_Surface_Class.cpp:50
Control_Surface_::sinkMIDIfromPipe
void sinkMIDIfromPipe(ChannelMessage msg) override
Accept an incoming MIDI Channel message.
Definition: Control_Surface_Class.cpp:99
MIDI_Sender
Statically polymorphic template for classes that send MIDI messages.
Definition: MIDI_Interface.hpp:19
Control_Surface_::Control_Surface_
Control_Surface_(Control_Surface_ const &)=delete
Copying is not allowed.
ChannelMessage
Definition: MIDI_MessageTypes.hpp:72
Control_Surface_::updateInputs
void updateInputs()
Update all MIDIInputElements.
Definition: Control_Surface_Class.cpp:177
Control_Surface_::realTimeMessageCallback
RealTimeMessageCallback realTimeMessageCallback
Definition: Control_Surface_Class.hpp:166
MIDI_Interface.hpp
Control_Surface_::SysExMessageCallback
bool(*)(SysExMessage) SysExMessageCallback
Callback function type for SysEx messages.
Definition: Control_Surface_Class.hpp:145
FilteredAnalog.hpp
Control_Surface_
This class ensures initialization, updating, and interaction between all other classes,...
Definition: Control_Surface_Class.hpp:27
Control_Surface_::Control_Surface_
Control_Surface_()=default
Control_Surface_ is a singleton, so the constructor is private.
AH::FILTERED_INPUT_UPDATE_INTERVAL
constexpr unsigned long FILTERED_INPUT_UPDATE_INTERVAL
The interval between updating filtered analog inputs, in microseconds.
Definition: AH/Settings/Settings.hpp:83
Control_Surface_::channelMessageCallback
ChannelMessageCallback channelMessageCallback
Definition: Control_Surface_Class.hpp:164
Control_Surface_::begin
void begin()
Initialize the Control_Surface.
Definition: Control_Surface_Class.cpp:25