Skip to content

Commit d9aeb3c

Browse files
P-R-O-C-H-Ylucasssvaz
authored andcommitted
Add flush method
1 parent f4fec86 commit d9aeb3c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

libraries/USB/examples/USBVendor/USBVendor.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,11 @@ void loop() {
177177
if (buttonState == LOW) {
178178
Serial.println("Button Pressed");
179179
Vendor.println("Button Pressed");
180+
Vendor.flush(); //Without flushing the data will only be sent when the buffer is full (64 bytes)
180181
} else {
181-
Vendor.println("Button Released");
182182
Serial.println("Button Released");
183+
Vendor.println("Button Released");
184+
Vendor.flush(); //Without flushing the data will only be sent when the buffer is full (64 bytes)
183185
}
184186
delay(100);
185187
}
@@ -189,6 +191,7 @@ void loop() {
189191
uint8_t b[l];
190192
l = Serial.read(b, l);
191193
Vendor.write(b, l);
194+
Vendor.flush(); //Without flushing the data will only be sent when the buffer is full (64 bytes)
192195
}
193196
}
194197
#endif /* ARDUINO_USB_MODE */

libraries/USB/src/USBVendor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ size_t USBVendor::read(uint8_t *buffer, size_t size){
212212
return count;
213213
}
214214

215-
void USBVendor::flush(void){}
215+
void USBVendor::flush(void){
216+
tud_vendor_n_write_flush(itf);
217+
}
216218

217219
#endif /* CONFIG_TINYUSB_VENDOR_ENABLED */
218220
#endif /* SOC_USB_OTG_SUPPORTED */

0 commit comments

Comments
 (0)