From 3cbaad9288fd6fe6d010cc3b4039dbffa863e31b Mon Sep 17 00:00:00 2001
From: Jonathan Bastien-Filiatrault <joe@x2a.org>
Date: Tue, 6 Nov 2012 20:32:13 -0500
Subject: [PATCH 1/5] RepRapDiscount Smart Controller pin definitions.

---
 Marlin/Configuration.h |  7 ++++++-
 Marlin/pins.h          | 17 +++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index fbce0eef2..2c6bf3982 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -296,8 +296,13 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
 //#define ULTIMAKERCONTROLLER //as available from the ultimaker online store.
 //#define ULTIPANEL  //the ultipanel as on thingiverse
 
+// The RepRapDiscount Smart Controller
+// http://reprap.org/wiki/RepRapDiscount_Smart_Controller
+//#define REPRAPDISCOUNTSC
 
-#ifdef ULTIMAKERCONTROLLER    //automatic expansion
+
+//automatic expansion
+#if defined(ULTIMAKERCONTROLLER) || defined(REPRAPDISCOUNTSC)
  #define ULTIPANEL
  #define NEWPANEL
 #endif 
diff --git a/Marlin/pins.h b/Marlin/pins.h
index fd79dc6e0..f968da807 100644
--- a/Marlin/pins.h
+++ b/Marlin/pins.h
@@ -405,6 +405,23 @@
     #define encrot2 3
     #define encrot3 1
 
+    #ifdef REPRAPDISCOUNTSC
+      // Override partially the above definitions
+      #define KILL_PIN 41
+      #define LCD_PINS_RS 16
+      #define LCD_PINS_ENABLE 17
+      #define LCD_PINS_D4 23
+      #define LCD_PINS_D5 25
+      #define LCD_PINS_D6 27
+      #define LCD_PINS_D7 29
+
+      #define BTN_EN1 31
+      #define BTN_EN2 33
+      #define BTN_ENC 35
+      #define BEEPER 37
+      #define SDCARDDETECT 49
+    #endif
+
   #else //old style panel with shift register
     //arduino pin witch triggers an piezzo beeper
     #define BEEPER 33		No Beeper added

From 9606f4d04f3049d1eb1de7ac0f179b6bbd940be9 Mon Sep 17 00:00:00 2001
From: Jonathan Bastien-Filiatrault <joe@x2a.org>
Date: Tue, 6 Nov 2012 20:18:26 -0500
Subject: [PATCH 2/5] Include Marlin_main.cpp in source files.

---
 Marlin/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Marlin/Makefile b/Marlin/Makefile
index 275c9c088..ea8b7bde6 100644
--- a/Marlin/Makefile
+++ b/Marlin/Makefile
@@ -89,10 +89,10 @@ SRC =  pins_arduino.c wiring.c \
 	wiring_analog.c wiring_digital.c \
 	wiring_pulse.c \
 	wiring_shift.c WInterrupts.c
-CXXSRC = WMath.cpp WString.cpp Print.cpp \
-	Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp \
-	SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp \
-	planner.cpp stepper.cpp temperature.cpp cardreader.cpp
+CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin.cpp Marlin_main.cpp	\
+	MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp	\
+	SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp		\
+	stepper.cpp temperature.cpp cardreader.cpp
 #CXXSRC += LiquidCrystal.cpp ultralcd.cpp
 #CXXSRC += ultralcd.cpp
 FORMAT = ihex

From 36b452c7ac88e360e0c3c7555eaea46dd27271f1 Mon Sep 17 00:00:00 2001
From: Jonathan Bastien-Filiatrault <joe@x2a.org>
Date: Wed, 7 Nov 2012 15:42:18 -0500
Subject: [PATCH 3/5] Remove abbrs.

---
 Marlin/Configuration.h | 2 +-
 Marlin/pins.h          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 2c6bf3982..742f33d9f 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -298,7 +298,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
 
 // The RepRapDiscount Smart Controller
 // http://reprap.org/wiki/RepRapDiscount_Smart_Controller
-//#define REPRAPDISCOUNTSC
+//#define REPRAP_DISCOUNT_SMART_CONTROLLER
 
 
 //automatic expansion
