Skip to content

Commit 97c371e

Browse files
committed
Make the "ln" functions no-inline.
Save 348B of flash
1 parent af36f65 commit 97c371e

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

Firmware/Marlin.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ extern FILE _uartout;
7979
#define SERIAL_PROTOCOL_F(x,y) (MYSERIAL.print(x,y))
8080
#define SERIAL_PROTOCOLPGM(x) (serialprintPGM(PSTR(x)))
8181
#define SERIAL_PROTOCOLRPGM(x) (serialprintPGM((x)))
82-
#define SERIAL_PROTOCOLLN(x) (MYSERIAL.println(x)/*,MYSERIAL.write('\n')*/)
83-
#define SERIAL_PROTOCOLLNPGM(x) (serialprintPGM(PSTR(x)),MYSERIAL.println()/*write('\n')*/)
84-
#define SERIAL_PROTOCOLLNRPGM(x) (serialprintPGM((x)),MYSERIAL.println()/*write('\n')*/)
82+
#define SERIAL_PROTOCOLLN(x) (MYSERIAL.println(x))
83+
#define SERIAL_PROTOCOLLNPGM(x) (serialprintlnPGM(PSTR(x)))
84+
#define SERIAL_PROTOCOLLNRPGM(x) (serialprintlnPGM((x)))
8585

8686

8787
extern const char errormagic[] PROGMEM;
@@ -115,6 +115,9 @@ void serial_echopair_P(const char *s_P, unsigned long v);
115115
// I'd rather skip a few CPU ticks than 5.5KB (!!) of FLASH
116116
void serialprintPGM(const char *str);
117117

118+
//The "ln" variant of the function above.
119+
void serialprintlnPGM(const char *str);
120+
118121
bool is_buffer_empty();
119122
void process_commands();
120123
void ramming();

Firmware/Marlin_main.cpp

+10-16
Original file line numberDiff line numberDiff line change
@@ -467,22 +467,16 @@ void serial_echopair_P(const char *s_P, double v)
467467
void serial_echopair_P(const char *s_P, unsigned long v)
468468
{ serialprintPGM(s_P); SERIAL_ECHO(v); }
469469

470-
/*FORCE_INLINE*/ void serialprintPGM(const char *str)
471-
{
472-
#if 0
473-
char ch=pgm_read_byte(str);
474-
while(ch)
475-
{
476-
MYSERIAL.write(ch);
477-
ch=pgm_read_byte(++str);
478-
}
479-
#else
480-
// hmm, same size as the above version, the compiler did a good job optimizing the above
481-
while( uint8_t ch = pgm_read_byte(str) ){
482-
MYSERIAL.write((char)ch);
483-
++str;
484-
}
485-
#endif
470+
void serialprintPGM(const char *str) {
471+
while(uint8_t ch = pgm_read_byte(str)) {
472+
MYSERIAL.write((char)ch);
473+
++str;
474+
}
475+
}
476+
477+
void serialprintlnPGM(const char *str) {
478+
serialprintPGM(str);
479+
MYSERIAL.println();
486480
}
487481

488482
#ifdef SDSUPPORT

0 commit comments

Comments
 (0)