From b5a964fcc54ecfe8badeae120282037a7692852e Mon Sep 17 00:00:00 2001 From: fmalpartida Date: Wed, 30 Oct 2013 11:45:32 +0100 Subject: [PATCH 1/3] Initial SAV MkI (RepRap CloneWars board) integration. Included support for BT dongle on AT90USB boards. Added LCD Shift Register LCD control Included support for RepRap Clone Wars project board (SAV MKI). --- Marlin/{BlinkM.cpp => BlinkM.__cpp} | 0 Marlin/{BlinkM.h => BlinkM.__h} | 0 Marlin/Configuration.h | 26 +++++- Marlin/Configuration_adv.h | 2 +- Marlin/Marlin.h | 13 +++ Marlin/MarlinSerial.cpp | 6 ++ Marlin/MarlinSerial.h | 5 ++ Marlin/Sd2PinMap.h | 8 +- Marlin/pins.h | 86 +++++++++++++++++++ Marlin/ultralcd.cpp | 20 +++-- .../ultralcd_implementation_hitachi_HD44780.h | 11 ++- 11 files changed, 162 insertions(+), 15 deletions(-) rename Marlin/{BlinkM.cpp => BlinkM.__cpp} (100%) rename Marlin/{BlinkM.h => BlinkM.__h} (100%) diff --git a/Marlin/BlinkM.cpp b/Marlin/BlinkM.__cpp similarity index 100% rename from Marlin/BlinkM.cpp rename to Marlin/BlinkM.__cpp diff --git a/Marlin/BlinkM.h b/Marlin/BlinkM.__h similarity index 100% rename from Marlin/BlinkM.h rename to Marlin/BlinkM.__h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 8496a8b24..39032f1fb 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -22,10 +22,21 @@ // This allows the connection of wireless adapters (for instance) to non-default port pins. // Serial port 0 is still used by the Arduino bootloader regardless of this setting. #define SERIAL_PORT 0 +//#define SERIAL_PORT 1 // Define serial port 1 for bluetooth configuration in AT90USB configurations +// This determines the communication speed of the printer // This determines the communication speed of the printer #define BAUDRATE 250000 -//#define BAUDRATE 115200 + +// This enables the serial port associated to the Bluetooth interface +//#define BTENABLED // Enable BT interface + + +// SERIAL_PORT selects which serial port should be used for communication with the host. +// This allows the connection of wireless adapters (for instance) to non-default port pins. +// Serial port 0 is still used by the Arduino bootloader regardless of this setting. +#define SERIAL_PORT 0 + //// The following define selects which electronics board you have. Please choose the one that matches your setup // 10 = Gen7 custom (Alfons3 Version) "https://github.com/Alfons3/Generation_7_Electronics" @@ -54,6 +65,7 @@ // 80 = Rumba // 81 = Printrboard (AT90USB1286) // 82 = Brainwave (AT90USB646) +// 83 = SAV Mk-I (AT90USB1286) // 9 = Gen3+ // 70 = Megatronics // 701= Megatronics v2.0 @@ -64,7 +76,8 @@ // 21 = Elefu Ra Board (v3) #ifndef MOTHERBOARD -#define MOTHERBOARD 7 +//[FMC]#define MOTHERBOARD 7 +#define MOTHERBOARD 83 #endif // Define this to set a custom name for your generic Mendel, @@ -507,6 +520,15 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of #define ULTIPANEL #endif +// Shift register panels +// --------------------- +//#define SR_LCD +#ifdef SR_LCD + #define SR_LCD_2W_NL // Non latching 2 wire shiftregister + //#define NEWPANEL +#endif + + #ifdef ULTIPANEL // #define NEWPANEL //enable this if you have a click-encoder panel #define SDSUPPORT diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 06101f00c..246eb3252 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -163,7 +163,7 @@ #ifdef Z_DUAL_STEPPER_DRIVERS && Y_DUAL_STEPPER_DRIVERS #error "You cannot have dual drivers for both Y and Z" -#endif +#endif // Enable this for dual x-carriage printers. // A dual x-carriage design has the advantage that the inactive extruder can be parked which diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index fe1e751d9..ef0fa7083 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -34,6 +34,10 @@ # define analogInputToDigitalPin(p) ((p) + A0) #endif +#ifdef AT90USB +#include "HardwareSerial.h" +#endif + #include "MarlinSerial.h" #ifndef cbi @@ -45,6 +49,15 @@ #include "WString.h" +#ifdef AT90USB + #ifdef BTENABLED + extern HardwareSerial bt; + #define MYSERIAL bt + #else + #define MYSERIAL Serial + #endif // BTENABLED +#endif + #ifdef AT90USB #define MYSERIAL Serial #else diff --git a/Marlin/MarlinSerial.cpp b/Marlin/MarlinSerial.cpp index 1358f3859..0433df2d3 100644 --- a/Marlin/MarlinSerial.cpp +++ b/Marlin/MarlinSerial.cpp @@ -320,3 +320,9 @@ MarlinSerial MSerial; #endif // whole file #endif // !AT90USB + +// For AT90USB targets use the UART for BT interfacing +#if defined(AT90USB) && defined (BTENABLED) + HardwareSerial bt; +#endif + diff --git a/Marlin/MarlinSerial.h b/Marlin/MarlinSerial.h index 9514730fa..7ccdfd6a0 100644 --- a/Marlin/MarlinSerial.h +++ b/Marlin/MarlinSerial.h @@ -181,4 +181,9 @@ class MarlinSerial //: public Stream extern MarlinSerial MSerial; #endif // !AT90USB +// Use the UART for BT in AT90USB configurations +#if defined(AT90USB) && defined (BTENABLED) + extern HardwareSerial bt; +#endif + #endif diff --git a/Marlin/Sd2PinMap.h b/Marlin/Sd2PinMap.h index a40729df2..93ab943ce 100644 --- a/Marlin/Sd2PinMap.h +++ b/Marlin/Sd2PinMap.h @@ -222,10 +222,10 @@ uint8_t const SDA_PIN = 1; // D1 uint8_t const SCL_PIN = 0; // D0 // SPI port -uint8_t const SS_PIN = 20; // B0 -uint8_t const MOSI_PIN = 22; // B2 -uint8_t const MISO_PIN = 23; // B3 -uint8_t const SCK_PIN = 21; // B1 +uint8_t const SS_PIN = 20; // B0 +uint8_t const MOSI_PIN = 22; // B2 +uint8_t const MISO_PIN = 23; // B3 +uint8_t const SCK_PIN = 21; // B1 static const pin_map_t digitalPinMap[] = { {&DDRD, &PIND, &PORTD, 0}, // D0 0 diff --git a/Marlin/pins.h b/Marlin/pins.h index 12dd93134..2fd921680 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -1541,6 +1541,92 @@ #endif // MOTHERBOARD == 82 (Brainwave) +// +// SAV Mk-I +// ----------------------------------------------------------------------------------- +/**************************************************************************************** +* SAV MkI pin assignments (AT90USB1286) +* Requires the Teensyduino software with Teensy++ 2.0 selected in Arduino IDE! + http://www.pjrc.com/teensy/teensyduino.html + RepRap Clone Wars project board. +****************************************************************************************/ +#if MOTHERBOARD == 83 // SAV Mk-I +#define KNOWN_BOARD 1 +#define AT90USB 1286 // Disable MarlinSerial etc. + +#ifndef __AVR_AT90USB1286__ +#error Oops! Make sure you have 'Teensy++ 2.0' selected from the 'Tools -> Boards' menu. +#endif + +#define LARGE_FLASH true + + +#define X_STEP_PIN 0 +#define X_DIR_PIN 1 +#define X_ENABLE_PIN 39 + +#define Y_STEP_PIN 2 +#define Y_DIR_PIN 3 +#define Y_ENABLE_PIN 38 + +#define Z_STEP_PIN 4 +#define Z_DIR_PIN 5 +#define Z_ENABLE_PIN 23 + +#define E0_STEP_PIN 6 +#define E0_DIR_PIN 7 +#define E0_ENABLE_PIN 19 + +#define HEATER_0_PIN 21 // Extruder +#define HEATER_1_PIN -1 +#define HEATER_2_PIN -1 +#define HEATER_BED_PIN 20 // Bed +#define FAN_PIN 16 // Fan -- from Teensyduino environment. + // For the fan and Teensyduino uses a different pin mapping. + + #define X_STOP_PIN 13 + #define Y_STOP_PIN 14 + #define Z_STOP_PIN 15 + #define TEMP_0_PIN 7 // Extruder / Analog pin numbering + #define TEMP_BED_PIN 6 // Bed / Analog pin numbering + +#define TEMP_1_PIN -1 +#define TEMP_2_PIN -1 + +#define SDPOWER -1 +#define SDSS 20 // PB0 - 8 in marlin env. +#define LED_PIN -1 +#define PS_ON_PIN -1 +#define KILL_PIN -1 +#define ALARM_PIN -1 +#define SDCARDDETECT -1 + + +#ifndef SDSUPPORT + // these pins are defined in the SD library if building with SD support + #define SCK_PIN 9 + #define MISO_PIN 11 + #define MOSI_PIN 10 +#endif + +#define BEEPER -1 +#define LCD_PINS_RS -1 +#define LCD_PINS_ENABLE -1 +#define LCD_PINS_D4 -1 +#define LCD_PINS_D5 -1 +#define LCD_PINS_D6 -1 +#define LCD_PINS_D7 -1 +#define BTN_EN1 -1 +#define BTN_EN2 -1 +#define BTN_ENC -1 + +// For LCD SHIFT register LCD +#define SR_DATA_PIN 0 +#define SR_CLK_PIN 1 + +#endif // MOTHERBOARD == 83 + + /**************************************************************************************** * Gen3+ pin assignment * diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 895c3ed4e..3e3cabc1e 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -992,14 +992,20 @@ void lcd_init() WRITE(SHIFT_LD,HIGH); #endif #else - pinMode(SHIFT_CLK,OUTPUT); - pinMode(SHIFT_LD,OUTPUT); - pinMode(SHIFT_EN,OUTPUT); - pinMode(SHIFT_OUT,INPUT); - WRITE(SHIFT_OUT,HIGH); - WRITE(SHIFT_LD,HIGH); - WRITE(SHIFT_EN,LOW); + #ifdef SR_LCD_2W_NL + pinMode (SR_DATA_PIN, OUTPUT); + pinMode (SR_CLK_PIN, OUTPUT); + #else + pinMode(SHIFT_CLK,OUTPUT); + pinMode(SHIFT_LD,OUTPUT); + pinMode(SHIFT_EN,OUTPUT); + pinMode(SHIFT_OUT,INPUT); + WRITE(SHIFT_OUT,HIGH); + WRITE(SHIFT_LD,HIGH); + WRITE(SHIFT_EN,LOW); + #endif // SR_LCD_2W_NL #endif//!NEWPANEL + #if (SDCARDDETECT > 0) WRITE(SDCARDDETECT, HIGH); lcd_oldcardstatus = IS_SD_INSERTED; diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 36462d887..c0d4989c3 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -178,7 +178,16 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #include #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT); - + +// 2 wire Non-latching LCD SR from: +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +#elif defined(SR_LCD_2W_NL) + + #include + #include + #define LCD_CLASS LiquidCrystal_SR + LCD_CLASS lcd(SR_DATA_PIN, SR_CLK_PIN); + #else // Standard directly connected LCD implementations #if LANGUAGE_CHOICE == 6 From 5b3f60ea2e15bd2b37d3f94052da084f5e0a8178 Mon Sep 17 00:00:00 2001 From: fmalpartida Date: Wed, 30 Oct 2013 21:52:46 +0100 Subject: [PATCH 2/3] Corrected LCD only error If only an LCD is defined and no menu or keyboard defined, there is a compilation error. Added conditional compilation. --- Marlin/{BlinkM.__cpp => BlinkM.cpp} | 0 Marlin/{BlinkM.__h => BlinkM.h} | 0 Marlin/ultralcd.cpp | 3 +++ 3 files changed, 3 insertions(+) rename Marlin/{BlinkM.__cpp => BlinkM.cpp} (100%) rename Marlin/{BlinkM.__h => BlinkM.h} (100%) diff --git a/Marlin/BlinkM.__cpp b/Marlin/BlinkM.cpp similarity index 100% rename from Marlin/BlinkM.__cpp rename to Marlin/BlinkM.cpp diff --git a/Marlin/BlinkM.__h b/Marlin/BlinkM.h similarity index 100% rename from Marlin/BlinkM.__h rename to Marlin/BlinkM.h diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 3e3cabc1e..e3e2556fa 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -19,7 +19,10 @@ int absPreheatHotendTemp; int absPreheatHPBTemp; int absPreheatFanSpeed; +#ifdef ULTIPANEL static float manual_feedrate[] = MANUAL_FEEDRATE; +#endif // ULTIPANEL + /* !Configuration settings */ //Function pointer to menu functions. From 7b556d2e96b3ac9504c74951b9e795c5dd1fa91b Mon Sep 17 00:00:00 2001 From: fmalpartida Date: Sun, 3 Nov 2013 19:57:06 +0100 Subject: [PATCH 3/3] Added BT support on AT90USB devices Added AT90USB device BT connectivity support using second UART. --- Marlin/Configuration.h | 14 ++++---------- Marlin/Marlin.h | 7 ------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 39032f1fb..129cf7477 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -22,20 +22,13 @@ // This allows the connection of wireless adapters (for instance) to non-default port pins. // Serial port 0 is still used by the Arduino bootloader regardless of this setting. #define SERIAL_PORT 0 -//#define SERIAL_PORT 1 // Define serial port 1 for bluetooth configuration in AT90USB configurations // This determines the communication speed of the printer // This determines the communication speed of the printer #define BAUDRATE 250000 // This enables the serial port associated to the Bluetooth interface -//#define BTENABLED // Enable BT interface - - -// SERIAL_PORT selects which serial port should be used for communication with the host. -// This allows the connection of wireless adapters (for instance) to non-default port pins. -// Serial port 0 is still used by the Arduino bootloader regardless of this setting. -#define SERIAL_PORT 0 +//#define BTENABLED // Enable BT interface on AT90USB devices //// The following define selects which electronics board you have. Please choose the one that matches your setup @@ -76,8 +69,7 @@ // 21 = Elefu Ra Board (v3) #ifndef MOTHERBOARD -//[FMC]#define MOTHERBOARD 7 -#define MOTHERBOARD 83 +//#define MOTHERBOARD 7 #endif // Define this to set a custom name for your generic Mendel, @@ -522,6 +514,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of // Shift register panels // --------------------- +// 2 wire Non-latching LCD SR from: +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection //#define SR_LCD #ifdef SR_LCD #define SR_LCD_2W_NL // Non latching 2 wire shiftregister diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index ef0fa7083..ef59f3f3f 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -51,19 +51,12 @@ #ifdef AT90USB #ifdef BTENABLED - extern HardwareSerial bt; #define MYSERIAL bt #else #define MYSERIAL Serial #endif // BTENABLED #endif -#ifdef AT90USB - #define MYSERIAL Serial -#else - #define MYSERIAL MSerial -#endif - #define SERIAL_PROTOCOL(x) (MYSERIAL.print(x)) #define SERIAL_PROTOCOL_F(x,y) (MYSERIAL.print(x,y)) #define SERIAL_PROTOCOLPGM(x) (serialprintPGM(PSTR(x)))