Explorar el Código

Make the "ln" functions no-inline.

Save 348B of flash
Alex Voinea hace 2 años
padre
commit
97c371e5e8
Se han modificado 2 ficheros con 16 adiciones y 19 borrados
  1. 6 3
      Firmware/Marlin.h
  2. 10 16
      Firmware/Marlin_main.cpp

+ 6 - 3
Firmware/Marlin.h

@@ -79,9 +79,9 @@ extern FILE _uartout;
 #define SERIAL_PROTOCOL_F(x,y) (MYSERIAL.print(x,y))
 #define SERIAL_PROTOCOLPGM(x) (serialprintPGM(PSTR(x)))
 #define SERIAL_PROTOCOLRPGM(x) (serialprintPGM((x)))
-#define SERIAL_PROTOCOLLN(x) (MYSERIAL.println(x)/*,MYSERIAL.write('\n')*/)
-#define SERIAL_PROTOCOLLNPGM(x) (serialprintPGM(PSTR(x)),MYSERIAL.println()/*write('\n')*/)
-#define SERIAL_PROTOCOLLNRPGM(x) (serialprintPGM((x)),MYSERIAL.println()/*write('\n')*/)
+#define SERIAL_PROTOCOLLN(x) (MYSERIAL.println(x))
+#define SERIAL_PROTOCOLLNPGM(x) (serialprintlnPGM(PSTR(x)))
+#define SERIAL_PROTOCOLLNRPGM(x) (serialprintlnPGM((x)))
 
 
 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
 void serialprintPGM(const char *str);
 
+//The "ln" variant of the function above.
+void serialprintlnPGM(const char *str);
+
 bool is_buffer_empty();
 void process_commands();
 void ramming();

+ 10 - 16
Firmware/Marlin_main.cpp

@@ -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)
     { serialprintPGM(s_P); SERIAL_ECHO(v); }
 
-/*FORCE_INLINE*/ void serialprintPGM(const char *str)
-{
-#if 0
-  char ch=pgm_read_byte(str);
-  while(ch)
-  {
-    MYSERIAL.write(ch);
-    ch=pgm_read_byte(++str);
-  }
-#else
-	// 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
+void serialprintPGM(const char *str) {
+    while(uint8_t ch = pgm_read_byte(str)) {
+        MYSERIAL.write((char)ch);
+        ++str;
+    }
+}
+
+void serialprintlnPGM(const char *str) {
+    serialprintPGM(str);
+    MYSERIAL.println();
 }
 
 #ifdef SDSUPPORT