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 "Arduino.h" // If using an old (pre-1.0) version of Arduino,
|
||||
// use WConstants.h instead of Arduino.h
|
||||
#include "HardwareSerial.h"
|
||||
|
||||
|
||||
#if USE_SOFTWARE_SERIAL
|
||||
#if MIDI_USE_SOFTWARE_SERIAL
|
||||
|
||||
// Note: Make sure the following relative path is correct.
|
||||
#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
|
||||
#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). */
|
||||
|
|
|
|||
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
|
||||
// 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
|
||||
// of the same type and channel.
|
||||
// Set to 0 if you have troubles controlling your hardware.
|
||||
|
|
@ -67,6 +61,18 @@
|
|||
#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
|
||||
(because "unsigned char" is a bit long to write.. )
|
||||
|
|
|
|||
Loading…
Reference in New Issue