From e8dc1bb8684120aa0cd81ed49eb995d25ef674a7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 4 Aug 2012 16:13:25 +0100 Subject: [PATCH] eeprom: provide smaller code for SERIAL_ECHOPAIR 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 --- Marlin/Marlin.h | 6 +++++- Marlin/Marlin.pde | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index b465d85..8e833d1 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -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(PSTR(name),(value))) + +void serial_echopair(const PROGMEM char *s, float v); +void serial_echopair(const PROGMEM char *s, double v); +void serial_echopair(const PROGMEM char *s, unsigned long v); //things to write to serial from Programmemory. saves 400 to 2k of RAM. diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 05e7d5a..ba8b3b8 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -203,6 +203,13 @@ bool Stopped=false; void get_arc_coordinates(); +void serial_echopair(const PROGMEM char *s, float v) + { serialprintPGM(s); SERIAL_ECHO(v); } +void serial_echopair(const PROGMEM char *s, double v) + { serialprintPGM(s); SERIAL_ECHO(v); } +void serial_echopair(const PROGMEM char *s, unsigned long v) + { serialprintPGM(s); SERIAL_ECHO(v); } + extern "C"{ extern unsigned int __bss_end; extern unsigned int __heap_start; -- 2.30.2