@@ -19,15 +19,8 @@ typedef struct {
1919
2020class USBMIDI {
2121private:
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- }
22+ static char * midiUserDeviceName; // user device name
23+ static void setDeviceName (const char * name); // set user device name limites to 32 characters
3124
3225public:
3326 /* *
@@ -38,11 +31,15 @@ class USBMIDI {
3831 USBMIDI (void );
3932
4033 /* *
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- */
34+ * @brief Set the current device name
35+ * 1. Name set via constructor (if any)
36+ * 2. Name set via SET_USB_MIDI_DEVICE_NAME() macro (if defined)
37+ * 3. Default name "TinyUSB MIDI"
38+ * It has no effect if name is set as NULL or ""
39+ */
4540 USBMIDI (const char * name);
41+
42+ ~USBMIDI ();
4643
4744 void begin (void );
4845 void end (void );
@@ -53,18 +50,8 @@ class USBMIDI {
5350 * 1. Name set via constructor (if any)
5451 * 2. Name set via SET_USB_MIDI_DEVICE_NAME() macro (if defined)
5552 * 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- }
53+ */
54+ static const char * getCurrentDeviceName (void );
6855
6956 /* User-level API */
7057
0 commit comments