diff --git a/hardware/arduino/avr/cores/arduino/Print.cpp b/hardware/arduino/avr/cores/arduino/Print.cpp index 652fed094a7..79fea6c8d5c 100644 --- a/hardware/arduino/avr/cores/arduino/Print.cpp +++ b/hardware/arduino/avr/cores/arduino/Print.cpp @@ -41,19 +41,6 @@ size_t Print::write(const uint8_t *buffer, size_t size) return n; } -size_t Print::print(const __FlashStringHelper *ifsh) -{ - PGM_P p = reinterpret_cast(ifsh); - size_t n = 0; - while (1) { - unsigned char c = pgm_read_byte(p++); - if (c == 0) break; - if (write(c)) n++; - else break; - } - return n; -} - size_t Print::print(const String &s) { return write(s.c_str(), s.length()); @@ -257,7 +244,7 @@ size_t Print::printFloat(double number, uint8_t digits) while (digits-- > 0) { remainder *= 10.0; - unsigned int toPrint = (unsigned int)(remainder); + unsigned int toPrint = (unsigned int)remainder; n += print(toPrint); remainder -= toPrint; } diff --git a/hardware/arduino/avr/cores/arduino/PrintFlashString.cpp b/hardware/arduino/avr/cores/arduino/PrintFlashString.cpp new file mode 100644 index 00000000000..5e535540a70 --- /dev/null +++ b/hardware/arduino/avr/cores/arduino/PrintFlashString.cpp @@ -0,0 +1,40 @@ +/* + PrintFlashString.cpp - Provides the platform-specific print for flash strings + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Modified 23 November 2006 by David A. Mellis + Modified 03 August 2015 by Chuck Todd + */ + +#include "Arduino.h" + +#include "Print.h" + +// Public Methods ////////////////////////////////////////////////////////////// + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + PGM_P p = reinterpret_cast(ifsh); + size_t n = 0; + while (1) { + unsigned char c = pgm_read_byte(p++); + if (c == 0) break; + if (write(c)) n++; + else break; + } + return n; +} diff --git a/hardware/arduino/avr/cores/arduino/Stream.h b/hardware/arduino/avr/cores/arduino/Stream.h index e4fd4338c7d..3582a181864 100644 --- a/hardware/arduino/avr/cores/arduino/Stream.h +++ b/hardware/arduino/avr/cores/arduino/Stream.h @@ -67,7 +67,7 @@ class Stream : public Print void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second unsigned long getTimeout(void) { return _timeout; } - + bool find(char *target); // reads data from the stream until the target string is found bool find(uint8_t *target) { return find ((char *)target); } // returns true if target string is found, false if timed out (see setTimeout) diff --git a/hardware/arduino/sam/cores/arduino/Print.cpp b/hardware/arduino/sam/cores/arduino/Print.cpp index 089a02bc46b..79fea6c8d5c 100644 --- a/hardware/arduino/sam/cores/arduino/Print.cpp +++ b/hardware/arduino/sam/cores/arduino/Print.cpp @@ -41,11 +41,6 @@ size_t Print::write(const uint8_t *buffer, size_t size) return n; } -size_t Print::print(const __FlashStringHelper *ifsh) -{ - return print(reinterpret_cast(ifsh)); -} - size_t Print::print(const String &s) { return write(s.c_str(), s.length()); diff --git a/hardware/arduino/sam/cores/arduino/PrintFlashString.cpp b/hardware/arduino/sam/cores/arduino/PrintFlashString.cpp new file mode 100644 index 00000000000..4d037d8030c --- /dev/null +++ b/hardware/arduino/sam/cores/arduino/PrintFlashString.cpp @@ -0,0 +1,32 @@ +/* + PrintFlashString.cpp - Provides the platform-specific print for flash strings + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Modified 23 November 2006 by David A. Mellis + Modified 03 August 2015 by Chuck Todd + */ + +#include "Arduino.h" + +#include "Print.h" + +// Public Methods ////////////////////////////////////////////////////////////// + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} diff --git a/hardware/arduino/sam/cores/arduino/Stream.cpp b/hardware/arduino/sam/cores/arduino/Stream.cpp index d018c31f3c2..f66546532e9 100644 --- a/hardware/arduino/sam/cores/arduino/Stream.cpp +++ b/hardware/arduino/sam/cores/arduino/Stream.cpp @@ -53,7 +53,7 @@ int Stream::timedPeek() // returns peek of the next digit in the stream or -1 if timeout // discards non-numeric characters -int Stream::peekNextDigit(LookaheadMode lookahead, bool detectDecimal ) +int Stream::peekNextDigit(LookaheadMode lookahead, bool detectDecimal) { int c; while (1) {