From f65e6905e93fb9c844c557aac62233872b34c4a5 Mon Sep 17 00:00:00 2001 From: Peter Edwards Date: Thu, 28 Sep 2017 12:08:59 +0200 Subject: [PATCH] Removed non standard functionality from Print class for BYTE "base" as this is available via e.g. Serial.write and conflicts with the FatFS library and potentially anything else defining BYTE Fixed sketches using this behaviour --- STM32F1/cores/maple/Print.cpp | 12 +----------- STM32F1/cores/maple/Print.h | 1 - .../examples/Communication/ASCIITable/ASCIITable.ino | 2 +- .../examples/Communication/MIDI/Midi.ino | 6 +++--- .../SerialCallResponse/SerialCallResponse.ino | 8 ++++---- .../SerialPassthrough/SerialPassthrough.ino | 2 +- .../examples/General/USB_ASCII/USB_ASCII.ino | 2 +- STM32F3/cores/maple/wirish/Print.cpp | 10 +--------- STM32F3/cores/maple/wirish/Print.h | 1 - STM32F4/cores/maple/Print.cpp | 12 +----------- STM32F4/cores/maple/Print.h | 1 - 11 files changed, 13 insertions(+), 44 deletions(-) diff --git a/STM32F1/cores/maple/Print.cpp b/STM32F1/cores/maple/Print.cpp index 76f386b..0a71cf0 100644 --- a/STM32F1/cores/maple/Print.cpp +++ b/STM32F1/cores/maple/Print.cpp @@ -99,10 +99,6 @@ size_t Print::print(unsigned long n, int base) { } size_t Print::print(long long n, int base) { - if (base == BYTE) - { - return write((uint8)n); - } if (n < 0) { print('-'); n = -n; @@ -111,13 +107,7 @@ size_t Print::print(long long n, int base) { } size_t Print::print(unsigned long long n, int base) { -size_t c=0; - if (base == BYTE) { - c= write((uint8)n); - } else { - c= printNumber(n, base); - } - return c; + return printNumber(n, base); } size_t Print::print(double n, int digits) { diff --git a/STM32F1/cores/maple/Print.h b/STM32F1/cores/maple/Print.h index bd37385..f265fac 100644 --- a/STM32F1/cores/maple/Print.h +++ b/STM32F1/cores/maple/Print.h @@ -28,7 +28,6 @@ #include "Printable.h" enum { - BYTE = 0, BIN = 2, OCT = 8, DEC = 10, diff --git a/STM32F1/libraries/A_STM32_Examples/examples/Communication/ASCIITable/ASCIITable.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/ASCIITable/ASCIITable.ino index fc5e5d7..d647457 100644 --- a/STM32F1/libraries/A_STM32_Examples/examples/Communication/ASCIITable/ASCIITable.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/Communication/ASCIITable/ASCIITable.ino @@ -47,7 +47,7 @@ void loop() { // Prints value unaltered, i.e. the raw binary version of the // byte. The serial monitor interprets all bytes as // ASCII, so 33, the first number, will show up as '!' - Serial.print(thisByte, BYTE); + Serial.write(thisByte); Serial.print(", dec: "); // Prints value as string as an ASCII-encoded decimal (base 10). diff --git a/STM32F1/libraries/A_STM32_Examples/examples/Communication/MIDI/Midi.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/MIDI/Midi.ino index 820ffdc..4feaea7 100644 --- a/STM32F1/libraries/A_STM32_Examples/examples/Communication/MIDI/Midi.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/Communication/MIDI/Midi.ino @@ -44,8 +44,8 @@ void loop() { // Plays a MIDI note. Doesn't check to see that cmd is greater than // 127, or that data values are less than 127: void noteOn(int cmd, int pitch, int velocity) { - Serial1.print(cmd, BYTE); - Serial1.print(pitch, BYTE); - Serial1.print(velocity, BYTE); + Serial1.write(cmd); + Serial1.write(pitch); + Serial1.write(velocity); } diff --git a/STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialCallResponse/SerialCallResponse.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialCallResponse/SerialCallResponse.ino index eee35e3..81270cf 100644 --- a/STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialCallResponse/SerialCallResponse.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialCallResponse/SerialCallResponse.ino @@ -50,15 +50,15 @@ void loop() { // read switch, map it to 0 or 255 thirdSensor = map(digitalRead(2), 0, 1, 0, 255); // send sensor values: - Serial.print(firstSensor, BYTE); - Serial.print(secondSensor, BYTE); - Serial.print(thirdSensor, BYTE); + Serial.write(firstSensor); + Serial.write(secondSensor); + Serial.write(thirdSensor); } } void establishContact() { while (Serial.available() <= 0) { - Serial.print('A', BYTE); // send a capital A + Serial.write('A'); // send a capital A delay(300); } } diff --git a/STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialPassthrough/SerialPassthrough.ino b/STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialPassthrough/SerialPassthrough.ino index 71b9e34..0d348f8 100644 --- a/STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialPassthrough/SerialPassthrough.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/Communication/SerialPassthrough/SerialPassthrough.ino @@ -26,6 +26,6 @@ void loop() { // Read from Serial1, send over USB on Maple (or uses hardware serial 1 and hardware serial 2 on non-maple boards: if (Serial1.available()) { inByte = Serial1.read(); - Serial.print(inByte, BYTE); + Serial.write(inByte); } } diff --git a/STM32F1/libraries/A_STM32_Examples/examples/General/USB_ASCII/USB_ASCII.ino b/STM32F1/libraries/A_STM32_Examples/examples/General/USB_ASCII/USB_ASCII.ino index a884978..8a6fe53 100644 --- a/STM32F1/libraries/A_STM32_Examples/examples/General/USB_ASCII/USB_ASCII.ino +++ b/STM32F1/libraries/A_STM32_Examples/examples/General/USB_ASCII/USB_ASCII.ino @@ -67,7 +67,7 @@ void loop() { // Prints value unaltered, i.e. the raw binary version of the // byte. The serial monitor interprets all bytes as // ASCII, so 33, the first number, will show up as '!' - Serial.print(thisByte, BYTE); + Serial.write(thisByte); Serial.print(", dec: "); // Prints value as string as an ASCII-encoded decimal (base 10). diff --git a/STM32F3/cores/maple/wirish/Print.cpp b/STM32F3/cores/maple/wirish/Print.cpp index f6bc0c6..9a8808d 100644 --- a/STM32F3/cores/maple/wirish/Print.cpp +++ b/STM32F3/cores/maple/wirish/Print.cpp @@ -88,10 +88,6 @@ void Print::print(unsigned long n, int base) { } void Print::print(long long n, int base) { - if (base == BYTE) { - write((uint8)n); - return; - } if (n < 0) { print('-'); n = -n; @@ -100,11 +96,7 @@ void Print::print(long long n, int base) { } void Print::print(unsigned long long n, int base) { - if (base == BYTE) { - write((uint8)n); - } else { - printNumber(n, base); - } + printNumber(n, base); } void Print::print(double n, int digits) { diff --git a/STM32F3/cores/maple/wirish/Print.h b/STM32F3/cores/maple/wirish/Print.h index 5fd0b7a..52203ea 100644 --- a/STM32F3/cores/maple/wirish/Print.h +++ b/STM32F3/cores/maple/wirish/Print.h @@ -26,7 +26,6 @@ #include enum { - BYTE = 0, BIN = 2, OCT = 8, DEC = 10, diff --git a/STM32F4/cores/maple/Print.cpp b/STM32F4/cores/maple/Print.cpp index 76f386b..0a71cf0 100644 --- a/STM32F4/cores/maple/Print.cpp +++ b/STM32F4/cores/maple/Print.cpp @@ -99,10 +99,6 @@ size_t Print::print(unsigned long n, int base) { } size_t Print::print(long long n, int base) { - if (base == BYTE) - { - return write((uint8)n); - } if (n < 0) { print('-'); n = -n; @@ -111,13 +107,7 @@ size_t Print::print(long long n, int base) { } size_t Print::print(unsigned long long n, int base) { -size_t c=0; - if (base == BYTE) { - c= write((uint8)n); - } else { - c= printNumber(n, base); - } - return c; + return printNumber(n, base); } size_t Print::print(double n, int digits) { diff --git a/STM32F4/cores/maple/Print.h b/STM32F4/cores/maple/Print.h index bd37385..f265fac 100644 --- a/STM32F4/cores/maple/Print.h +++ b/STM32F4/cores/maple/Print.h @@ -28,7 +28,6 @@ #include "Printable.h" enum { - BYTE = 0, BIN = 2, OCT = 8, DEC = 10,