From 0a19109476fd9053a0e13df191342bc3604076de Mon Sep 17 00:00:00 2001
From: kieranc <kieranc@gmail.com>
Date: Tue, 10 Feb 2015 14:11:44 +0100
Subject: [PATCH 01/13] Enable PID debugging for heated bed

---
 Marlin/temperature.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp
index 9889e1fda5..6289288b45 100644
--- a/Marlin/temperature.cpp
+++ b/Marlin/temperature.cpp
@@ -647,6 +647,20 @@ void manage_heater()
     #else 
       pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
     #endif //PID_OPENLOOP
+        #ifdef PID_BED_DEBUG
+    SERIAL_ECHO_START;
+    SERIAL_ECHO(" PID_BED_DEBUG ");
+    SERIAL_ECHO(": Input ");
+    SERIAL_ECHO(pid_input);
+    SERIAL_ECHO(" Output ");
+    SERIAL_ECHO(pid_output);
+    SERIAL_ECHO(" pTerm ");
+    SERIAL_ECHO(pTerm_bed);
+    SERIAL_ECHO(" iTerm ");
+    SERIAL_ECHO(iTerm_bed);
+    SERIAL_ECHO(" dTerm ");
+    SERIAL_ECHOLN(dTerm_bed);
+    #endif //PID_BED_DEBUG
 
 	  if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) 
 	  {

From b9ed873827f03482bc5cca12efd4a8cb8b301604 Mon Sep 17 00:00:00 2001
From: kieranc <kieranc@gmail.com>
Date: Tue, 10 Feb 2015 14:13:06 +0100
Subject: [PATCH 02/13] Enable PID debugging for heated bed

---
 Marlin/Configuration.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 9b422a812c..b9f31540bb 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -218,6 +218,8 @@ Here are some standard links for getting your machine calibrated:
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
 #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)

From 1c71e4751a157bfc1c5df1aff5d08aeee7ae98af Mon Sep 17 00:00:00 2001
From: kieranc <kieranc@gmail.com>
Date: Mon, 23 Feb 2015 09:39:07 +0100
Subject: [PATCH 03/13] Enable PID debugging for heated bed

---
 Marlin/example_configurations/Hephestos/Configuration.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h
index 2823f2d95c..7025a33b8e 100644
--- a/Marlin/example_configurations/Hephestos/Configuration.h
+++ b/Marlin/example_configurations/Hephestos/Configuration.h
@@ -224,6 +224,8 @@ Here are some standard links for getting your machine calibrated:
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
 #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)

From c89413db1e4c0551e05050bd6a3229f7706aaa6c Mon Sep 17 00:00:00 2001
From: kieranc <kieranc@gmail.com>
Date: Mon, 23 Feb 2015 09:39:39 +0100
Subject: [PATCH 04/13] Enable PID debugging for heated bed

---
 Marlin/example_configurations/K8200/Configuration.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h
index 06e944b194..3eef687360 100644
--- a/Marlin/example_configurations/K8200/Configuration.h
+++ b/Marlin/example_configurations/K8200/Configuration.h
@@ -225,6 +225,8 @@ Here are some standard links for getting your machine calibrated:
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
 #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)

From 08c543f8fb7af47e74f0fa7c56a09730216a993b Mon Sep 17 00:00:00 2001
From: kieranc <kieranc@gmail.com>
Date: Mon, 23 Feb 2015 09:40:06 +0100
Subject: [PATCH 05/13] Enable PID debugging for heated bed

---
 Marlin/example_configurations/SCARA/Configuration.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h
index 8bc4eb70e9..c4d54cdde3 100644
--- a/Marlin/example_configurations/SCARA/Configuration.h
+++ b/Marlin/example_configurations/SCARA/Configuration.h
@@ -245,6 +245,8 @@ Here are some standard links for getting your machine calibrated:
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
 #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)

From fb56aad8984f995d08bf798bab7e43b38504d632 Mon Sep 17 00:00:00 2001
From: kieranc <kieranc@gmail.com>
Date: Mon, 23 Feb 2015 09:40:29 +0100
Subject: [PATCH 06/13] Enable PID debugging for heated bed

---
 Marlin/example_configurations/WITBOX/Configuration.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h
index 4a12bda515..547bef050b 100644
--- a/Marlin/example_configurations/WITBOX/Configuration.h
+++ b/Marlin/example_configurations/WITBOX/Configuration.h
@@ -227,6 +227,8 @@ Here are some standard links for getting your machine calibrated:
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
 #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)

From 21bd4fd6dbe1093ee3463d6f2d1993f16f99794a Mon Sep 17 00:00:00 2001
From: kieranc <kieranc@gmail.com>
Date: Mon, 23 Feb 2015 09:40:53 +0100
Subject: [PATCH 07/13] Enable PID debugging for heated bed

---
 Marlin/example_configurations/delta/Configuration.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Marlin/example_configurations/delta/Configuration.h b/Marlin/example_configurations/delta/Configuration.h
index 3eb268041a..c33f2f9582 100644
--- a/Marlin/example_configurations/delta/Configuration.h
+++ b/Marlin/example_configurations/delta/Configuration.h
@@ -242,6 +242,8 @@ Here are some standard links for getting your machine calibrated:
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
 #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)

From 29097b0ab228840090d9be0364cfa1d1fd4ef0df Mon Sep 17 00:00:00 2001
From: kieranc <kieranc@gmail.com>
Date: Mon, 23 Feb 2015 09:41:25 +0100
Subject: [PATCH 08/13] Enable PID debugging for heated bed

---
 Marlin/example_configurations/makibox/Configuration.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h
index 99feceba8c..788f3b2271 100644
--- a/Marlin/example_configurations/makibox/Configuration.h
+++ b/Marlin/example_configurations/makibox/Configuration.h
@@ -225,6 +225,8 @@ Here are some standard links for getting your machine calibrated:
 // to increase the heat up rate. However, if changed, user must be aware of the safety concerns
 // of drawing too much current from the power supply.
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)

