Skip to content

Commit 66df53a

Browse files
committed
Make avr and sam files more similar to aid arduino#5771
1 parent d115f44 commit 66df53a

File tree

6 files changed

+75
-21
lines changed

6 files changed

+75
-21
lines changed

hardware/arduino/avr/cores/arduino/Print.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,6 @@ size_t Print::write(const uint8_t *buffer, size_t size)
4141
return n;
4242
}
4343

44-
size_t Print::print(const __FlashStringHelper *ifsh)
45-
{
46-
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
47-
size_t n = 0;
48-
while (1) {
49-
unsigned char c = pgm_read_byte(p++);
50-
if (c == 0) break;
51-
if (write(c)) n++;
52-
else break;
53-
}
54-
return n;
55-
}
56-
5744
size_t Print::print(const String &s)
5845
{
5946
return write(s.c_str(), s.length());
@@ -257,7 +244,7 @@ size_t Print::printFloat(double number, uint8_t digits)
257244
while (digits-- > 0)
258245
{
259246
remainder *= 10.0;
260-
unsigned int toPrint = (unsigned int)(remainder);
247+
unsigned int toPrint = (unsigned int)remainder;
261248
n += print(toPrint);
262249
remainder -= toPrint;
263250
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
PrintFlashString.cpp - Provides the platform-specific print for flash strings
3+
Copyright (c) 2008 David A. Mellis. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
19+
Modified 23 November 2006 by David A. Mellis
20+
Modified 03 August 2015 by Chuck Todd
21+
*/
22+
23+
#include "Arduino.h"
24+
25+
#include "Print.h"
26+
27+
// Public Methods //////////////////////////////////////////////////////////////
28+
29+
size_t Print::print(const __FlashStringHelper *ifsh)
30+
{
31+
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
32+
size_t n = 0;
33+
while (1) {
34+
unsigned char c = pgm_read_byte(p++);
35+
if (c == 0) break;
36+
if (write(c)) n++;
37+
else break;
38+
}
39+
return n;
40+
}

hardware/arduino/avr/cores/arduino/Stream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Stream : public Print
6767

6868
void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second
6969
unsigned long getTimeout(void) { return _timeout; }
70-
70+
7171
bool find(char *target); // reads data from the stream until the target string is found
7272
bool find(uint8_t *target) { return find ((char *)target); }
7373
// returns true if target string is found, false if timed out (see setTimeout)

hardware/arduino/sam/cores/arduino/Print.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ size_t Print::write(const uint8_t *buffer, size_t size)
4141
return n;
4242
}
4343

44-
size_t Print::print(const __FlashStringHelper *ifsh)
45-
{
46-
return print(reinterpret_cast<const char *>(ifsh));
47-
}
48-
4944
size_t Print::print(const String &s)
5045
{
5146
return write(s.c_str(), s.length());
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
PrintFlashString.cpp - Provides the platform-specific print for flash strings
3+
Copyright (c) 2008 David A. Mellis. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
19+
Modified 23 November 2006 by David A. Mellis
20+
Modified 03 August 2015 by Chuck Todd
21+
*/
22+
23+
#include "Arduino.h"
24+
25+
#include "Print.h"
26+
27+
// Public Methods //////////////////////////////////////////////////////////////
28+
29+
size_t Print::print(const __FlashStringHelper *ifsh)
30+
{
31+
return print(reinterpret_cast<const char *>(ifsh));
32+
}

hardware/arduino/sam/cores/arduino/Stream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int Stream::timedPeek()
5353

5454
// returns peek of the next digit in the stream or -1 if timeout
5555
// discards non-numeric characters
56-
int Stream::peekNextDigit(LookaheadMode lookahead, bool detectDecimal )
56+
int Stream::peekNextDigit(LookaheadMode lookahead, bool detectDecimal)
5757
{
5858
int c;
5959
while (1) {

0 commit comments

Comments
 (0)