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
This commit is contained in:
Peter Edwards 2017-09-28 12:08:59 +02:00
parent f8d28b8663
commit f65e6905e9
11 changed files with 13 additions and 44 deletions

View File

@ -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) {

View File

@ -28,7 +28,6 @@
#include "Printable.h"
enum {
BYTE = 0,
BIN = 2,
OCT = 8,
DEC = 10,

View File

@ -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).

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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).

View File

@ -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) {

View File

@ -26,7 +26,6 @@
#include <libmaple/libmaple_types.h>
enum {
BYTE = 0,
BIN = 2,
OCT = 8,
DEC = 10,

View File

@ -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) {

View File

@ -28,7 +28,6 @@
#include "Printable.h"
enum {
BYTE = 0,
BIN = 2,
OCT = 8,
DEC = 10,