From 8ccdac9898ca1c724e076ce1de6e4fd2fe4ad622 Mon Sep 17 00:00:00 2001
From: kieranc <kieranc@gmail.com>
Date: Mon, 23 Feb 2015 09:42:01 +0100
Subject: [PATCH 09/13] Enable PID debugging for heated bed

---
 Marlin/example_configurations/tvrrug/Round2/Configuration.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h
index 4ca415d8ff..f12fd01caa 100644
--- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h
+++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h
@@ -228,6 +228,8 @@ Here are some standard links for getting your machine calibrated:
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
 #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)

From 72a9fed4fb392319b5a34bfb36857538443c4103 Mon Sep 17 00:00:00 2001
From: AnHardt <github@kitelab.de>
Date: Wed, 18 Mar 2015 11:41:14 +0100
Subject: [PATCH 10/13] codepos not used in gcode_M28()

Got:
Marlin_main.cpp:2567: warning: unused variable 'codepos'

Needs revision.
Don't now how this should look like.
---
 Marlin/Marlin_main.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp
index 5ad45ef2ec..e5e548c526 100644
--- a/Marlin/Marlin_main.cpp
+++ b/Marlin/Marlin_main.cpp
@@ -2564,7 +2564,7 @@ inline void gcode_M17() {
    * M28: Start SD Write
    */
   inline void gcode_M28() {
-    char* codepos = strchr_pointer + 4;
+//    char* codepos = strchr_pointer + 4; // ??? not used ???
     char* starpos = strchr(strchr_pointer + 4, '*');
     if (starpos) {
       char* npos = strchr(cmdbuffer[bufindr], 'N');

From ae01a6b5f2c7236ee8b6ba4b2b14c33e3e17fddb Mon Sep 17 00:00:00 2001
From: AnHardt <github@kitelab.de>
Date: Thu, 19 Mar 2015 09:45:16 +0100
Subject: [PATCH 11/13] Make use of codepos.

Saves one addition.
Needs one pointer on the stack.

Don't know if this is a go trade.
---
 Marlin/Marlin_main.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp
index e5e548c526..5527cebb61 100644
--- a/Marlin/Marlin_main.cpp
+++ b/Marlin/Marlin_main.cpp
@@ -2564,14 +2564,14 @@ inline void gcode_M17() {
    * M28: Start SD Write
    */
   inline void gcode_M28() {
-//    char* codepos = strchr_pointer + 4; // ??? not used ???
-    char* starpos = strchr(strchr_pointer + 4, '*');
+    char* codepos = strchr_pointer + 4;
+    char* starpos = strchr(codepos, '*');
     if (starpos) {
       char* npos = strchr(cmdbuffer[bufindr], 'N');
       strchr_pointer = strchr(npos, ' ') + 1;
       *(starpos) = '\0';
     }
-    card.openFile(strchr_pointer + 4, false);
+    card.openFile(codepos, false);
   }
 
   /**

From fa889cd6e142167e24c45656400397b4251ad0ee Mon Sep 17 00:00:00 2001
From: AnHardt <github@kitelab.de>
Date: Thu, 19 Mar 2015 22:13:37 +0100
Subject: [PATCH 12/13] Beautivy statusscreen

by shifting things some pixels around
---
 Marlin/dogm_lcd_implementation.h | 33 ++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h
index b60d689363..aecec0109b 100644
--- a/Marlin/dogm_lcd_implementation.h
+++ b/Marlin/dogm_lcd_implementation.h
@@ -197,7 +197,7 @@ static void lcd_implementation_status_screen() {
       u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2);
     }
 
-    u8g.setPrintPos(80,47);
+    u8g.setPrintPos(80,48);
     if (starttime != 0) {
       uint16_t time = (millis() - starttime) / 60000;
       u8g.print(itostr2(time/60));
@@ -231,26 +231,27 @@ static void lcd_implementation_status_screen() {
     }
 
   // X, Y, Z-Coordinates
+  #define XYZ_BASELINE 38
   u8g.setFont(FONT_STATUSMENU);
-  u8g.drawBox(0,29,128,10);
+  u8g.drawBox(0,30,128,9);
   u8g.setColorIndex(0); // white on black
-  u8g.setPrintPos(2,37);
+  u8g.setPrintPos(2,XYZ_BASELINE);
   u8g.print("X");
-  u8g.drawPixel(8,33);
-  u8g.drawPixel(8,35);
-  u8g.setPrintPos(10,37);
+  u8g.drawPixel(8,XYZ_BASELINE - 5);
+  u8g.drawPixel(8,XYZ_BASELINE - 3);
+  u8g.setPrintPos(10,XYZ_BASELINE);
   u8g.print(ftostr31ns(current_position[X_AXIS]));
-  u8g.setPrintPos(43,37);
+  u8g.setPrintPos(43,XYZ_BASELINE);
   lcd_printPGM(PSTR("Y"));
-  u8g.drawPixel(49,33);
-  u8g.drawPixel(49,35);
-  u8g.setPrintPos(51,37);
+  u8g.drawPixel(49,XYZ_BASELINE - 5);
+  u8g.drawPixel(49,XYZ_BASELINE - 3);
+  u8g.setPrintPos(51,XYZ_BASELINE);
   u8g.print(ftostr31ns(current_position[Y_AXIS]));
-  u8g.setPrintPos(83,37);
+  u8g.setPrintPos(83,XYZ_BASELINE);
   u8g.print("Z");
-  u8g.drawPixel(89,33);
-  u8g.drawPixel(89,35);
-  u8g.setPrintPos(91,37);
+  u8g.drawPixel(89,XYZ_BASELINE - 5);
+  u8g.drawPixel(89,XYZ_BASELINE - 3);
+  u8g.setPrintPos(91,XYZ_BASELINE);
   u8g.print(ftostr31(current_position[Z_AXIS]));
   u8g.setColorIndex(1); // black on white
  
@@ -259,13 +260,13 @@ static void lcd_implementation_status_screen() {
   u8g.setPrintPos(3,49);
   u8g.print(LCD_STR_FEEDRATE[0]);
   u8g.setFont(FONT_STATUSMENU);
-  u8g.setPrintPos(12,48);
+  u8g.setPrintPos(12,49);
   u8g.print(itostr3(feedmultiply));
   u8g.print('%');
 
   // Status line
   u8g.setFont(FONT_STATUSMENU);
-  u8g.setPrintPos(0,61);
+  u8g.setPrintPos(0,63);
   #ifndef FILAMENT_LCD_DISPLAY
     u8g.print(lcd_status_message);
   #else

From e85061d20d952e8aed894daff91894d5eebc4f0e Mon Sep 17 00:00:00 2001
From: AnHardt <github@kitelab.de>
Date: Fri, 20 Mar 2015 10:36:29 +0100
Subject: [PATCH 13/13] Added changes to the 'new' Configuration.h s

---
 Marlin/configurator/config/Configuration.h                      | 2 ++
 Marlin/example_configurations/Felix/Configuration.h             | 2 ++
 Marlin/example_configurations/Felix/Configuration_DUAL.h        | 2 ++
 Marlin/example_configurations/delta/kossel_mini/Configuration.h | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/Marlin/configurator/config/Configuration.h b/Marlin/configurator/config/Configuration.h
index 89bfe5c18f..57ec74f9be 100644
--- a/Marlin/configurator/config/Configuration.h
+++ b/Marlin/configurator/config/Configuration.h
@@ -234,6 +234,8 @@ Here are some standard links for getting your machine calibrated:
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
 #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h
index 12a82f5899..17da67953b 100644
--- a/Marlin/example_configurations/Felix/Configuration.h
+++ b/Marlin/example_configurations/Felix/Configuration.h
@@ -215,6 +215,8 @@ Here are some standard links for getting your machine calibrated:
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
 #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 // Felix Foil Heater
    #define DEFAULT_bedKp 103.37
diff --git a/Marlin/example_configurations/Felix/Configuration_DUAL.h b/Marlin/example_configurations/Felix/Configuration_DUAL.h
index 9b1f10263e..9766961a50 100644
--- a/Marlin/example_configurations/Felix/Configuration_DUAL.h
+++ b/Marlin/example_configurations/Felix/Configuration_DUAL.h
@@ -215,6 +215,8 @@ Here are some standard links for getting your machine calibrated:
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
 #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 // Felix Foil Heater
    #define DEFAULT_bedKp 103.37
diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h
index 22db0e955a..1ff5c482eb 100644
--- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h
+++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h
@@ -259,6 +259,8 @@ Here are some standard links for getting your machine calibrated:
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
 #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
 
+//#define PID_BED_DEBUG // Sends debug data to the serial port.
+
 #ifdef PIDTEMPBED
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)