From 05e82a21e392bdbab76c0a240b58c23006efaa9e Mon Sep 17 00:00:00 2001 From: Shawn Silverman Date: Mon, 7 Aug 2023 18:03:49 -0700 Subject: [PATCH] Change 'virtual' to 'override' where appropriate --- teensy/CrashReport.h | 2 +- teensy/HardwareSerial.h | 12 +++--- teensy/IPAddress.h | 2 +- teensy3/CrashReport.h | 2 +- teensy3/FS.h | 2 +- teensy3/HardwareSerial.h | 84 ++++++++++++++++++++-------------------- teensy3/IPAddress.h | 2 +- teensy3/usb_keyboard.h | 2 +- teensy3/usb_seremu.h | 28 +++++++------- teensy3/usb_serial.h | 28 +++++++------- teensy3/usb_serial2.h | 14 +++---- teensy3/usb_serial3.h | 14 +++---- teensy4/CrashReport.h | 2 +- teensy4/FS.h | 2 +- teensy4/HardwareSerial.h | 12 +++--- teensy4/IPAddress.h | 2 +- teensy4/usb_keyboard.h | 2 +- teensy4/usb_seremu.h | 28 +++++++------- teensy4/usb_serial.h | 56 +++++++++++++-------------- usb_disk/usb_api.h | 12 +++--- usb_flightsim/usb_api.h | 10 ++--- usb_hid/usb_api.h | 12 +++--- usb_midi/usb_api.h | 10 ++--- usb_rawhid/usb_api.h | 10 ++--- usb_serial/usb_api.h | 14 +++---- usb_serial_hid/usb_api.h | 14 +++---- 26 files changed, 189 insertions(+), 189 deletions(-) diff --git a/teensy/CrashReport.h b/teensy/CrashReport.h index a92ff0091..10a34ba04 100644 --- a/teensy/CrashReport.h +++ b/teensy/CrashReport.h @@ -5,7 +5,7 @@ class CrashReportClass: public Printable { public: - virtual size_t printTo(Print& p) const; + size_t printTo(Print& p) const override; void clear(); operator bool(); }; diff --git a/teensy/HardwareSerial.h b/teensy/HardwareSerial.h index 4e27408df..25daeede1 100644 --- a/teensy/HardwareSerial.h +++ b/teensy/HardwareSerial.h @@ -13,14 +13,14 @@ class HardwareSerial : public Stream void _begin(uint16_t baud_count, uint8_t pin); void end(void); void transmitterEnable(uint8_t pin); - virtual int available(void); - virtual int peek(void); - virtual int read(void); - virtual void flush(void); - int availableForWrite(void); + int available(void) override; + int peek(void) override; + int read(void) override; + void flush(void) override; + int availableForWrite(void) override; void clear(void); #if ARDUINO >= 100 - virtual size_t write(uint8_t); + size_t write(uint8_t) override; #else virtual void write(uint8_t); #endif diff --git a/teensy/IPAddress.h b/teensy/IPAddress.h index 3640f5639..1555be8d8 100644 --- a/teensy/IPAddress.h +++ b/teensy/IPAddress.h @@ -70,7 +70,7 @@ class IPAddress : public Printable { IPAddress& operator=(const uint8_t *address); IPAddress& operator=(uint32_t address); - virtual size_t printTo(Print& p) const; + size_t printTo(Print& p) const override; friend class EthernetClass; friend class UDP; diff --git a/teensy3/CrashReport.h b/teensy3/CrashReport.h index 972484232..c8d87aa31 100644 --- a/teensy3/CrashReport.h +++ b/teensy3/CrashReport.h @@ -5,7 +5,7 @@ class CrashReportClass: public Printable { public: - virtual size_t printTo(Print& p) const; + size_t printTo(Print& p) const override; void clear(); operator bool(); void breadcrumb(unsigned int num, unsigned int value) { } diff --git a/teensy3/FS.h b/teensy3/FS.h index dabc8c89a..dbcb0f24f 100644 --- a/teensy3/FS.h +++ b/teensy3/FS.h @@ -167,7 +167,7 @@ class File final : public Stream { } // override print version - virtual size_t write(const uint8_t *buf, size_t size) { + size_t write(const uint8_t *buf, size_t size) override { return (f) ? f->write((void*)buf, size) : 0; } diff --git a/teensy3/HardwareSerial.h b/teensy3/HardwareSerial.h index b90b1c907..d0f01221e 100644 --- a/teensy3/HardwareSerial.h +++ b/teensy3/HardwareSerial.h @@ -292,21 +292,21 @@ class HardwareSerial : public Stream virtual void setTX(uint8_t pin, bool opendrain=false) { serial_set_tx(pin, opendrain); } virtual bool attachRts(uint8_t pin) { return serial_set_rts(pin); } virtual bool attachCts(uint8_t pin) { return serial_set_cts(pin); } - virtual int available(void) { return serial_available(); } - virtual int peek(void) { return serial_peek(); } - virtual int read(void) { return serial_getchar(); } - virtual void flush(void) { serial_flush(); } + int available(void) override { return serial_available(); } + int peek(void) override { return serial_peek(); } + int read(void) override { return serial_getchar(); } + void flush(void) override { serial_flush(); } virtual void clear(void) { serial_clear(); } - virtual int availableForWrite(void) { return serial_write_buffer_free(); } + int availableForWrite(void) override { return serial_write_buffer_free(); } virtual void addMemoryForRead(void *buffer, size_t length) {serial_add_memory_for_read(buffer, length);} virtual void addMemoryForWrite(void *buffer, size_t length){serial_add_memory_for_write(buffer, length);} using Print::write; - virtual size_t write(uint8_t c) { serial_putchar(c); return 1; } + size_t write(uint8_t c) override { serial_putchar(c); return 1; } virtual size_t write(unsigned long n) { return write((uint8_t)n); } virtual size_t write(long n) { return write((uint8_t)n); } virtual size_t write(unsigned int n) { return write((uint8_t)n); } virtual size_t write(int n) { return write((uint8_t)n); } - virtual size_t write(const uint8_t *buffer, size_t size) + size_t write(const uint8_t *buffer, size_t size) override { serial_write(buffer, size); return size; } virtual size_t write(const char *str) { size_t len = strlen(str); serial_write((const uint8_t *)str, len); @@ -346,21 +346,21 @@ class HardwareSerial2 : public HardwareSerial virtual void setTX(uint8_t pin, bool opendrain=false) { serial2_set_tx(pin, opendrain); } virtual bool attachRts(uint8_t pin) { return serial2_set_rts(pin); } virtual bool attachCts(uint8_t pin) { return serial2_set_cts(pin); } - virtual int available(void) { return serial2_available(); } - virtual int peek(void) { return serial2_peek(); } - virtual int read(void) { return serial2_getchar(); } - virtual void flush(void) { serial2_flush(); } + int available(void) override { return serial2_available(); } + int peek(void) override { return serial2_peek(); } + int read(void) override { return serial2_getchar(); } + void flush(void) override { serial2_flush(); } virtual void clear(void) { serial2_clear(); } - virtual int availableForWrite(void) { return serial2_write_buffer_free(); } + int availableForWrite(void) override { return serial2_write_buffer_free(); } virtual void addMemoryForRead(void *buffer, size_t length) {serial2_add_memory_for_read(buffer, length);} virtual void addMemoryForWrite(void *buffer, size_t length){serial2_add_memory_for_write(buffer, length);} using Print::write; - virtual size_t write(uint8_t c) { serial2_putchar(c); return 1; } + size_t write(uint8_t c) override { serial2_putchar(c); return 1; } virtual size_t write(unsigned long n) { return write((uint8_t)n); } virtual size_t write(long n) { return write((uint8_t)n); } virtual size_t write(unsigned int n) { return write((uint8_t)n); } virtual size_t write(int n) { return write((uint8_t)n); } - virtual size_t write(const uint8_t *buffer, size_t size) + size_t write(const uint8_t *buffer, size_t size) override { serial2_write(buffer, size); return size; } virtual size_t write(const char *str) { size_t len = strlen(str); serial2_write((const uint8_t *)str, len); @@ -385,21 +385,21 @@ class HardwareSerial3 : public HardwareSerial virtual void setTX(uint8_t pin, bool opendrain=false) { serial3_set_tx(pin, opendrain); } virtual bool attachRts(uint8_t pin) { return serial3_set_rts(pin); } virtual bool attachCts(uint8_t pin) { return serial3_set_cts(pin); } - virtual int available(void) { return serial3_available(); } - virtual int peek(void) { return serial3_peek(); } - virtual int read(void) { return serial3_getchar(); } - virtual void flush(void) { serial3_flush(); } + int available(void) override { return serial3_available(); } + int peek(void) override { return serial3_peek(); } + int read(void) override { return serial3_getchar(); } + void flush(void) override { serial3_flush(); } virtual void clear(void) { serial3_clear(); } - virtual int availableForWrite(void) { return serial3_write_buffer_free(); } + int availableForWrite(void) override { return serial3_write_buffer_free(); } virtual void addMemoryForRead(void *buffer, size_t length) {serial3_add_memory_for_read(buffer, length);} virtual void addMemoryForWrite(void *buffer, size_t length){serial3_add_memory_for_write(buffer, length);} using Print::write; - virtual size_t write(uint8_t c) { serial3_putchar(c); return 1; } + size_t write(uint8_t c) override { serial3_putchar(c); return 1; } virtual size_t write(unsigned long n) { return write((uint8_t)n); } virtual size_t write(long n) { return write((uint8_t)n); } virtual size_t write(unsigned int n) { return write((uint8_t)n); } virtual size_t write(int n) { return write((uint8_t)n); } - virtual size_t write(const uint8_t *buffer, size_t size) + size_t write(const uint8_t *buffer, size_t size) override { serial3_write(buffer, size); return size; } virtual size_t write(const char *str) { size_t len = strlen(str); serial3_write((const uint8_t *)str, len); @@ -424,21 +424,21 @@ class HardwareSerial4 : public HardwareSerial virtual void setTX(uint8_t pin, bool opendrain=false) { serial4_set_tx(pin, opendrain); } virtual bool attachRts(uint8_t pin) { return serial4_set_rts(pin); } virtual bool attachCts(uint8_t pin) { return serial4_set_cts(pin); } - virtual int available(void) { return serial4_available(); } - virtual int peek(void) { return serial4_peek(); } - virtual int read(void) { return serial4_getchar(); } - virtual void flush(void) { serial4_flush(); } + int available(void) override { return serial4_available(); } + int peek(void) override { return serial4_peek(); } + int read(void) override { return serial4_getchar(); } + void flush(void) override { serial4_flush(); } virtual void clear(void) { serial4_clear(); } - virtual int availableForWrite(void) { return serial4_write_buffer_free(); } + int availableForWrite(void) override { return serial4_write_buffer_free(); } virtual void addMemoryForRead(void *buffer, size_t length) {serial4_add_memory_for_read(buffer, length);} virtual void addMemoryForWrite(void *buffer, size_t length){serial4_add_memory_for_write(buffer, length);} using Print::write; - virtual size_t write(uint8_t c) { serial4_putchar(c); return 1; } + size_t write(uint8_t c) override { serial4_putchar(c); return 1; } virtual size_t write(unsigned long n) { return write((uint8_t)n); } virtual size_t write(long n) { return write((uint8_t)n); } virtual size_t write(unsigned int n) { return write((uint8_t)n); } virtual size_t write(int n) { return write((uint8_t)n); } - virtual size_t write(const uint8_t *buffer, size_t size) + size_t write(const uint8_t *buffer, size_t size) override { serial4_write(buffer, size); return size; } virtual size_t write(const char *str) { size_t len = strlen(str); serial4_write((const uint8_t *)str, len); @@ -463,21 +463,21 @@ class HardwareSerial5 : public HardwareSerial virtual void setTX(uint8_t pin, bool opendrain=false) { serial5_set_tx(pin, opendrain); } virtual bool attachRts(uint8_t pin) { return serial5_set_rts(pin); } virtual bool attachCts(uint8_t pin) { return serial5_set_cts(pin); } - virtual int available(void) { return serial5_available(); } - virtual int peek(void) { return serial5_peek(); } - virtual int read(void) { return serial5_getchar(); } - virtual void flush(void) { serial5_flush(); } + int available(void) override { return serial5_available(); } + int peek(void) override { return serial5_peek(); } + int read(void) override { return serial5_getchar(); } + void flush(void) override { serial5_flush(); } virtual void clear(void) { serial5_clear(); } - virtual int availableForWrite(void) { return serial5_write_buffer_free(); } + int availableForWrite(void) override { return serial5_write_buffer_free(); } virtual void addMemoryForRead(void *buffer, size_t length) {serial5_add_memory_for_read(buffer, length);} virtual void addMemoryForWrite(void *buffer, size_t length){serial5_add_memory_for_write(buffer, length);} using Print::write; - virtual size_t write(uint8_t c) { serial5_putchar(c); return 1; } + size_t write(uint8_t c) override { serial5_putchar(c); return 1; } virtual size_t write(unsigned long n) { return write((uint8_t)n); } virtual size_t write(long n) { return write((uint8_t)n); } virtual size_t write(unsigned int n) { return write((uint8_t)n); } virtual size_t write(int n) { return write((uint8_t)n); } - virtual size_t write(const uint8_t *buffer, size_t size) + size_t write(const uint8_t *buffer, size_t size) override { serial5_write(buffer, size); return size; } virtual size_t write(const char *str) { size_t len = strlen(str); serial5_write((const uint8_t *)str, len); @@ -509,21 +509,21 @@ class HardwareSerial6 : public HardwareSerial virtual void setTX(uint8_t pin, bool opendrain=false) { serial6_set_tx(pin, opendrain); } virtual bool attachRts(uint8_t pin) { return serial6_set_rts(pin); } virtual bool attachCts(uint8_t pin) { return serial6_set_cts(pin); } - virtual int available(void) { return serial6_available(); } - virtual int peek(void) { return serial6_peek(); } - virtual int read(void) { return serial6_getchar(); } - virtual void flush(void) { serial6_flush(); } + int available(void) override { return serial6_available(); } + int peek(void) override { return serial6_peek(); } + int read(void) override { return serial6_getchar(); } + void flush(void) override { serial6_flush(); } virtual void clear(void) { serial6_clear(); } - virtual int availableForWrite(void) { return serial6_write_buffer_free(); } + int availableForWrite(void) override { return serial6_write_buffer_free(); } virtual void addMemoryForRead(void *buffer, size_t length) {serial6_add_memory_for_read(buffer, length);} virtual void addMemoryForWrite(void *buffer, size_t length){serial6_add_memory_for_write(buffer, length);} using Print::write; - virtual size_t write(uint8_t c) { serial6_putchar(c); return 1; } + size_t write(uint8_t c) override { serial6_putchar(c); return 1; } virtual size_t write(unsigned long n) { return write((uint8_t)n); } virtual size_t write(long n) { return write((uint8_t)n); } virtual size_t write(unsigned int n) { return write((uint8_t)n); } virtual size_t write(int n) { return write((uint8_t)n); } - virtual size_t write(const uint8_t *buffer, size_t size) + size_t write(const uint8_t *buffer, size_t size) override { serial6_write(buffer, size); return size; } virtual size_t write(const char *str) { size_t len = strlen(str); serial6_write((const uint8_t *)str, len); diff --git a/teensy3/IPAddress.h b/teensy3/IPAddress.h index c71ea0427..aaa5c9396 100644 --- a/teensy3/IPAddress.h +++ b/teensy3/IPAddress.h @@ -115,7 +115,7 @@ class IPAddress : public Printable { return *this; } - virtual size_t printTo(Print& p) const; + size_t printTo(Print& p) const override; friend class EthernetClass; friend class UDP; diff --git a/teensy3/usb_keyboard.h b/teensy3/usb_keyboard.h index 630f9baea..54e62e27d 100644 --- a/teensy3/usb_keyboard.h +++ b/teensy3/usb_keyboard.h @@ -73,7 +73,7 @@ class usb_keyboard_class : public Print public: void begin(void) { } void end(void) { } - virtual size_t write(uint8_t c) { usb_keyboard_write(c); return 1; } + size_t write(uint8_t c) override { usb_keyboard_write(c); return 1; } size_t write(unsigned long n) { return write((uint8_t)n); } size_t write(long n) { return write((uint8_t)n); } size_t write(unsigned int n) { return write((uint8_t)n); } diff --git a/teensy3/usb_seremu.h b/teensy3/usb_seremu.h index 8dd2a8717..c2a0d122c 100644 --- a/teensy3/usb_seremu.h +++ b/teensy3/usb_seremu.h @@ -82,17 +82,17 @@ class usb_seremu_class : public Stream } } void end() { /* TODO: flush output and shut down USB port */ }; - virtual int available() { return usb_seremu_available(); } - virtual int read() { return usb_seremu_getchar(); } - virtual int peek() { return usb_seremu_peekchar(); } - virtual void flush() { usb_seremu_flush_output(); } - virtual size_t write(uint8_t c) { return usb_seremu_putchar(c); } - virtual size_t write(const uint8_t *buffer, size_t size) { return usb_seremu_write(buffer, size); } + int available() override { return usb_seremu_available(); } + int read() override { return usb_seremu_getchar(); } + int peek() override { return usb_seremu_peekchar(); } + void flush() override { usb_seremu_flush_output(); } + size_t write(uint8_t c) override { return usb_seremu_putchar(c); } + size_t write(const uint8_t *buffer, size_t size) override { return usb_seremu_write(buffer, size); } size_t write(unsigned long n) { return write((uint8_t)n); } size_t write(long n) { return write((uint8_t)n); } size_t write(unsigned int n) { return write((uint8_t)n); } size_t write(int n) { return write((uint8_t)n); } - virtual int availableForWrite() { return usb_seremu_write_buffer_free(); } + int availableForWrite() override { return usb_seremu_write_buffer_free(); } using Print::write; void send_now(void) { usb_seremu_flush_output(); }; uint32_t baud(void) { return 9600; } @@ -120,17 +120,17 @@ class usb_seremu_class : public Stream constexpr usb_seremu_class() {} void begin(long) { }; void end() { }; - virtual int available() { return 0; } - virtual int read() { return -1; } - virtual int peek() { return -1; } - virtual void flush() { } - virtual size_t write(uint8_t c) { return 1; } - virtual size_t write(const uint8_t *buffer, size_t size) { return size; } + int available() override { return 0; } + int read() override { return -1; } + int peek() override { return -1; } + void flush() override { } + size_t write(uint8_t c) override { return 1; } + size_t write(const uint8_t *buffer, size_t size) override { return size; } size_t write(unsigned long n) { return 1; } size_t write(long n) { return 1; } size_t write(unsigned int n) { return 1; } size_t write(int n) { return 1; } - virtual int availableForWrite() { return 0; } + int availableForWrite() override { return 0; } using Print::write; void send_now(void) { } uint32_t baud(void) { return 0; } diff --git a/teensy3/usb_serial.h b/teensy3/usb_serial.h index 07c6ac391..804334832 100644 --- a/teensy3/usb_serial.h +++ b/teensy3/usb_serial.h @@ -91,18 +91,18 @@ class usb_serial_class : public Stream } } void end() { /* TODO: flush output and shut down USB port */ }; - virtual int available() { return usb_serial_available(); } - virtual int read() { return usb_serial_getchar(); } - virtual int peek() { return usb_serial_peekchar(); } - virtual void flush() { usb_serial_flush_output(); } // TODO: actually wait for data to leave USB... + int available() override { return usb_serial_available(); } + int read() override { return usb_serial_getchar(); } + int peek() override { return usb_serial_peekchar(); } + void flush() override { usb_serial_flush_output(); } // TODO: actually wait for data to leave USB... virtual void clear(void) { usb_serial_flush_input(); } - virtual size_t write(uint8_t c) { return usb_serial_putchar(c); } - virtual size_t write(const uint8_t *buffer, size_t size) { return usb_serial_write(buffer, size); } + size_t write(uint8_t c) override { return usb_serial_putchar(c); } + size_t write(const uint8_t *buffer, size_t size) override { return usb_serial_write(buffer, size); } size_t write(unsigned long n) { return write((uint8_t)n); } size_t write(long n) { return write((uint8_t)n); } size_t write(unsigned int n) { return write((uint8_t)n); } size_t write(int n) { return write((uint8_t)n); } - virtual int availableForWrite() { return usb_serial_write_buffer_free(); } + int availableForWrite() override { return usb_serial_write_buffer_free(); } using Print::write; void send_now(void) { usb_serial_flush_output(); } uint32_t baud(void) { return usb_cdc_line_coding[0]; } @@ -144,18 +144,18 @@ class usb_serial_class : public Stream constexpr usb_serial_class() {} void begin(long) { }; void end() { }; - virtual int available() { return 0; } - virtual int read() { return -1; } - virtual int peek() { return -1; } - virtual void flush() { } + int available() override { return 0; } + int read() override { return -1; } + int peek() override { return -1; } + void flush() override { } virtual void clear() { } - virtual size_t write(uint8_t c) { return 1; } - virtual size_t write(const uint8_t *buffer, size_t size) { return size; } + size_t write(uint8_t c) override { return 1; } + size_t write(const uint8_t *buffer, size_t size) override { return size; } size_t write(unsigned long n) { return 1; } size_t write(long n) { return 1; } size_t write(unsigned int n) { return 1; } size_t write(int n) { return 1; } - virtual int availableForWrite() { return 0; } + int availableForWrite() override { return 0; } using Print::write; void send_now(void) { } uint32_t baud(void) { return 0; } diff --git a/teensy3/usb_serial2.h b/teensy3/usb_serial2.h index 4acbbca3b..a912b0ed4 100644 --- a/teensy3/usb_serial2.h +++ b/teensy3/usb_serial2.h @@ -93,18 +93,18 @@ class usb_serial2_class : public Stream //} } void end() { /* TODO: flush output and shut down USB port */ }; - virtual int available() { return usb_serial2_available(); } - virtual int read() { return usb_serial2_getchar(); } - virtual int peek() { return usb_serial2_peekchar(); } - virtual void flush() { usb_serial2_flush_output(); } // TODO: actually wait for data to leave USB... + int available() override { return usb_serial2_available(); } + int read() override { return usb_serial2_getchar(); } + int peek() override { return usb_serial2_peekchar(); } + void flush() override { usb_serial2_flush_output(); } // TODO: actually wait for data to leave USB... virtual void clear(void) { usb_serial2_flush_input(); } - virtual size_t write(uint8_t c) { return usb_serial2_putchar(c); } - virtual size_t write(const uint8_t *buffer, size_t size) { return usb_serial2_write(buffer, size); } + size_t write(uint8_t c) override { return usb_serial2_putchar(c); } + size_t write(const uint8_t *buffer, size_t size) override { return usb_serial2_write(buffer, size); } size_t write(unsigned long n) { return write((uint8_t)n); } size_t write(long n) { return write((uint8_t)n); } size_t write(unsigned int n) { return write((uint8_t)n); } size_t write(int n) { return write((uint8_t)n); } - virtual int availableForWrite() { return usb_serial2_write_buffer_free(); } + int availableForWrite() override { return usb_serial2_write_buffer_free(); } using Print::write; void send_now(void) { usb_serial2_flush_output(); } uint32_t baud(void) { return usb_cdc2_line_coding[0]; } diff --git a/teensy3/usb_serial3.h b/teensy3/usb_serial3.h index 7406cd6c6..0e4eab574 100644 --- a/teensy3/usb_serial3.h +++ b/teensy3/usb_serial3.h @@ -93,18 +93,18 @@ class usb_serial3_class : public Stream //} } void end() { /* TODO: flush output and shut down USB port */ }; - virtual int available() { return usb_serial3_available(); } - virtual int read() { return usb_serial3_getchar(); } - virtual int peek() { return usb_serial3_peekchar(); } - virtual void flush() { usb_serial3_flush_output(); } // TODO: actually wait for data to leave USB... + int available() override { return usb_serial3_available(); } + int read() override { return usb_serial3_getchar(); } + int peek() override { return usb_serial3_peekchar(); } + void flush() override { usb_serial3_flush_output(); } // TODO: actually wait for data to leave USB... virtual void clear(void) { usb_serial3_flush_input(); } - virtual size_t write(uint8_t c) { return usb_serial3_putchar(c); } - virtual size_t write(const uint8_t *buffer, size_t size) { return usb_serial3_write(buffer, size); } + size_t write(uint8_t c) override { return usb_serial3_putchar(c); } + size_t write(const uint8_t *buffer, size_t size) override { return usb_serial3_write(buffer, size); } size_t write(unsigned long n) { return write((uint8_t)n); } size_t write(long n) { return write((uint8_t)n); } size_t write(unsigned int n) { return write((uint8_t)n); } size_t write(int n) { return write((uint8_t)n); } - virtual int availableForWrite() { return usb_serial3_write_buffer_free(); } + int availableForWrite() override { return usb_serial3_write_buffer_free(); } using Print::write; void send_now(void) { usb_serial3_flush_output(); } uint32_t baud(void) { return usb_cdc3_line_coding[0]; } diff --git a/teensy4/CrashReport.h b/teensy4/CrashReport.h index 2763a79f5..e09563a74 100644 --- a/teensy4/CrashReport.h +++ b/teensy4/CrashReport.h @@ -5,7 +5,7 @@ class CrashReportClass: public Printable { public: - virtual size_t printTo(Print& p) const; + size_t printTo(Print& p) const override ; static void clear(); operator bool(); static void breadcrumb(unsigned int num, unsigned int value) { diff --git a/teensy4/FS.h b/teensy4/FS.h index 93b7d7535..ede2e4997 100644 --- a/teensy4/FS.h +++ b/teensy4/FS.h @@ -167,7 +167,7 @@ class File final : public Stream { return (f) ? f->read(buf, nbyte) : 0; } // Write bytes to a file - virtual size_t write(const uint8_t *buf, size_t size) { + size_t write(const uint8_t *buf, size_t size) override { // override print version return (f) ? f->write((void*)buf, size) : 0; } diff --git a/teensy4/HardwareSerial.h b/teensy4/HardwareSerial.h index f585bfcd9..c9069f9bd 100644 --- a/teensy4/HardwareSerial.h +++ b/teensy4/HardwareSerial.h @@ -212,16 +212,16 @@ class HardwareSerialIMXRT : public HardwareSerial void end(void); // Returns the number of bytes which have been received and // can be fetched with read() or readBytes(). - virtual int available(void); + int available(void) override; // Returns the next received byte, but does not remove it from the receive // buffer. Returns -1 if nothing has been received. - virtual int peek(void); + int peek(void) override; // Wait for all data written by print() or write() to actually transmit. - virtual void flush(void); + void flush(void) override; // Transmit a single byte - virtual size_t write(uint8_t c); + size_t write(uint8_t c) override; // Reads the next received byte, or returns -1 if nothing has been received. - virtual int read(void); + int read(void) override; // Configures a digital pin to be HIGH while transmitting. Typically this // pin is used to control the DE and RE' pins of an 8 pin RS485 transceiver // chip, which transmits when DE is high and receives when RE' is low. @@ -250,7 +250,7 @@ class HardwareSerialIMXRT : public HardwareSerial // without waiting. Typically programs which must maintain rapid checking // and response to sensors use availableForWrite() to decide whether to // transmit. - virtual int availableForWrite(void); + int availableForWrite(void) override; // Increase the amount of buffer memory between reception of bytes by the // serial hardware and the available() and read() functions. This is useful // when your program must spend lengthy times performing other work, like diff --git a/teensy4/IPAddress.h b/teensy4/IPAddress.h index c71ea0427..aaa5c9396 100644 --- a/teensy4/IPAddress.h +++ b/teensy4/IPAddress.h @@ -115,7 +115,7 @@ class IPAddress : public Printable { return *this; } - virtual size_t printTo(Print& p) const; + size_t printTo(Print& p) const override; friend class EthernetClass; friend class UDP; diff --git a/teensy4/usb_keyboard.h b/teensy4/usb_keyboard.h index 18932193b..bbc71c99e 100644 --- a/teensy4/usb_keyboard.h +++ b/teensy4/usb_keyboard.h @@ -74,7 +74,7 @@ class usb_keyboard_class : public Print public: void begin(void) { } void end(void) { } - virtual size_t write(uint8_t c) { usb_keyboard_write(c); return 1; } + size_t write(uint8_t c) override { usb_keyboard_write(c); return 1; } size_t write(unsigned long n) { return write((uint8_t)n); } size_t write(long n) { return write((uint8_t)n); } size_t write(unsigned int n) { return write((uint8_t)n); } diff --git a/teensy4/usb_seremu.h b/teensy4/usb_seremu.h index 034b59950..cec0457bb 100644 --- a/teensy4/usb_seremu.h +++ b/teensy4/usb_seremu.h @@ -80,17 +80,17 @@ class usb_seremu_class : public Stream } } void end() { /* TODO: flush output and shut down USB port */ }; - virtual int available() { return usb_seremu_available(); } - virtual int read() { return usb_seremu_getchar(); } - virtual int peek() { return usb_seremu_peekchar(); } - virtual void flush() { usb_seremu_flush_output(); } - virtual size_t write(uint8_t c) { return usb_seremu_putchar(c); } - virtual size_t write(const uint8_t *buffer, size_t size) { return usb_seremu_write(buffer, size); } + int available() override { return usb_seremu_available(); } + int read() override { return usb_seremu_getchar(); } + int peek() override { return usb_seremu_peekchar(); } + void flush() override { usb_seremu_flush_output(); } + size_t write(uint8_t c) override { return usb_seremu_putchar(c); } + size_t write(const uint8_t *buffer, size_t size) override { return usb_seremu_write(buffer, size); } size_t write(unsigned long n) { return write((uint8_t)n); } size_t write(long n) { return write((uint8_t)n); } size_t write(unsigned int n) { return write((uint8_t)n); } size_t write(int n) { return write((uint8_t)n); } - virtual int availableForWrite() { return usb_seremu_write_buffer_free(); } + int availableForWrite() override { return usb_seremu_write_buffer_free(); } using Print::write; void send_now(void) { usb_seremu_flush_output(); }; uint32_t baud(void) { return 9600; } @@ -115,17 +115,17 @@ class usb_seremu_class : public Stream constexpr usb_seremu_class() {} void begin(long) { }; void end() { }; - virtual int available() { return 0; } - virtual int read() { return -1; } - virtual int peek() { return -1; } - virtual void flush() { } - virtual size_t write(uint8_t c) { return 1; } - virtual size_t write(const uint8_t *buffer, size_t size) { return size; } + int available() override { return 0; } + int read() override { return -1; } + int peek() override { return -1; } + void flush() override { } + size_t write(uint8_t c) override { return 1; } + size_t write(const uint8_t *buffer, size_t size) override { return size; } size_t write(unsigned long n) { return 1; } size_t write(long n) { return 1; } size_t write(unsigned int n) { return 1; } size_t write(int n) { return 1; } - virtual int availableForWrite() { return 0; } + int availableForWrite() override { return 0; } using Print::write; void send_now(void) { } uint32_t baud(void) { return 0; } diff --git a/teensy4/usb_serial.h b/teensy4/usb_serial.h index 6254a436a..8150e38de 100644 --- a/teensy4/usb_serial.h +++ b/teensy4/usb_serial.h @@ -96,25 +96,25 @@ class usb_serial_class : public Stream void end() { /* TODO: flush output and shut down USB port */ }; // Returns the number of bytes which have been received from your PC and // can be fetched using Serial.read() or Serial.readBytes(). - virtual int available() { return usb_serial_available(); } + int available() override { return usb_serial_available(); } // Reads the next received byte, or returns -1 if nothing has been received // from your PC. - virtual int read() { return usb_serial_getchar(); } + int read() override { return usb_serial_getchar(); } // Returns the next received byte, but does not remove it from the receive // buffer. Returns -1 if nothing has been received from your PC. - virtual int peek() { return usb_serial_peekchar(); } + int peek() override { return usb_serial_peekchar(); } // Wait for all data written by print() or write() to actually transmit to // your PC. On Teensy 4, this function has a known limitation where it // returns early, when buffered data has been given to Teensy's USB device // controller, but before your PC's USB host controller actually transfers // the data across your USB cable. - virtual void flush() { usb_serial_flush_output(); } // TODO: actually wait for data to leave USB... + void flush() override { usb_serial_flush_output(); } // TODO: actually wait for data to leave USB... // Discard all received data which has not been read. virtual void clear(void) { usb_serial_flush_input(); } // Transmit a single byte to your PC - virtual size_t write(uint8_t c) { return usb_serial_putchar(c); } + size_t write(uint8_t c) override { return usb_serial_putchar(c); } // Transmit a buffer containing any number of bytes to your PC - virtual size_t write(const uint8_t *buffer, size_t size) { return usb_serial_write(buffer, size); } + size_t write(const uint8_t *buffer, size_t size) override { return usb_serial_write(buffer, size); } // Transmit a single byte to your PC size_t write(unsigned long n) { return write((uint8_t)n); } // Transmit a single byte to your PC @@ -127,7 +127,7 @@ class usb_serial_class : public Stream // without waiting. Typically programs which must maintain rapid checking // and response to sensors use availableForWrite() to decide whether to // transmit. - virtual int availableForWrite() { return usb_serial_write_buffer_free(); } + int availableForWrite() override { return usb_serial_write_buffer_free(); } using Print::write; // Cause any previously transmitted data written to buffers to be actually // sent over the USB cable to your PC as soon as possible. Normally writes @@ -199,18 +199,18 @@ class usb_serial_class : public Stream constexpr usb_serial_class() {} void begin(long) { }; void end() { }; - virtual int available() { return 0; } - virtual int read() { return -1; } - virtual int peek() { return -1; } - virtual void flush() { } + int available() override { return 0; } + int read() override { return -1; } + int peek() override { return -1; } + void flush() override { } virtual void clear() { } - virtual size_t write(uint8_t c) { return 1; } - virtual size_t write(const uint8_t *buffer, size_t size) { return size; } + size_t write(uint8_t c) override { return 1; } + size_t write(const uint8_t *buffer, size_t size) override { return size; } size_t write(unsigned long n) { return 1; } size_t write(long n) { return 1; } size_t write(unsigned int n) { return 1; } size_t write(int n) { return 1; } - virtual int availableForWrite() { return 0; } + int availableForWrite() override { return 0; } using Print::write; void send_now(void) { } uint32_t baud(void) { return 0; } @@ -278,18 +278,18 @@ class usb_serial2_class : public Stream //} } void end() { /* TODO: flush output and shut down USB port */ }; - virtual int available() { return usb_serial2_available(); } - virtual int read() { return usb_serial2_getchar(); } - virtual int peek() { return usb_serial2_peekchar(); } - virtual void flush() { usb_serial2_flush_output(); } // TODO: actually wait for data to leave USB... + int available() override { return usb_serial2_available(); } + int read() override { return usb_serial2_getchar(); } + int peek() override { return usb_serial2_peekchar(); } + void flush() override { usb_serial2_flush_output(); } // TODO: actually wait for data to leave USB... virtual void clear(void) { usb_serial2_flush_input(); } - virtual size_t write(uint8_t c) { return usb_serial2_putchar(c); } - virtual size_t write(const uint8_t *buffer, size_t size) { return usb_serial2_write(buffer, size); } + size_t write(uint8_t c) override { return usb_serial2_putchar(c); } + size_t write(const uint8_t *buffer, size_t size) override { return usb_serial2_write(buffer, size); } size_t write(unsigned long n) { return write((uint8_t)n); } size_t write(long n) { return write((uint8_t)n); } size_t write(unsigned int n) { return write((uint8_t)n); } size_t write(int n) { return write((uint8_t)n); } - virtual int availableForWrite() { return usb_serial2_write_buffer_free(); } + int availableForWrite() override { return usb_serial2_write_buffer_free(); } using Print::write; void send_now(void) { usb_serial2_flush_output(); } uint32_t baud(void) { return usb_cdc2_line_coding[0]; } @@ -368,18 +368,18 @@ class usb_serial3_class : public Stream //} } void end() { /* TODO: flush output and shut down USB port */ }; - virtual int available() { return usb_serial3_available(); } - virtual int read() { return usb_serial3_getchar(); } - virtual int peek() { return usb_serial3_peekchar(); } - virtual void flush() { usb_serial3_flush_output(); } // TODO: actually wait for data to leave USB... + int available() override { return usb_serial3_available(); } + int read() override { return usb_serial3_getchar(); } + int peek() override { return usb_serial3_peekchar(); } + void flush() override { usb_serial3_flush_output(); } // TODO: actually wait for data to leave USB... virtual void clear(void) { usb_serial3_flush_input(); } - virtual size_t write(uint8_t c) { return usb_serial3_putchar(c); } - virtual size_t write(const uint8_t *buffer, size_t size) { return usb_serial3_write(buffer, size); } + size_t write(uint8_t c) override { return usb_serial3_putchar(c); } + size_t write(const uint8_t *buffer, size_t size) override { return usb_serial3_write(buffer, size); } size_t write(unsigned long n) { return write((uint8_t)n); } size_t write(long n) { return write((uint8_t)n); } size_t write(unsigned int n) { return write((uint8_t)n); } size_t write(int n) { return write((uint8_t)n); } - virtual int availableForWrite() { return usb_serial3_write_buffer_free(); } + int availableForWrite() override { return usb_serial3_write_buffer_free(); } using Print::write; void send_now(void) { usb_serial3_flush_output(); } uint32_t baud(void) { return usb_cdc3_line_coding[0]; } diff --git a/usb_disk/usb_api.h b/usb_disk/usb_api.h index 7df80e2b3..2b446405f 100644 --- a/usb_disk/usb_api.h +++ b/usb_disk/usb_api.h @@ -14,7 +14,7 @@ class usb_keyboard_class : public Print void begin(void) { } void end(void) { } #if ARDUINO >= 100 - virtual size_t write(uint8_t); + size_t write(uint8_t) override; #else virtual void write(uint8_t); #endif @@ -54,12 +54,12 @@ class usb_serial_class : public Stream // standard Arduino functions void begin(long); void end(); - virtual int available(); - virtual int read(); - virtual int peek(); - virtual void flush(); + int available() override; + int read() override; + int peek() override; + void flush() override; #if ARDUINO >= 100 - virtual size_t write(uint8_t); + size_t write(uint8_t) override; #else virtual void write(uint8_t); #endif diff --git a/usb_flightsim/usb_api.h b/usb_flightsim/usb_api.h index c55d897f3..6795cf272 100644 --- a/usb_flightsim/usb_api.h +++ b/usb_flightsim/usb_api.h @@ -195,12 +195,12 @@ class usb_serial_class : public Stream // standard Arduino functions void begin(long); void end(); - virtual int available(); - virtual int read(); - virtual int peek(); - virtual void flush(); + int available() override; + int read() override; + int peek() override; + void flush() override; #if ARDUINO >= 100 - virtual size_t write(uint8_t); + size_t write(uint8_t) override; #else virtual void write(uint8_t); #endif diff --git a/usb_hid/usb_api.h b/usb_hid/usb_api.h index 6166a9b92..01e617ea8 100644 --- a/usb_hid/usb_api.h +++ b/usb_hid/usb_api.h @@ -12,7 +12,7 @@ class usb_keyboard_class : public Print public: void begin(void) { } void end(void) { } - virtual size_t write(uint8_t); + size_t write(uint8_t) override; using Print::write; void write_unicode(uint16_t unicode) { write_keycode(unicode_to_keycode(unicode)); } void set_modifier(uint16_t); @@ -188,11 +188,11 @@ class usb_serial_class : public Stream // standard Arduino functions void begin(long); void end(); - virtual int available(); - virtual int read(); - virtual int peek(); - virtual void flush(); - virtual size_t write(uint8_t); + int available() override; + int read() override; + int peek() override; + void flush() override; + size_t write(uint8_t) override; using Print::write; operator bool(); // Teensy extensions diff --git a/usb_midi/usb_api.h b/usb_midi/usb_api.h index 6fe167af0..35f0b16c1 100644 --- a/usb_midi/usb_api.h +++ b/usb_midi/usb_api.h @@ -328,12 +328,12 @@ class usb_serial_class : public Stream // standard Arduino functions void begin(long); void end(); - virtual int available(); - virtual int read(); - virtual int peek(); - virtual void flush(); + int available() override; + int read() override; + int peek() override; + void flush() override; #if ARDUINO >= 100 - virtual size_t write(uint8_t); + size_t write(uint8_t) override; #else virtual void write(uint8_t); #endif diff --git a/usb_rawhid/usb_api.h b/usb_rawhid/usb_api.h index 973ae2137..dab22af61 100644 --- a/usb_rawhid/usb_api.h +++ b/usb_rawhid/usb_api.h @@ -23,12 +23,12 @@ class usb_serial_class : public Stream // standard Arduino functions void begin(long); void end(); - virtual int available(); - virtual int read(); - virtual int peek(); - virtual void flush(); + int available() override; + int read() override; + int peek() override; + void flush() override; #if ARDUINO >= 100 - virtual size_t write(uint8_t); + size_t write(uint8_t) override; #else virtual void write(uint8_t); #endif diff --git a/usb_serial/usb_api.h b/usb_serial/usb_api.h index f1f7efc54..f16b36f10 100644 --- a/usb_serial/usb_api.h +++ b/usb_serial/usb_api.h @@ -10,20 +10,20 @@ class usb_serial_class : public Stream public: void begin(long); void end(); - virtual int available(); - virtual int read(); - virtual int peek(); - virtual void flush(); + int available() override; + int read() override; + int peek() override; + void flush() override; #if ARDUINO >= 100 - virtual size_t write(uint8_t c) { return write(&c, 1); } - virtual size_t write(const uint8_t *buffer, uint16_t size); + size_t write(uint8_t c) override { return write(&c, 1); } + size_t write(const uint8_t *buffer, uint16_t size) override; using Print::write; #else virtual void write(uint8_t c) { write(&c, 1); } virtual void write(const uint8_t *buffer, uint16_t size); virtual void write(const char *s) { write((const uint8_t *)s, strlen(s)); } #endif - virtual int availableForWrite(void); + int availableForWrite(void) override; void clear(void); void send_now(void); uint32_t baud(void); diff --git a/usb_serial_hid/usb_api.h b/usb_serial_hid/usb_api.h index e8c29c178..23c208cb7 100644 --- a/usb_serial_hid/usb_api.h +++ b/usb_serial_hid/usb_api.h @@ -12,13 +12,13 @@ class usb_serial_class : public Stream public: void begin(long); void end(); - virtual int available(); - virtual int read(); - virtual int peek(); - virtual void flush(); + int available() override; + int read() override; + int peek() override; + void flush() override; #if ARDUINO >= 100 - virtual size_t write(uint8_t c) { return write(&c, 1); } - virtual size_t write(const uint8_t *buffer, uint16_t size); + size_t write(uint8_t c) override { return write(&c, 1); } + size_t write(const uint8_t *buffer, uint16_t size) override; using Print::write; #else virtual void write(uint8_t c) { write(&c, 1); } @@ -48,7 +48,7 @@ class usb_keyboard_class : public Print void begin(void) { } void end(void) { } #if ARDUINO >= 100 - virtual size_t write(uint8_t); + size_t write(uint8_t) override; #else virtual void write(uint8_t); #endif