Fix Adafruit TinyUSB API: TinyUSBDevice, writePacket, mounted()
This commit is contained in:
@@ -11,7 +11,6 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel
|
||||
|
||||
build_flags =
|
||||
-DARDUINO_USB_MODE=0
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
|
||||
monitor_speed = 115200
|
||||
|
||||
+11
-8
@@ -13,16 +13,16 @@ UsbMidiTransport::~UsbMidiTransport() {
|
||||
bool UsbMidiTransport::begin() {
|
||||
Serial.println("[MIDI] Initializing USB MIDI...");
|
||||
|
||||
USBDevice.setManufacturerDescriptor("Ashley Strahle");
|
||||
USBDevice.setProductDescriptor("Loopy Foot Controller");
|
||||
USBDevice.setSerialDescriptor("LFMIDI001");
|
||||
TinyUSBDevice.setManufacturerDescriptor("Ashley Strahle");
|
||||
TinyUSBDevice.setProductDescriptor("Loopy Foot Controller");
|
||||
TinyUSBDevice.setSerialDescriptor("LFMIDI001");
|
||||
|
||||
if (!usb_midi.begin(32)) {
|
||||
Serial.println("[MIDI] ERROR: USB MIDI init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
USB.begin();
|
||||
TinyUSBDevice.begin();
|
||||
initialized = true;
|
||||
Serial.println("[MIDI] USB MIDI initialized - waiting for host");
|
||||
return true;
|
||||
@@ -61,24 +61,27 @@ void UsbMidiTransport::on_midi_receive(std::function<void(const MidiEvent&)> cal
|
||||
|
||||
void UsbMidiTransport::send_note_on(uint8_t channel, uint8_t note, uint8_t velocity) {
|
||||
if (!initialized) return;
|
||||
usb_midi.sendNoteOn(note, velocity, channel);
|
||||
uint8_t packet[4] = {0x09, (uint8_t)(0x90 | (channel - 1)), note, velocity};
|
||||
usb_midi.writePacket(packet);
|
||||
Serial.printf("[MIDI OUT] Ch:%d NOTE_ON:%d:%d\n", channel, note, velocity);
|
||||
}
|
||||
|
||||
void UsbMidiTransport::send_note_off(uint8_t channel, uint8_t note, uint8_t velocity) {
|
||||
if (!initialized) return;
|
||||
usb_midi.sendNoteOff(note, velocity, channel);
|
||||
uint8_t packet[4] = {0x08, (uint8_t)(0x80 | (channel - 1)), note, velocity};
|
||||
usb_midi.writePacket(packet);
|
||||
Serial.printf("[MIDI OUT] Ch:%d NOTE_OFF:%d:%d\n", channel, note, velocity);
|
||||
}
|
||||
|
||||
void UsbMidiTransport::send_cc(uint8_t channel, uint8_t cc, uint8_t value) {
|
||||
if (!initialized) return;
|
||||
usb_midi.sendControlChange(cc, value, channel);
|
||||
uint8_t packet[4] = {0x0B, (uint8_t)(0xB0 | (channel - 1)), cc, value};
|
||||
usb_midi.writePacket(packet);
|
||||
Serial.printf("[MIDI OUT] Ch:%d CC:%d:%d\n", channel, cc, value);
|
||||
}
|
||||
|
||||
bool UsbMidiTransport::is_connected() {
|
||||
return initialized && usb_midi.isMounted();
|
||||
return initialized && TinyUSBDevice.mounted();
|
||||
}
|
||||
|
||||
void UsbMidiTransport::parse_midi_packet(const uint8_t* buffer, uint32_t size, MidiEvent& event) {
|
||||
|
||||
Reference in New Issue
Block a user