Skip to content

Commit ea4256f

Browse files
committed
skip waiting for serial connection in examples
instead wait until device enumerated/mounted
1 parent 143e2f5 commit ea4256f

File tree

6 files changed

+17
-5
lines changed

6 files changed

+17
-5
lines changed

examples/HID/hid_composite/hid_composite.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ void setup()
6161

6262
Serial.begin(115200);
6363
Serial.println("Adafruit TinyUSB HID Composite example");
64+
65+
// wait until device mounted
66+
while( !USBDevice.mounted() ) delay(1);
6467
}
6568

6669
void loop()

examples/HID/hid_composite_joy_featherwing/hid_composite_joy_featherwing.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ void setup()
7575

7676
last_y = ss.analogRead(2);
7777
last_x = ss.analogRead(3);
78+
79+
// wait until device mounted
80+
while( !USBDevice.mounted() ) delay(1);
7881
}
7982

8083
void loop()

examples/HID/hid_generic_inout/hid_generic_inout.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ void setup()
4949
usb_hid.begin();
5050

5151
Serial.begin(115200);
52-
while ( !Serial ) delay(10); // wait for native usb
52+
53+
// wait until device mounted
54+
while( !USBDevice.mounted() ) delay(1);
5355

5456
Serial.println("Adafruit TinyUSB HID Generic In Out example");
5557
}

examples/HID/hid_keyboard/hid_keyboard.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ void setup()
5050
{
5151
pinMode(pins[i], INPUT_PULLUP);
5252
}
53+
54+
// wait until device mounted
55+
while( !USBDevice.mounted() ) delay(1);
5356
}
5457

5558

examples/HID/hid_mouse/hid_mouse.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ void setup()
5353

5454
Serial.begin(115200);
5555

56+
// wait until device mounted
57+
while( !USBDevice.mounted() ) delay(1);
58+
5659
Serial.println("Adafruit TinyUSB HID Mouse example");
5760
}
5861

examples/MIDI/midi_test/midi_test.ino

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ void setup()
5353

5454
Serial.begin(115200);
5555

56-
// wait for native usb serial to connect
57-
while(!Serial) delay(1);
58-
59-
Serial.println("Adafruit TinyUSB MIDI example");
56+
// wait until device mounted
57+
while( !USBDevice.mounted() ) delay(1);
6058
}
6159

6260
void loop()

0 commit comments

Comments
 (0)