Added USBHost support.

pull/4/head
Holger Wirtz 7 years ago
parent d58ad40ba6
commit cd80459f4a
  1. 22
      MicroDexed.ino
  2. 1
      config.h

@ -27,6 +27,7 @@
#include <SPI.h>
#include <SD.h>
#include <MIDI.h>
#include <USBHost_t36.h>
#include "dexed.h"
#include "dexed_sysex.h"
#include "config.h"
@ -42,6 +43,11 @@ AudioControlSGTL5000 sgtl5000_1; //xy=507,403
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
Dexed* dexed = new Dexed(SAMPLE_RATE);
IntervalTimer sched;
#ifdef USE_ONBOARD_USB_HOST
USBHost usb_host;
MIDIDevice midi_usb(usb_host);
#endif
bool sd_card_available = false;
#ifdef TEST_MIDI
IntervalTimer sched_note_on;
@ -58,6 +64,11 @@ void setup()
Serial.println(F("(c)2018 H. Wirtz"));
Serial.println(F("setup start"));
// strat up USB host
#ifdef USE_ONBOARD_USB_HOST
usb_host.begin();
#endif
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!SD.begin(SDCARD_CS_PIN))
@ -128,27 +139,34 @@ void loop()
while (42 == 42) // DON'T PANIC!
{
#ifdef USE_ONBOARD_USB_HOST
usb_host.Task();
#endif
audio_buffer = queue1.getBuffer();
if (audio_buffer == NULL)
{
Serial.println(F("audio_buffer allocation problems!"));
}
while (usbMIDI.read())
#ifdef USE_ONBOARD_USB_HOST
while (midi_usb.read())
{
break_for_calculation = dexed->processMidiMessage(usbMIDI.getType(), usbMIDI.getData1(), usbMIDI.getData2());
break_for_calculation = dexed->processMidiMessage(midi_usb.getType(), midi_usb.getData1(), midi_usb.getData2());
if (break_for_calculation == true)
break;
}
if (!break_for_calculation)
{
#endif
while (MIDI.read())
{
break_for_calculation = dexed->processMidiMessage(MIDI.getType(), MIDI.getData1(), MIDI.getData2());
if (break_for_calculation == true)
break;
}
#ifdef USE_ONBOARD_USB_HOST
}
#endif
if (!queue1.available())
continue;

@ -32,6 +32,7 @@
#define VOLUME 0.1
#define SAMPLE_RATE 44100
#define DEXED_ENGINE DEXED_ENGINE_MODERN
#define USE_ONBOARD_USB_HOST 1
//#define SHOW_DEXED_TIMING 1
#define SHOW_XRUN 1
#define SHOW_CPU_LOAD_MSEC 5000

Loading…
Cancel
Save