tttapa / Control-Surface

Arduino library for creating MIDI controllers and other MIDI devices.
GNU General Public License v3.0
1.24k stars 139 forks source link

How to properly use the code for HairlessMIDI and midi 5 pin togeather? #764

Open e36910 opened 2 years ago

e36910 commented 2 years ago

I have 2 exaple HairlessMIDI_Interface midi; // for usb with HairlessMIDI app and USBMIDI_Interface midi; // for midi 5 pin

Separately it works, but when both lines are left, then there is a conflict. What is the right way to write this part of the code so that 2 functions work together?

tttapa commented 2 years ago

This depends on the board you're using. On boards without native USB support, both the Hairless and the USBMIDI interfaces use the same Serial UART by default.

USBMIDI_Interface midi; // for midi 5 pin

This doesn't make much sense, if you want an interface for 5-pin MIDI, use the HardwareSerialMIDI_Interface (or any of the other available Serial interfaces: https://tttapa.github.io/Control-Surface-doc/Doxygen/dc/df0/group__MIDIInterfaces.html).

If both work separately, that probably means that you connected your 5-pin MIDI connector to the same UART that is also connected to the on-board UART-to-USB adapter. You cannot use that one UART for both purposes at the same time, you'll have to use a different UART for 5-pin MIDI.

e36910 commented 2 years ago

I have Node mcu V3 8266. I would used one device for PC via USB and for Helix Rack via 5pin midi out.

tttapa commented 2 years ago

Then you'll have to use UART1 for 5-pin DIN and UART0 for Hairless.

e36910 commented 2 years ago

How to use it?

tttapa commented 2 years ago

Use Serial1: https://arduino-esp8266.readthedocs.io/en/latest/reference.html#serial

e36910 commented 2 years ago

OK thanks. How to correctly write line UART0 for usb and UART1 for midi5 din?

tttapa commented 2 years ago
HardwareSerialMIDI_Interface my_midi_uart0 {Serial};
HardwareSerialMIDI_Interface my_midi_uart1 {Serial1};