From 42e21bb06ed614a5b148329a38fab44724862cd1 Mon Sep 17 00:00:00 2001
From: Johann Rocholl <johann@rocholl.net>
Date: Sat, 8 Dec 2012 10:49:01 -0800
Subject: [PATCH] Add support for Printrboard (from
 https://github.com/lincomatic/Marlin) and Brainwave (from
 https://github.com/metrix/Sprinter).

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

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 4aff7fe099..9db8dee5f4 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -37,6 +37,8 @@
 // 7  = Ultimaker
 // 71 = Ultimaker (Older electronics. Pre 1.5.4. This is rare)
 // 8  = Teensylu
+// 81 = Printrboard (AT90USB1286)
+// 82 = Brainwave (AT90USB646)
 // 9  = Gen3+
 // 70 = Megatronics
 // 90 = Alpha OMCA board
diff --git a/Marlin/pins.h b/Marlin/pins.h
index febe2cd1f3..f61f534d04 100644
--- a/Marlin/pins.h
+++ b/Marlin/pins.h
@@ -1015,6 +1015,206 @@
 #endif
 #endif
 
+/****************************************************************************************
+* Printrboard Rev. B pin assingments (ATMEGA90USB1286)
+* Requires the Teensyduino software with Teensy++ 2.0 selected in arduino IDE!
+  http://www.pjrc.com/teensy/teensyduino.html
+* See http://reprap.org/wiki/Printrboard for more info
+****************************************************************************************/
+#if MOTHERBOARD == 81
+#define MOTHERBOARD 8  // Disable MarlinSerial etc.
+#define KNOWN_BOARD 1
+
+#ifndef __AVR_AT90USB1286__
+#error Oops!  Make sure you have 'Teensy++ 2.0' selected from the 'Tools -> Boards' menu.
+#endif
+
+#define X_STEP_PIN         28
+#define X_DIR_PIN          29
+#define X_ENABLE_PIN       19
+#define X_MIN_PIN          47
+#define X_MAX_PIN          -1
+
+#define Y_STEP_PIN         30
+#define Y_DIR_PIN          31
+#define Y_ENABLE_PIN       18
+#define Y_MIN_PIN           20
+#define Y_MAX_PIN          -1
+
+#define Z_STEP_PIN         32
+#define Z_DIR_PIN          33
+#define Z_ENABLE_PIN       17
+#define Z_MIN_PIN          36
+#define Z_MAX_PIN          -1
+
+#define E0_STEP_PIN         34
+#define E0_DIR_PIN          35
+#define E0_ENABLE_PIN       13
+
+#define HEATER_0_PIN       15  // Extruder
+#define HEATER_1_PIN       -1
+#define HEATER_2_PIN       -1
+#define HEATER_BED_PIN     14  // Bed
+#define FAN_PIN            16  // Fan
+
+#define TEMP_0_PIN          1  // Extruder - ANALOG PIN NUMBERING
+#define TEMP_1_PIN         -1
+#define TEMP_2_PIN         -1
+#define TEMP_BED_PIN        0  // Bed - ANALOG PIN NUMBERING
+
+#define SDPOWER            -1
+#define SDSS                26
+#define LED_PIN            -1
+#define PS_ON_PIN          -1
+#define KILL_PIN           -1
+
+#ifndef SDSUPPORT
+// these pins are defined in the SD library if building with SD support
+  #define SCK_PIN          21
+  #define MISO_PIN         22
+  #define MOSI_PIN         23
+#endif
+
+#ifdef ULTRA_LCD
+
+  #ifdef NEWPANEL
+  //arduino pin which triggers an piezzo beeper
+    #define BEEPER 33			// Beeper on AUX-4
+
+#ifndef MCP28017_LCD
+    #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
+#endif // MCP28017_LCD
+
+    //buttons are directly attached using AUX-2
+    #define BTN_EN1 11 // PC1
+    #define BTN_EN2 12 // PC2
+#ifndef VERSAPANEL
+    #define BTN_ENC 31  //the click
+#endif
+
+    #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
+
+  #else //old style panel with shift register
+    //arduino pin witch triggers an piezzo beeper
+    #define BEEPER 33		No Beeper added
+
+    //buttons are attached to a shift register
+	// Not wired this yet
+    //#define SHIFT_CLK 38
+    //#define SHIFT_LD 42
+    //#define SHIFT_OUT 40
+    //#define SHIFT_EN 17
+
+    #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
+
+    //encoder rotation values
+    #define encrot0 0
+    #define encrot1 2
+    #define encrot2 3
+    #define encrot3 1
+
+    //bits in the shift register that carry the buttons for:
+    // left up center down right red
+    #define BL_LE 7
+    #define BL_UP 6
+    #define BL_MI 5
+    #define BL_DW 4
+    #define BL_RI 3
+    #define BL_ST 2
+
+    #define BLEN_B 1
+    #define BLEN_A 0
+  #endif
+#endif //ULTRA_LCD
+
+#endif
+
+/****************************************************************************************
+ * Brainwave 1.0 pin assignments (AT90USB646)
+ * Requires hardware bundle for Arduino:
+   https://github.com/unrepentantgeek/brainwave-arduino
+ ****************************************************************************************/
+#if MOTHERBOARD == 82
+#define MOTHERBOARD 8  // Disable MarlinSerial etc.
+#define KNOWN_BOARD 1
+
+#ifndef __AVR_AT90USB646__
+#error Oops!  Make sure you have 'Brainwave' selected from the 'Tools -> Boards' menu.
+#endif
+
+#define X_STEP_PIN         27
+#define X_DIR_PIN          29
+#define X_ENABLE_PIN       28
+#define X_MIN_PIN           7
+#define X_MAX_PIN          -1
+#define X_ATT_PIN          26
+
+#define Y_STEP_PIN         31
+#define Y_DIR_PIN          33
+#define Y_ENABLE_PIN       32
+#define Y_MIN_PIN           6
+#define Y_MAX_PIN          -1
+#define Y_ATT_PIN          30
+
+#define Z_STEP_PIN         17
+#define Z_DIR_PIN          19
+#define Z_ENABLE_PIN       18
+#define Z_MIN_PIN           5
+#define Z_MAX_PIN          -1
+#define Z_ATT_PIN          16
+
+#define E0_STEP_PIN         21
+#define E0_DIR_PIN          23
+#define E0_ENABLE_PIN       22
+#define E0_ATT_PIN          20
+
+#define HEATER_0_PIN        4  // Extruder
+#define HEATER_1_PIN       -1
+#define HEATER_2_PIN       -1
+#define HEATER_BED_PIN     38  // Bed
+#define FAN_PIN             3  // Fan
+
+#define TEMP_0_PIN          7  // Extruder / Analog pin numbering
+#define TEMP_1_PIN         -1
+#define TEMP_2_PIN         -1
+#define TEMP_BED_PIN        6  // Bed / Analog pin numbering
+
+#define SDPOWER            -1
+#define SDSS               -1
+#define LED_PIN            39
+#define PS_ON_PIN          -1
+#define KILL_PIN           -1
+#define ALARM_PIN          -1
+
+#ifndef SDSUPPORT
+// these pins are defined in the SD library if building with SD support
+  #define SCK_PIN          21
+  #define MISO_PIN         22
+  #define MOSI_PIN         23
+#endif
+
+#endif
+
 /****************************************************************************************
 * Gen3+ pin assignment
 *