chiark / gitweb /
Refresh of eeprom-provide-smaller-code-fo
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 8 Aug 2012 16:55:40 +0000 (17:55 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 8 Aug 2012 16:55:40 +0000 (17:55 +0100)
Marlin/EEPROMwrite.h
Marlin/Marlin.h
Marlin/Marlin.pde

index 96791c7148ebb8ce2adca13769b548e1c348cbf1..96e2ec9856e5b63421ab0be59f052a3a2723d045 100644 (file)
@@ -75,34 +75,25 @@ inline void EEPROM_StoreSettings()
 }
 
 
-static void serial_echopair_double(const PROGMEM char *s, double v) {
-      serialprintPGM(s);
-      SERIAL_ECHO(v);
-}
-
-#define SERIAL_ECHOPAIR_DOUBLE(s,v) \
-  ((void)(&(v) == &acceleration), /* type check */ \
-   serial_echopair_double(PSTR(s),(v)))
-
 inline void EEPROM_printSettings()
 {  // if def=true, the default values will be used
   #ifdef EEPROM_SETTINGS  
       SERIAL_ECHO_START;
       SERIAL_ECHOLNPGM("Steps per unit:");
       SERIAL_ECHO_START;
-      SERIAL_ECHOPAIR_DOUBLE("  M92 X",axis_steps_per_unit[0]);
-      SERIAL_ECHOPAIR_DOUBLE(" Y",axis_steps_per_unit[1]);
-      SERIAL_ECHOPAIR_DOUBLE(" Z",axis_steps_per_unit[2]);
-      SERIAL_ECHOPAIR_DOUBLE(" E",axis_steps_per_unit[3]);
+      SERIAL_ECHOPAIR("  M92 X",axis_steps_per_unit[0]);
+      SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[1]);
+      SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[2]);
+      SERIAL_ECHOPAIR(" E",axis_steps_per_unit[3]);
       SERIAL_ECHOLN("");
       
     SERIAL_ECHO_START;
       SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
       SERIAL_ECHO_START;
-      SERIAL_ECHOPAIR_DOUBLE("  M203 X",max_feedrate[0]);
-      SERIAL_ECHOPAIR_DOUBLE(" Y",max_feedrate[1] ); 
-      SERIAL_ECHOPAIR_DOUBLE(" Z", max_feedrate[2] ); 
-      SERIAL_ECHOPAIR_DOUBLE(" E", max_feedrate[3]);
+      SERIAL_ECHOPAIR("  M203 X",max_feedrate[0]);
+      SERIAL_ECHOPAIR(" Y",max_feedrate[1] ); 
+      SERIAL_ECHOPAIR(" Z", max_feedrate[2] ); 
+      SERIAL_ECHOPAIR(" E", max_feedrate[3]);
       SERIAL_ECHOLN("");
     SERIAL_ECHO_START;
       SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
@@ -115,24 +106,24 @@ inline void EEPROM_printSettings()
     SERIAL_ECHO_START;
       SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration");
       SERIAL_ECHO_START;
-      SERIAL_ECHOPAIR_DOUBLE("  M204 S",acceleration ); 
-      SERIAL_ECHOPAIR_DOUBLE(" T" ,retract_acceleration);
+      SERIAL_ECHOPAIR("  M204 S",acceleration ); 
+      SERIAL_ECHOPAIR(" T" ,retract_acceleration);
       SERIAL_ECHOLN("");
     SERIAL_ECHO_START;
       SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum xY jerk (mm/s),  Z=maximum Z jerk (mm/s)");
       SERIAL_ECHO_START;
-      SERIAL_ECHOPAIR_DOUBLE("  M205 S",minimumfeedrate ); 
-      SERIAL_ECHOPAIR_DOUBLE(" T" ,mintravelfeedrate ); 
+      SERIAL_ECHOPAIR("  M205 S",minimumfeedrate ); 
+      SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); 
       SERIAL_ECHOPAIR(" B" ,minsegmenttime ); 
-      SERIAL_ECHOPAIR_DOUBLE(" X" ,max_xy_jerk ); 
-      SERIAL_ECHOPAIR_DOUBLE(" Z" ,max_z_jerk);
-      SERIAL_ECHOPAIR_DOUBLE(" E" ,max_e_jerk);
+      SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); 
+      SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
+      SERIAL_ECHOPAIR(" E" ,max_e_jerk);
       SERIAL_ECHOLN(""); 
     #ifdef PIDTEMP
       SERIAL_ECHO_START;
       SERIAL_ECHOLNPGM("PID settings:");
       SERIAL_ECHO_START;
-      SERIAL_ECHOPAIR_DOUBLE("   M301 P",Kp); 
+      SERIAL_ECHOPAIR("   M301 P",Kp); 
       SERIAL_ECHOPAIR(" I" ,Ki/PID_dT); 
       SERIAL_ECHOPAIR(" D" ,Kd*PID_dT);
       SERIAL_ECHOLN(""); 
index c8115af4114f39850be31991dab2e23c2abde063..a78d2ee847494a13de129f8519c1f9e9ec1eeb3a 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(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.
index 9f8e98c249422caa2d2f618b8cb4ae7cc10a45f1..d0c8d795da30c3402ae994a87538c6319afcbaab 100644 (file)
@@ -200,6 +200,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;