Control Surface  1.1.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 
20 /**
21  * @brief This class ensures initialization, updating, and interaction between
22  * all other classes, it's the glue that holds everything together.
23  *
24  * @ingroup ControlSurfaceModule
25  */
27  public:
28  // Copying is not allowed
29  Control_Surface_(Control_Surface_ const &) = delete;
30  void operator=(Control_Surface_ const &) = delete;
31 
32  /**
33  * @brief Return the static Control_Surface_ instance.
34  * (Control_Surface_ is a singleton.)
35  */
36  static Control_Surface_ &getInstance();
37 
38  /**
39  * @brief Initialize the Control_Surface.
40  */
41  void begin();
42 
43  /**
44  * @brief Update all MIDI elements, send MIDI events and read MIDI input.
45  */
46  void loop();
47 
48  /**
49  * @brief Get the MIDI interface of the Control Surface.
50  *
51  * @return A reference to the Control Surface's MIDI interface.
52  *
53  * @todo This violate's the Law of Demeter.
54  */
56 
57  /**
58  * @brief Update all MIDI interfaces to receive new MIDI events.
59  */
60  void updateMidiInput();
61 
62  /**
63  * @brief Update all MIDIInputElement%s.
64  */
65  void updateInputs();
66 
67  /**
68  * @brief Clear, draw and display all displays.
69  */
70  void updateDisplays();
71 
72  private:
73  /**
74  * @brief Control_Surface_ is a singleton, so the constructor is private.
75  */
76  Control_Surface_() = default;
77 
78  /**
79  * @brief The callback to be called when a MIDI channel message is
80  * received.
81  */
82  void onChannelMessage(Parsing_MIDI_Interface &midi) override;
83 
84  /**
85  * @brief The callback to be called when a MIDI System Exclusive message
86  * is received.
87  */
88  void onSysExMessage(Parsing_MIDI_Interface &midi) override;
89 
90  /**
91  * @brief The callback to be called when a MIDI Real-Time message is
92  * received.
93  */
95  uint8_t message) override;
96 
97  /// A timer to know when to update the analog inputs.
99  /// A timer to know when to refresh the displays.
101 
102  public:
103  /// Callback function type for channel messages. Return true if handling is
104  /// done in the user-provided callback, false if `Control_Surface`
105  /// should handle the message.
107  /// Callback function type for SysEx messages. Return true if handling is
108  /// done in the user-provided callback, false if `Control_Surface`
109  /// should handle the message.
111  /// Callback function type for Real-Time messages. Return true if handling
112  /// is done in the user-provided callback, false if `Control_Surface`
113  /// should handle the message.
115 
116  /// Set the MIDI input callbacks.
117  void
121  this->channelMessageCallback = channelMessageCallback;
122  this->sysExMessageCallback = sysExMessageCallback;
123  this->realTimeMessageCallback = realTimeMessageCallback;
124  }
125 
126  private:
130 };
131 
132 /// A predefined instance of the Control Surface to use in the Arduino sketches.
134 
Control_Surface
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
Definition: Control_Surface_Class.cpp:174
AH::Updatable
A super class for object that have to be updated regularly.
Definition: Updatable.hpp:25
AH::NormalUpdatable
Definition: Updatable.hpp:16
MillisMicrosTimer.hpp
SysExMessage
Definition: MIDI_Parser.hpp:64
Control_Surface_::onSysExMessage
void onSysExMessage(Parsing_MIDI_Interface &midi) override
The callback to be called when a MIDI System Exclusive message is received.
Definition: Control_Surface_Class.cpp:121
Updatable.hpp
Parsing_MIDI_Interface
An abstract class for MIDI interfaces.
Definition: MIDI_Interface.hpp:188
Control_Surface_::updateInputs
void updateInputs()
Update all MIDIInputElements.
Definition: Control_Surface_Class.cpp:150
AH::Timer
A class for easily managing timed events.
Definition: MillisMicrosTimer.hpp:28
Control_Surface_::onChannelMessage
void onChannelMessage(Parsing_MIDI_Interface &midi) override
The callback to be called when a MIDI channel message is received.
Definition: Control_Surface_Class.cpp:71
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:54
Control_Surface_::MIDI
MIDI_Interface & MIDI()
Get the MIDI interface of the Control Surface.
Definition: Control_Surface_Class.cpp:58
Control_Surface_::Control_Surface_
Control_Surface_()=default
Control_Surface_ is a singleton, so the constructor is private.
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:59
Control_Surface_::displayTimer
Timer< micros > displayTimer
A timer to know when to refresh the displays.
Definition: Control_Surface_Class.hpp:100
Control_Surface_::updateMidiInput
void updateMidiInput()
Update all MIDI interfaces to receive new MIDI events.
Definition: Control_Surface_Class.cpp:66
Control_Surface_::onRealtimeMessage
void onRealtimeMessage(Parsing_MIDI_Interface &midi, uint8_t message) override
The callback to be called when a MIDI Real-Time message is received.
Definition: Control_Surface_Class.cpp:140
DisplayElement.hpp
Control_Surface_::operator=
void operator=(Control_Surface_ const &)=delete
Control_Surface_::RealTimeMessageCallback
bool(*)(RealTimeMessage) RealTimeMessageCallback
Callback function type for Real-Time messages.
Definition: Control_Surface_Class.hpp:114
Control_Surface_::channelMessageCallback
ChannelMessageCallback channelMessageCallback
Definition: Control_Surface_Class.hpp:127
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
RealTimeMessage
Definition: MIDI_Parser.hpp:77
Control_Surface_::setMIDIInputCallbacks
void setMIDIInputCallbacks(ChannelMessageCallback channelMessageCallback, SysExMessageCallback sysExMessageCallback, RealTimeMessageCallback realTimeMessageCallback)
Set the MIDI input callbacks.
Definition: Control_Surface_Class.hpp:118
Control_Surface_::potentiometerTimer
Timer< micros > potentiometerTimer
A timer to know when to update the analog inputs.
Definition: Control_Surface_Class.hpp:98
Control_Surface_::sysExMessageCallback
SysExMessageCallback sysExMessageCallback
Definition: Control_Surface_Class.hpp:128
Control_Surface_::realTimeMessageCallback
RealTimeMessageCallback realTimeMessageCallback
Definition: Control_Surface_Class.hpp:129
Control_Surface_::begin
void begin()
Initialize the Control_Surface.
Definition: Control_Surface_Class.cpp:25
Control_Surface_::updateDisplays
void updateDisplays()
Clear, draw and display all displays.
Definition: Control_Surface_Class.cpp:158
Control_Surface_::ChannelMessageCallback
bool(*)(ChannelMessage) ChannelMessageCallback
Callback function type for channel messages.
Definition: Control_Surface_Class.hpp:106
ChannelMessage
Definition: MIDI_Parser.hpp:47
Control_Surface_::SysExMessageCallback
bool(*)(SysExMessage) SysExMessageCallback
Callback function type for SysEx messages.
Definition: Control_Surface_Class.hpp:110
MIDI_Callbacks
A class for callbacks from MIDI input.
Definition: MIDI_Interface.hpp:247
MIDI_Interface
An abstract class for MIDI interfaces.
Definition: MIDI_Interface.hpp:16
MIDI_Interface.hpp
FilteredAnalog.hpp
Control_Surface_
This class ensures initialization, updating, and interaction between all other classes,...
Definition: Control_Surface_Class.hpp:26
Control_Surface_::loop
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Definition: Control_Surface_Class.cpp:48
Control_Surface_::getInstance
static Control_Surface_ & getInstance()
Return the static Control_Surface_ instance.
Definition: Control_Surface_Class.cpp:20