Skip to content

Commit

Permalink
add usb host and names
Browse files Browse the repository at this point in the history
  • Loading branch information
okyeron committed Apr 9, 2020
1 parent a5d932f commit 7493cab
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
13 changes: 13 additions & 0 deletions Software/Polaron/Polaron.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "SimpleSineChannel.h"
//#include "SimpleSampleChannel.h"

#include "USBHost_t36.h"

#define PULSE_WIDTH_USEC 5

#define SHIFT_IN_PLOAD_PIN 0 // 2 // Connects to Parallel load pin the 165
Expand All @@ -43,6 +45,9 @@
// pin used to send the serial data to the array of leds (via fastLED)
#define DATA_PIN 6

USBHost myusb;
MIDIDevice midi1(myusb);

BoomChannel channel1;
//SimpleSampleChannel channel2;
SimpleDrumChannel channel2(200, 6000);
Expand Down Expand Up @@ -95,6 +100,9 @@ void setup() {
digitalWrite(SHIFT_IN_CLOCK_PIN, LOW);
digitalWrite(SHIFT_IN_PLOAD_PIN, HIGH);

myusb.begin();
midi1.setHandleRealTimeSystem(onRealTimeSystem);

usbMIDI.setHandleRealTimeSystem(onRealTimeSystem);

AudioMemory(70);
Expand Down Expand Up @@ -238,6 +246,9 @@ void loop() {
FastLED.clearData();
// read all inputs
usbMIDI.read();
myusb.Task();
midi1.read();

readButtonStates();
// update the sequencer state
sequencer.updateState();
Expand All @@ -246,6 +257,8 @@ void loop() {
}

void onRealTimeSystem(uint8_t rtb) {
Serial.println(rtb);

sequencer.onMidiInput(rtb);
}

Expand Down
9 changes: 5 additions & 4 deletions Software/Polaron/Sequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,14 +622,15 @@ void Sequencer::setFunctionButtonLights() {

void Sequencer::onMidiInput(uint8_t rtb) {
switch (rtb) {
case 0xF8: // Clock
case 248: // Clock 248 / 0xF8
//clockMode = ClockMode::MIDI_CLOCK;
midiClockReceived = true;
break;
case 0xFA: // Start
case 250: // Start 250 / 0xFA
clockMode = ClockMode::MIDI_CLOCK;
start();
break;
case 0xFC: // Stop
case 252: // Stop 252 / 0xFC
clockMode = ClockMode::INTERNAL_CLOCK;
stop();
break;
Expand Down Expand Up @@ -721,4 +722,4 @@ CRGB Sequencer::colorForStepState(uint8_t state) {
// trigger off / plock rec off
return CRGB::Black;
}
}
}
30 changes: 30 additions & 0 deletions Software/Polaron/usb_names.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "usb_names.h"

// USED BY TEENSY TO DEFINE USB PRODUCT/MANUFACTURER/SERIAL INFO

#define PRODUCT_NAME {'p','o','l','a','r','o', 'n'}
#define PRODUCT_NAME_LEN 7
#define MANUFACTURER_NAME {'p','o','l','a','r','o', 'n'}
#define MANUFACTURER_NAME_LEN 7

// Change this to something different if you like - but you MUST keep the "m" as the first character.
#define SERIAL_NUM {'m','4','6','7','6','0','5','5'}
#define SERIAL_NUM_LEN 8

struct usb_string_descriptor_struct usb_string_product_name = {
2 + PRODUCT_NAME_LEN * 2,
3,
PRODUCT_NAME
};

struct usb_string_descriptor_struct usb_string_manufacturer_name = {
2 + MANUFACTURER_NAME_LEN * 2,
3,
MANUFACTURER_NAME
};

struct usb_string_descriptor_struct usb_string_serial_number = {
2 + SERIAL_NUM_LEN * 2,
3,
SERIAL_NUM
};

0 comments on commit 7493cab

Please sign in to comment.