Skip to content

Commit 10570eb

Browse files
committed
printlf: prinln with only \n and not \r\n
1 parent 6b4a3a6 commit 10570eb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ size_t Print::print(const Printable& x)
125125

126126
size_t Print::println(void)
127127
{
128-
return write("\r\n");
128+
return write(line_ending);
129129
}
130130

131131
size_t Print::println(const String &s)
@@ -198,6 +198,10 @@ size_t Print::println(const Printable& x)
198198
return n;
199199
}
200200

201+
void Print::set_line_ending(const char * ending){
202+
line_ending = ending;
203+
}
204+
201205
// Private Methods /////////////////////////////////////////////////////////////
202206

203207
size_t Print::printNumber(unsigned long n, uint8_t base)

hardware/arduino/avr/cores/arduino/Print.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ class Print
4040
int write_error;
4141
size_t printNumber(unsigned long, uint8_t);
4242
size_t printFloat(double, uint8_t);
43+
const char * line_ending;
4344
protected:
4445
void setWriteError(int err = 1) { write_error = err; }
4546
public:
46-
Print() : write_error(0) {}
47-
47+
Print() : write_error(0) {
48+
line_ending = "\r\n";
49+
}
50+
4851
int getWriteError() { return write_error; }
4952
void clearWriteError() { setWriteError(0); }
5053

@@ -87,6 +90,8 @@ class Print
8790
size_t println(const Printable&);
8891
size_t println(void);
8992

93+
void set_line_ending(const char * ending);
94+
9095
virtual void flush() { /* Empty implementation for backward compatibility */ }
9196
};
9297

0 commit comments

Comments
 (0)