chiark / gitweb /
eeprom: provide smaller code for SERIAL_ECHOPAIR
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Aug 2012 15:13:25 +0000 (16:13 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 11 Aug 2012 00:35:52 +0000 (01:35 +0100)
SERIAL_ECHOPAIR implies, eventually, two calls to MYSERIAL.print.  One
of these has FORCE_INLINE for a per-character loop, and both involve
constructing a method call rather than a simple function call.

Produce better and smaller code by providing three specialised
functions serial_echopair.  This saves 672 bytes of program memory
(with EEPROM_SETTINGS and SDSUPPORT enabled).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Marlin/Marlin.h
Marlin/Marlin.pde

index b465d8535ad41b6f9131ef8d76861da21bfe08d5..208ac3303366a7486cb3aec9978116fcaabcd7cf 100644 (file)
@@ -84,7 +84,11 @@ const char echomagic[] PROGMEM ="echo:";
 #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
 #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
 
-#define SERIAL_ECHOPAIR(name,value) {SERIAL_ECHOPGM(name);SERIAL_ECHO(value);}
+#define SERIAL_ECHOPAIR(name,value) (serial_echopair_P(PSTR(name),(value)))
+
+void serial_echopair_P(const char *s_P, float v);
+void serial_echopair_P(const char *s_P, double v);
+void serial_echopair_P(const char *s_P, unsigned long v);
 
 
 //things to write to serial from Programmemory. saves 400 to 2k of RAM.
index c1532980f7fc6515d89524957c804420371586ef..bb7c6f29cfb1af4dcb6117168a15a52d84074fbe 100644 (file)
@@ -203,6 +203,13 @@ bool Stopped=false;
 
 void get_arc_coordinates();
 
+void serial_echopair_P(const char *s_P, float v)
+    { serialprintPGM(s_P); SERIAL_ECHO(v); }
+void serial_echopair_P(const char *s_P, double v)
+    { serialprintPGM(s_P); SERIAL_ECHO(v); }
+void serial_echopair_P(const char *s_P, unsigned long v)
+    { serialprintPGM(s_P); SERIAL_ECHO(v); }
+
 extern "C"{
   extern unsigned int __bss_end;
   extern unsigned int __heap_start;