Define some macros before including MIDI.h in your sketch to enable software serial.
This commit is contained in:
parent
8e087e40b1
commit
323d8e1707
13
src/MIDI.cpp
13
src/MIDI.cpp
|
|
@ -12,19 +12,18 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "Arduino.h" // If using an old (pre-1.0) version of Arduino,
|
#include "Arduino.h" // If using an old (pre-1.0) version of Arduino,
|
||||||
// use WConstants.h instead of Arduino.h
|
// use WConstants.h instead of Arduino.h
|
||||||
#include "HardwareSerial.h"
|
#if MIDI_USE_SOFTWARE_SERIAL
|
||||||
|
|
||||||
|
|
||||||
#if USE_SOFTWARE_SERIAL
|
|
||||||
|
|
||||||
// Note: Make sure the following relative path is correct.
|
// Note: Make sure the following relative path is correct.
|
||||||
#include "../SoftwareSerial/SoftwareSerial.h"
|
#include "../SoftwareSerial/SoftwareSerial.h"
|
||||||
SoftwareSerial softSerialClass(SOFTSERIAL_RX_PIN,SOFTSERIAL_TX_PIN);
|
SoftwareSerial softSerialClass(MIDI_SOFTSERIAL_RX_PIN,
|
||||||
|
MIDI_SOFTSERIAL_TX_PIN);
|
||||||
#undef MIDI_SERIAL_PORT
|
#undef MIDI_SERIAL_PORT
|
||||||
#define MIDI_SERIAL_PORT softSerialClass
|
#define MIDI_SERIAL_PORT softSerialClass
|
||||||
|
|
||||||
#endif // USE_SOFTWARE_SERIAL
|
#else
|
||||||
|
#include "HardwareSerial.h"
|
||||||
|
#endif // MIDI_USE_SOFTWARE_SERIAL
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Main instance (the class comes pre-instantiated). */
|
/*! \brief Main instance (the class comes pre-instantiated). */
|
||||||
|
|
|
||||||
18
src/MIDI.h
18
src/MIDI.h
|
|
@ -36,12 +36,6 @@
|
||||||
|
|
||||||
#define MIDI_SERIAL_PORT Serial // Change the number (to Serial1 for example) if you want
|
#define MIDI_SERIAL_PORT Serial // Change the number (to Serial1 for example) if you want
|
||||||
// to use a different serial port for MIDI I/O.
|
// to use a different serial port for MIDI I/O.
|
||||||
|
|
||||||
#define USE_SOFTWARE_SERIAL 0 // Set to 1 to use SoftwareSerial instead of native serial ports.
|
|
||||||
#define SOFTSERIAL_RX_PIN 1 // This pin number will be used for MIDI Input
|
|
||||||
#define SOFTSERIAL_TX_PIN 2 // This pin number will be used for MIDI Output.
|
|
||||||
|
|
||||||
|
|
||||||
#define USE_RUNNING_STATUS 1 // Running status enables short messages when sending multiple values
|
#define USE_RUNNING_STATUS 1 // Running status enables short messages when sending multiple values
|
||||||
// of the same type and channel.
|
// of the same type and channel.
|
||||||
// Set to 0 if you have troubles controlling your hardware.
|
// Set to 0 if you have troubles controlling your hardware.
|
||||||
|
|
@ -67,6 +61,18 @@
|
||||||
#define MIDI_PITCHBEND_MAX 8191
|
#define MIDI_PITCHBEND_MAX 8191
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MIDI_USE_SOFTWARE_SERIAL
|
||||||
|
#define MIDI_USE_SOFTWARE_SERIAL 0
|
||||||
|
#else
|
||||||
|
#if MIDI_USE_SOFTWARE_SERIAL
|
||||||
|
#if !defined(MIDI_SOFTSERIAL_RX_PIN) || !defined(MIDI_SOFTSERIAL_TX_PIN)
|
||||||
|
#error You need to define some pins to enable MIDI with software serial.
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*! Type definition for practical use
|
/*! Type definition for practical use
|
||||||
(because "unsigned char" is a bit long to write.. )
|
(because "unsigned char" is a bit long to write.. )
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue