Make the "ln" functions no-inline.

Save 348B of flash
This commit is contained in:
Alex Voinea 2022-02-27 20:55:40 +01:00
parent af36f654d1
commit 97c371e5e8
2 changed files with 16 additions and 19 deletions

View File

@ -79,9 +79,9 @@ extern FILE _uartout;
#define SERIAL_PROTOCOL_F(x,y) (MYSERIAL.print(x,y)) #define SERIAL_PROTOCOL_F(x,y) (MYSERIAL.print(x,y))
#define SERIAL_PROTOCOLPGM(x) (serialprintPGM(PSTR(x))) #define SERIAL_PROTOCOLPGM(x) (serialprintPGM(PSTR(x)))
#define SERIAL_PROTOCOLRPGM(x) (serialprintPGM((x))) #define SERIAL_PROTOCOLRPGM(x) (serialprintPGM((x)))
#define SERIAL_PROTOCOLLN(x) (MYSERIAL.println(x)/*,MYSERIAL.write('\n')*/) #define SERIAL_PROTOCOLLN(x) (MYSERIAL.println(x))
#define SERIAL_PROTOCOLLNPGM(x) (serialprintPGM(PSTR(x)),MYSERIAL.println()/*write('\n')*/) #define SERIAL_PROTOCOLLNPGM(x) (serialprintlnPGM(PSTR(x)))
#define SERIAL_PROTOCOLLNRPGM(x) (serialprintPGM((x)),MYSERIAL.println()/*write('\n')*/) #define SERIAL_PROTOCOLLNRPGM(x) (serialprintlnPGM((x)))
extern const char errormagic[] PROGMEM; extern const char errormagic[] PROGMEM;
@ -115,6 +115,9 @@ void serial_echopair_P(const char *s_P, unsigned long v);
// I'd rather skip a few CPU ticks than 5.5KB (!!) of FLASH // I'd rather skip a few CPU ticks than 5.5KB (!!) of FLASH
void serialprintPGM(const char *str); void serialprintPGM(const char *str);
//The "ln" variant of the function above.
void serialprintlnPGM(const char *str);
bool is_buffer_empty(); bool is_buffer_empty();
void process_commands(); void process_commands();
void ramming(); void ramming();

View File

@ -467,22 +467,16 @@ void serial_echopair_P(const char *s_P, double v)
void serial_echopair_P(const char *s_P, unsigned long v) void serial_echopair_P(const char *s_P, unsigned long v)
{ serialprintPGM(s_P); SERIAL_ECHO(v); } { serialprintPGM(s_P); SERIAL_ECHO(v); }
/*FORCE_INLINE*/ void serialprintPGM(const char *str) void serialprintPGM(const char *str) {
{ while(uint8_t ch = pgm_read_byte(str)) {
#if 0 MYSERIAL.write((char)ch);
char ch=pgm_read_byte(str); ++str;
while(ch) }
{ }
MYSERIAL.write(ch);
ch=pgm_read_byte(++str); void serialprintlnPGM(const char *str) {
} serialprintPGM(str);
#else MYSERIAL.println();
// hmm, same size as the above version, the compiler did a good job optimizing the above
while( uint8_t ch = pgm_read_byte(str) ){
MYSERIAL.write((char)ch);
++str;
}
#endif
} }
#ifdef SDSUPPORT #ifdef SDSUPPORT