Control Surface  1.1.1
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:
71  unsigned long baud = AH::defaultBaudRate)
76  void begin() override { serial.begin(baud); }
77 
78  private:
79  T &serial;
80  const unsigned long baud;
81 };
82 
90  : public SerialDebugMIDI_Interface<HardwareSerial> {
91  public:
102  unsigned long baud = AH::defaultBaudRate)
104 };
105 
116  : public SerialDebugMIDI_Interface<decltype(Serial)> {
117  public:
125  : SerialDebugMIDI_Interface(Serial, baud) {}
126 };
127 
128 // TODO: Teensy 4.0 SoftwareSerial bug
129 #if defined(__AVR__) || (defined(TEENSYDUINO) && TEENSYDUINO != 147) || \
130  (defined(TEENSYDUINO) && !defined(__IMXRT1052__) && \
131  !defined(__IMXRT1062__))
132 #include <SoftwareSerial.h>
140  : public SerialDebugMIDI_Interface<SoftwareSerial> {
141  public:
152  unsigned long baud)
154 };
155 #endif
156 
StreamMIDI_Interface::stream
Stream & stream
Definition: SerialMIDI_Interface.hpp:70
SerialDebugMIDI_Interface::serial
T & serial
Definition: DebugMIDI_Interface.hpp:79
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:89
SerialMIDI_Interface.hpp
MIDI_read_t
MIDI_read_t
Definition: MIDI_Parser.hpp:29
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
StreamDebugMIDI_Interface::hexCharToNibble
static uint8_t hexCharToNibble(char hex)
Convert a hexadecimal character to a 4-bit nibble.
Definition: DebugMIDI_Interface.hpp:43
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
SerialDebugMIDI_Interface::SerialDebugMIDI_Interface
SerialDebugMIDI_Interface(T &serial, unsigned long baud=AH::defaultBaudRate)
Construct a new Debug MIDI Interface on the given Serial interface with the given baud rate.
Definition: DebugMIDI_Interface.hpp:70
USBDebugMIDI_Interface::USBDebugMIDI_Interface
USBDebugMIDI_Interface(unsigned long baud=AH::defaultBaudRate)
Construct a USBDebugMIDI_Interface with the given baud rate.
Definition: DebugMIDI_Interface.hpp:124
StreamDebugMIDI_Interface::secondChar
char secondChar
Definition: DebugMIDI_Interface.hpp:38
AH::defaultBaudRate
constexpr unsigned long defaultBaudRate
The default baud rate for debug output.
Definition: AH/Settings/Settings.hpp:36
StreamDebugMIDI_Interface::StreamDebugMIDI_Interface
StreamDebugMIDI_Interface(Stream &stream)
Construct a debug MIDI interface on the given Stream.
Definition: DebugMIDI_Interface.hpp:22
StreamDebugMIDI_Interface::firstChar
char firstChar
Definition: DebugMIDI_Interface.hpp:37
SerialDebugMIDI_Interface::baud
const unsigned long baud
Definition: DebugMIDI_Interface.hpp:80
StreamDebugMIDI_Interface::read
MIDI_read_t read() override
Definition: DebugMIDI_Interface.cpp:40
SerialDebugMIDI_Interface::begin
void begin() override
Start the Serial interface at the predefined baud rate.
Definition: DebugMIDI_Interface.hpp:76
StreamDebugMIDI_Interface
A class for MIDI interfaces sending and receiving human-readable MIDI messages over a Stream.
Definition: DebugMIDI_Interface.hpp:14
hex
Print & hex(Print &printer)
Definition: PrintStream.cpp:62
SoftwareSerialDebugMIDI_Interface
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over a SoftwareS...
Definition: DebugMIDI_Interface.hpp:139
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:151
StreamMIDI_Interface
A class for MIDI interfaces sending and receiving MIDI messages over a Stream.
Definition: SerialMIDI_Interface.hpp:17
USBDebugMIDI_Interface
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over the USB CDC...
Definition: DebugMIDI_Interface.hpp:115
HardwareSerialDebugMIDI_Interface::HardwareSerialDebugMIDI_Interface
HardwareSerialDebugMIDI_Interface(HardwareSerial &serial, unsigned long baud=AH::defaultBaudRate)
Construct a new Debug MIDI Interface on the given HardwareSerial interface with the given baud rate.
Definition: DebugMIDI_Interface.hpp:101