This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
DebugMIDI_Interface.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <ctype.h>
5 
7 
15  public:
23 
24  MIDI_read_t read() override;
25 
26  protected:
27  void sendImpl(uint8_t m, uint8_t c, uint8_t d1, uint8_t d2,
28  uint8_t cn) override;
29 
30  void sendImpl(uint8_t m, uint8_t c, uint8_t d1, uint8_t cn) override;
31 
32  void sendImpl(const uint8_t *data, size_t length, uint8_t cn) override;
33 
34  void sendImpl(uint8_t rt, uint8_t cn) override;
35 
36  private:
37  char firstChar = '\0';
38  char secondChar = '\0';
39 
43  static uint8_t hexCharToNibble(char hex) {
44  return hex < 'a' ? hex - '0' : hex - 'a' + 10;
45  }
46 };
47 
58 template <typename T>
60  public:
75  void begin() override { serial.begin(baud); }
76 
77  private:
78  T &serial;
79  const unsigned long baud;
80 };
81 
89  : public SerialDebugMIDI_Interface<HardwareSerial> {
90  public:
101  unsigned long baud = defaultBaudRate)
103 };
104 
115  : public SerialDebugMIDI_Interface<decltype(Serial)> {
116  public:
124  : SerialDebugMIDI_Interface(Serial, baud) {}
125 };
126 
127 // TODO: Teensy 4.0 SoftwareSerial bug
128 #if defined(__AVR__) || (defined(TEENSYDUINO) && TEENSYDUINO != 147) || \
129  (defined(TEENSYDUINO) && !defined(__IMXRT1052__) && \
130  !defined(__IMXRT1062__))
131 #include <SoftwareSerial.h>
139  : public SerialDebugMIDI_Interface<SoftwareSerial> {
140  public:
151  unsigned long baud)
153 };
154 #endif
155 
StreamDebugMIDI_Interface::hexCharToNibble
static uint8_t hexCharToNibble(char hex)
Convert a hexadecimal character to a 4-bit nibble.
Definition: DebugMIDI_Interface.hpp:43
SerialDebugMIDI_Interface
A wrapper class for debug MIDI interfaces sending and receiving human-readable MIDI messages over a S...
Definition: DebugMIDI_Interface.hpp:59
HardwareSerialDebugMIDI_Interface
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over a HardwareS...
Definition: DebugMIDI_Interface.hpp:88
SerialMIDI_Interface.hpp
MIDI_read_t
MIDI_read_t
Definition: MIDI_Parser.hpp:29
StreamDebugMIDI_Interface::StreamDebugMIDI_Interface
StreamDebugMIDI_Interface(Stream &stream)
Construct a debug MIDI interface on the given Stream.
Definition: DebugMIDI_Interface.hpp:22
StreamDebugMIDI_Interface::sendImpl
void sendImpl(uint8_t m, uint8_t c, uint8_t d1, uint8_t d2, uint8_t cn) override
Low-level function for sending a 3-byte MIDI message.
Definition: DebugMIDI_Interface.cpp:77
SerialDebugMIDI_Interface::serial
T & serial
Definition: DebugMIDI_Interface.hpp:78
StreamDebugMIDI_Interface::read
MIDI_read_t read() override
Definition: DebugMIDI_Interface.cpp:40
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
SerialDebugMIDI_Interface::begin
void begin() override
Start the Serial interface at the predefined baud rate.
Definition: DebugMIDI_Interface.hpp:75
defaultBaudRate
constexpr unsigned long defaultBaudRate
The default baud rate for debug MIDI interfaces.
Definition: Settings.hpp:34
StreamDebugMIDI_Interface::secondChar
char secondChar
Definition: DebugMIDI_Interface.hpp:38
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
StreamDebugMIDI_Interface
A class for MIDI interfaces sending and receiving human-readable MIDI messages over a Stream.
Definition: DebugMIDI_Interface.hpp:14
SoftwareSerialDebugMIDI_Interface
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over a SoftwareS...
Definition: DebugMIDI_Interface.hpp:138
USBDebugMIDI_Interface::USBDebugMIDI_Interface
USBDebugMIDI_Interface(unsigned long baud=defaultBaudRate)
Construct a USBDebugMIDI_Interface with the given baud rate.
Definition: DebugMIDI_Interface.hpp:123
hex
Print & hex(Print &printer)
Definition: PrintStream.cpp:62
SerialDebugMIDI_Interface::SerialDebugMIDI_Interface
SerialDebugMIDI_Interface(T &serial, unsigned long baud=defaultBaudRate)
Construct a new Debug MIDI Interface on the given Serial interface with the given baud rate.
Definition: DebugMIDI_Interface.hpp:70
SoftwareSerialDebugMIDI_Interface::SoftwareSerialDebugMIDI_Interface
SoftwareSerialDebugMIDI_Interface(SoftwareSerial &serial, unsigned long baud)
Construct a SoftwareSerialDebugMIDI_Interface on the given SoftwareSerial interface with the given ba...
Definition: DebugMIDI_Interface.hpp:150
StreamDebugMIDI_Interface::firstChar
char firstChar
Definition: DebugMIDI_Interface.hpp:37
StreamMIDI_Interface
A class for MIDI interfaces sending and receiving MIDI messages over a Stream.
Definition: SerialMIDI_Interface.hpp:17
StreamMIDI_Interface::stream
Stream & stream
Definition: SerialMIDI_Interface.hpp:70
USBDebugMIDI_Interface
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over the USB CDC...
Definition: DebugMIDI_Interface.hpp:114
SerialDebugMIDI_Interface::baud
const unsigned long baud
Definition: DebugMIDI_Interface.hpp:79
HardwareSerialDebugMIDI_Interface::HardwareSerialDebugMIDI_Interface
HardwareSerialDebugMIDI_Interface(HardwareSerial &serial, unsigned long baud=defaultBaudRate)
Construct a new Debug MIDI Interface on the given HardwareSerial interface with the given baud rate.
Definition: DebugMIDI_Interface.hpp:100