diff --git a/Marlin/pins.h b/Marlin/pins.h
index f968da807..a14db4702 100644
--- a/Marlin/pins.h
+++ b/Marlin/pins.h
@@ -405,7 +405,7 @@
     #define encrot2 3
     #define encrot3 1
 
-    #ifdef REPRAPDISCOUNTSC
+    #ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
       // Override partially the above definitions
       #define KILL_PIN 41
       #define LCD_PINS_RS 16

From 0f73afb0b0df433e4a3cb00d6425df4e4ecc39b4 Mon Sep 17 00:00:00 2001
From: Jonathan Bastien-Filiatrault <joe@x2a.org>
Date: Wed, 7 Nov 2012 16:04:28 -0500
Subject: [PATCH 4/5] Avoid defining overriding definitions for the
 RepRapDiscount Smart Controller. Remove common definitions. Harmonize
 declaration order.

---
 Marlin/pins.h | 54 +++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 28 deletions(-)

diff --git a/Marlin/pins.h b/Marlin/pins.h
index a14db4702..9723e3623 100644
--- a/Marlin/pins.h
+++ b/Marlin/pins.h
@@ -360,7 +360,12 @@
 #define FAN_PIN            4 // IO pin. Buffer needed
 #endif
 #define PS_ON_PIN          12
+
+#ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
+#define KILL_PIN           41
+#else
 #define KILL_PIN           -1
+#endif
 
 #define HEATER_0_PIN       10   // EXTRUDER 1
 #if MOTHERBOARD == 33
@@ -378,8 +383,15 @@
 #ifdef ULTRA_LCD
 
   #ifdef NEWPANEL
-  //arduino pin which triggers an piezzo beeper
-    #define BEEPER 33			// Beeper on AUX-4
+     //encoder rotation values
+    #define encrot0 0
+    #define encrot1 2
+    #define encrot2 3
+    #define encrot3 1
+
+    #define BLEN_A 0
+    #define BLEN_B 1
+    #define BLEN_C 2
 
     #define LCD_PINS_RS 16 
     #define LCD_PINS_ENABLE 17
@@ -388,38 +400,24 @@
     #define LCD_PINS_D6 27
     #define LCD_PINS_D7 29
     
-    //buttons are directly attached using AUX-2
-    #define BTN_EN1 37
-    #define BTN_EN2 35
-    #define BTN_ENC 31  //the click
-    
-    #define BLEN_C 2
-    #define BLEN_B 1
-    #define BLEN_A 0
-    
-    #define SDCARDDETECT -1		// Ramps does not use this port
-    
-      //encoder rotation values
-    #define encrot0 0
-    #define encrot1 2
-    #define encrot2 3
-    #define encrot3 1
-
     #ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
-      // Override partially the above definitions
-      #define KILL_PIN 41
-      #define LCD_PINS_RS 16
-      #define LCD_PINS_ENABLE 17
-      #define LCD_PINS_D4 23
-      #define LCD_PINS_D5 25
-      #define LCD_PINS_D6 27
-      #define LCD_PINS_D7 29
+      #define BEEPER 37
 
       #define BTN_EN1 31
       #define BTN_EN2 33
       #define BTN_ENC 35
-      #define BEEPER 37
+
       #define SDCARDDETECT 49
+    #else
+      //arduino pin which triggers an piezzo beeper
+      #define BEEPER 33	 // Beeper on AUX-4
+
+      //buttons are directly attached using AUX-2
+      #define BTN_EN1 37
+      #define BTN_EN2 35
+      #define BTN_ENC 31  //the click
+
+      #define SDCARDDETECT -1  // Ramps does not use this port
     #endif
 
   #else //old style panel with shift register

From 46b9988e26d3e876f0d81ae64b4a1773a0b173f9 Mon Sep 17 00:00:00 2001
From: Jonathan Bastien-Filiatrault <joe@x2a.org>
Date: Wed, 7 Nov 2012 16:09:30 -0500
Subject: [PATCH 5/5] Search and replace failure.

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

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 742f33d9f..54435f646 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -302,7 +302,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
 
 
 //automatic expansion
-#if defined(ULTIMAKERCONTROLLER) || defined(REPRAPDISCOUNTSC)
+#if defined(ULTIMAKERCONTROLLER) || defined(REPRAP_DISCOUNT_SMART_CONTROLLER)
  #define ULTIPANEL
  #define NEWPANEL
 #endif