@@ -18,10 +18,53 @@ typedef struct {
18
18
} midiEventPacket_t;
19
19
20
20
class USBMIDI {
21
+ private:
22
+ static const char * deviceName;
23
+ static char nameBuffer[32 ]; // Buffer to store the device name
24
+ /* *
25
+ * @brief Get the default device name
26
+ * @return Default name "TinyUSB MIDI" if no other name is set
27
+ */
28
+ static const char * getDefaultDeviceName () {
29
+ return " TinyUSB MIDI" ;
30
+ }
31
+
21
32
public:
22
- USBMIDI (String devDescName = " TinyUSB MIDI" );
33
+ /* *
34
+ * @brief Default constructor
35
+ * Will use the compile-time name if set via SET_USB_MIDI_DEVICE_NAME(),
36
+ * otherwise uses "TinyUSB MIDI"
37
+ */
38
+ USBMIDI (void );
39
+
40
+ /* *
41
+ * @brief Constructor with custom device name
42
+ * @param name The device name to use. This takes precedence over any
43
+ * compile-time name set via SET_USB_MIDI_DEVICE_NAME()
44
+ */
45
+ USBMIDI (const char * name);
46
+
23
47
void begin (void );
24
48
void end (void );
49
+
50
+ /* *
51
+ * @brief Get the current device name
52
+ * @return The device name in order of precedence:
53
+ * 1. Name set via constructor (if any)
54
+ * 2. Name set via SET_USB_MIDI_DEVICE_NAME() macro (if defined)
55
+ * 3. Default name "TinyUSB MIDI"
56
+ */
57
+ static const char * getCurrentDeviceName (void ) {
58
+ return deviceName ? deviceName : getDefaultDeviceName ();
59
+ }
60
+
61
+ /* *
62
+ * @brief Set the default name at compile time
63
+ * @param name The name to set as default if no runtime name is provided
64
+ */
65
+ static void setDefaultName (const char * name) {
66
+ if (!deviceName) deviceName = name;
67
+ }
25
68
26
69
/* User-level API */
27
70
0 commit comments