Target detection and simplified auto-instanciation.
This commit is contained in:
parent
39a9c3eb2d
commit
691b172187
27
src/MIDI.cpp
27
src/MIDI.cpp
|
|
@ -25,28 +25,11 @@
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if MIDI_AUTO_INSTANCIATE
|
#if MIDI_AUTO_INSTANCIATE && defined(ARDUINO)
|
||||||
# if MIDI_USE_SOFTWARE_SERIAL
|
MIDI_CREATE_INSTANCE(MIDI_DEFAULT_SERIAL_CLASS,
|
||||||
# ifndef FSE_AVR
|
MIDI_DEFAULT_SERIAL_PORT,
|
||||||
# include "../SoftwareSerial/SoftwareSerial.h"
|
MIDI);
|
||||||
SoftwareSerial softSerialClass(MIDI_SOFTSERIAL_RX_PIN,
|
#endif
|
||||||
MIDI_SOFTSERIAL_TX_PIN);
|
|
||||||
# else
|
|
||||||
# error Todo: implement SoftwareSerial for avr core.
|
|
||||||
# endif
|
|
||||||
# undef MIDI_SERIAL_PORT
|
|
||||||
# define MIDI_SERIAL_PORT softSerialClass
|
|
||||||
MIDI_NAMESPACE::MidiInterface<SoftwareSerial> MIDI(MIDI_SERIAL_PORT);
|
|
||||||
|
|
||||||
# else
|
|
||||||
# ifdef FSE_AVR
|
|
||||||
# include <hardware_Serial.h>
|
|
||||||
# else
|
|
||||||
# include "HardwareSerial.h"
|
|
||||||
# endif
|
|
||||||
MIDI_NAMESPACE::MidiInterface<HardwareSerial> MIDI((HardwareSerial&)Serial);
|
|
||||||
# endif // MIDI_USE_SOFTWARE_SERIAL
|
|
||||||
#endif // MIDI_AUTO_INSTANCIATE
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -225,8 +225,8 @@ END_MIDI_NAMESPACE
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if MIDI_AUTO_INSTANCIATE
|
#if MIDI_AUTO_INSTANCIATE && defined(ARDUINO)
|
||||||
extern MIDI_NAMESPACE::MidiInterface<MIDI_SERIAL_CLASS> MIDI;
|
extern MIDI_NAMESPACE::MidiInterface<MIDI_DEFAULT_SERIAL_CLASS> MIDI;
|
||||||
#endif // MIDI_AUTO_INSTANCIATE
|
#endif // MIDI_AUTO_INSTANCIATE
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,9 @@
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef FSE_AVR
|
#if defined(ARDUINO)
|
||||||
|
# include <inttypes.h>
|
||||||
|
#elif defined(FSE_AVR)
|
||||||
# include <core_Types.h>
|
# include <core_Types.h>
|
||||||
#else
|
#else
|
||||||
# include <inttypes.h>
|
# include <inttypes.h>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
// Compilation flags. Set them to 1 to build the associated feature
|
// Compilation flags. Set them to 1 to build the associated feature
|
||||||
// (MIDI in, out, thru), or to 0 to disable the feature and save space.
|
// (MIDI in, out, thru), or to 0 to disable the feature and save space.
|
||||||
// Note that the Thru can only work if in and out are enabled.
|
// Note that thru can work only if input and output are enabled.
|
||||||
|
|
||||||
#define MIDI_BUILD_INPUT 1
|
#define MIDI_BUILD_INPUT 1
|
||||||
#define MIDI_BUILD_OUTPUT 1
|
#define MIDI_BUILD_OUTPUT 1
|
||||||
|
|
@ -37,8 +37,10 @@
|
||||||
// You can turn this off by adding #define MIDI_AUTO_INSTANCIATE 0 just before
|
// You can turn this off by adding #define MIDI_AUTO_INSTANCIATE 0 just before
|
||||||
// including <MIDI.h> in your sketch.
|
// including <MIDI.h> in your sketch.
|
||||||
#ifndef MIDI_AUTO_INSTANCIATE
|
#ifndef MIDI_AUTO_INSTANCIATE
|
||||||
# ifndef FSE_AVR
|
# ifdef ARDUINO
|
||||||
# define MIDI_AUTO_INSTANCIATE 1
|
# define MIDI_AUTO_INSTANCIATE 1
|
||||||
|
# else
|
||||||
|
# define MIDI_AUTO_INSTANCIATE 0 ///< @see MIDI_CREATE_INSTANCE
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -47,10 +49,14 @@
|
||||||
|
|
||||||
// Set the default port to use for MIDI.
|
// Set the default port to use for MIDI.
|
||||||
#if MIDI_AUTO_INSTANCIATE
|
#if MIDI_AUTO_INSTANCIATE
|
||||||
# define MIDI_DEFAULT_SERIAL_PORT Serial
|
# ifdef ARDUINO
|
||||||
# define MIDI_SERIAL_CLASS HardwareSerial
|
# define MIDI_DEFAULT_SERIAL_PORT Serial
|
||||||
# include "Arduino.h"
|
# define MIDI_DEFAULT_SERIAL_CLASS HardwareSerial
|
||||||
# include "HardwareSerial.h"
|
# include "Arduino.h"
|
||||||
|
# include "HardwareSerial.h"
|
||||||
|
# else
|
||||||
|
# error Auto-instanciation disabled. Use MIDI_CREATE_INSTANCE macro.
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue