I am currently working on a project for a plug-and-play USB-C connected control surface for my Mac. The goal is to control the volume of my sound card via Totalmix using a KY040 encoder, and to add six buttons for shortcuts such as launching applications I will also use a OLED display.
Currently, I am using an ESP32 S2 mini but I am facing difficulties uploading the necessary libraries, including Control_Surface.h and HID-Project.h.
I'm reaching out to the community for help in choosing the most suitable chip for this project, considering MIDI, USB-C functionalities, and the requirement that the controller should be plug-and-play. If anyone has recommendations for a specific chip or insights on maintaining plug-and-play functionality, I would be extremely grateful for your shared experiences.
Thank you in advance for your valuable assistance!
Why this particular chip? It seems overkill for your project in terms of capabilities. It's also relatively new and there's a chance the libraries you mentioned may not have been adapted for this chip yet.
Why not choose a simple Arduino Pro Micro? (Don't confuse with Pro Mini)
#include <Control_Surface.h>
#if ARDUINO_USB_MODE
#error "This sketch should be used when USB is in OTG mode"
#endif
#include "USB.h"
#include "USBMIDI.h"
// This class defines how to send and receive MIDI data using your custom
// backend.
struct MyUSBMIDIBackend {
// USB MIDI packages are 4 bytes.
using MIDIUSBPacket_t = AH::Array<uint8_t, 4>;
// Called once upon initialization.
void begin() { backend.begin(); USB.begin(); }
// Read a single packet. Return a packet of all zeros if there is no packet.
MIDIUSBPacket_t read() {
midiEventPacket_t packet{0, 0, 0, 0};
backend.readPacket(&packet);
return {packet.header, packet.byte1, packet.byte2, packet.byte3};
}
// Write a single packet to the output buffer.
void write(MIDIUSBPacket_t p) {
midiEventPacket_t packet{p[0], p[1], p[2], p[3]};
backend.writePacket(&packet);
}
// Transmit the output buffer immediately.
void sendNow() { /* not implemented */ }
// No explicit call to sendNow is required.
bool preferImmediateSend() { return false; }
// The actual low-level USB MIDI backend provided by the core libraries.
USBMIDI backend;
};
// This is the actual MIDI interface that makes use of the backend defined above.
struct MyUSBMIDI_Interface : GenericUSBMIDI_Interface<MyUSBMIDIBackend> {
MyUSBMIDI_Interface() = default;
using MIDIUSBPacket_t = MyUSBMIDIBackend::MIDIUSBPacket_t;
};
MyUSBMIDI_Interface midi;
void setup() {
Control_Surface.begin();
}
void loop() {
Control_Surface.loop();
}
You right a pro micro is better for my project and more simple to code with. Sorry it's because im new to coding and i thought a esp 32 S2 was simpler. Thank you for your help !