From 42824b0e1f3747393c64b05ec7a186afec5bf82d Mon Sep 17 00:00:00 2001
From: Scott Lahteine <github@thinkyhead.com>
Date: Sun, 30 Apr 2017 18:36:40 -0500
Subject: [PATCH] Use new serial spacing function to save PROGMEM

---
 Marlin/pinsDebug.h | 32 ++++++++++++++++++++++----------
 Marlin/ubl.cpp     |  6 +++---
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/Marlin/pinsDebug.h b/Marlin/pinsDebug.h
index a40d1480df..0d73f95ba0 100644
--- a/Marlin/pinsDebug.h
+++ b/Marlin/pinsDebug.h
@@ -409,11 +409,17 @@ static void pwm_details(uint8_t pin) {
     // looking for port B7 - PWMs 0A and 1C
     if ( ('B' == digitalPinToPort(pin) + 64) && (0x80 == digitalPinToBitMask(pin))) {
       #ifndef TEENSYDUINO_IDE
-        SERIAL_PROTOCOLPGM("\n .                  TIMER1C is also tied to this pin             ");
-        timer_prefix(1,'C',4);
+        SERIAL_PROTOCOLPGM("\n .");
+        SERIAL_PROTOCOL_SP(18);
+        SERIAL_PROTOCOLPGM("TIMER1C is also tied to this pin");
+        SERIAL_PROTOCOL_SP(13);
+        timer_prefix(1, 'C', 4);
       #else
-        SERIAL_PROTOCOLPGM("\n .                  TIMER0A is also tied to this pin             ");
-        timer_prefix(0,'A',3);
+        SERIAL_PROTOCOLPGM("\n .");
+        SERIAL_PROTOCOL_SP(18);
+        SERIAL_PROTOCOLPGM("TIMER0A is also tied to this pin");
+        SERIAL_PROTOCOL_SP(13);
+        timer_prefix(0, 'A', 3);
       #endif
     }
   #endif
@@ -437,7 +443,7 @@ void print_port(int8_t pin) {   // print port number
     for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1;
     SERIAL_CHAR(x);
   #else
-    SERIAL_PROTOCOLPGM("          ");
+    SERIAL_PROTOCOL_SP(10);
   #endif
 }
 
@@ -460,7 +466,11 @@ inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = t
           sprintf(buffer, " (A%2d)  ", int(pin - analogInputToDigitalPin(0)));    // analog pin number
           SERIAL_ECHO(buffer);
         }
-        else SERIAL_ECHOPGM("        ");   // add padding if not an analog pin
+        else SERIAL_ECHO_SP(8);   // add padding if not an analog pin
+      }
+      else {
+        SERIAL_CHAR('.');
+        SERIAL_ECHO_SP(25);  // add padding if not the first instance found
       }
       else SERIAL_ECHOPGM(".                         ");  // add padding if not the first instance found
       name_mem_pointer = (char*) pgm_read_word(&pin_array[x][0]);
@@ -506,17 +516,19 @@ inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = t
       SERIAL_ECHO(buffer);
     }
     else
-      SERIAL_ECHOPGM("        ");   // add padding if not an analog pin
+      SERIAL_ECHO_SP(8);   // add padding if not an analog pin
     SERIAL_ECHOPGM("<unused/unknown>");
-    if (get_pinMode(pin))
-      SERIAL_PROTOCOLPAIR("            Output = ", digitalRead_mod(pin));
+    if (get_pinMode(pin)) {
+      SERIAL_PROTOCOL_SP(12);
+      SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin));
+    }
     else {
       if (IS_ANALOG(pin)) {
         sprintf(buffer, "   Analog in = %5d", analogRead(pin - analogInputToDigitalPin(0)));
         SERIAL_ECHO(buffer);
       }
       else
-        SERIAL_ECHOPGM("         ");   // add padding if not an analog pin
+        SERIAL_ECHO_SP(9);   // add padding if not an analog pin
 
       SERIAL_PROTOCOLPAIR("   Input  = ", digitalRead_mod(pin));
     }
diff --git a/Marlin/ubl.cpp b/Marlin/ubl.cpp
index 8d8676bf7f..c76aa80fec 100755
--- a/Marlin/ubl.cpp
+++ b/Marlin/ubl.cpp
@@ -52,7 +52,7 @@
 
   static void serial_echo_12x_spaces() {
     for (uint8_t i = GRID_MAX_POINTS_X - 1; --i;) {
-      SERIAL_ECHOPGM("            ");
+      SERIAL_ECHO_SP(12);
       safe_delay(10);
     }
   }
@@ -201,12 +201,12 @@
 
     if (map0) {
       serial_echo_xy(UBL_MESH_MIN_X, UBL_MESH_MIN_Y);
-      SERIAL_ECHOPGM("    ");
+      SERIAL_ECHO_SP(4);
       serial_echo_12x_spaces();
       serial_echo_xy(UBL_MESH_MAX_X, UBL_MESH_MIN_Y);
       SERIAL_EOL;
       serial_echo_xy(0, 0);
-      SERIAL_ECHOPGM("       ");
+      SERIAL_ECHO_SP(7);
       serial_echo_12x_spaces();
       serial_echo_xy(GRID_MAX_POINTS_X - 1, 0);
       SERIAL_EOL;