diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index f56dd4ee8..6a2ebe6b5 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -2,7 +2,7 @@
#define CONFIGURATION_H
// This configurtion file contains the basic settings.
-// Advanced settings can be found in Configuration_adv.h
+// Advanced settings can be found in Configuration_adv.h
// BASIC SETTINGS: select your board type, temperature sensor type, axis scaling, and endstop configuration
//User specified version info of this build to display in [Pronterface, etc] terminal window during startup.
@@ -78,7 +78,7 @@
// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
// 10 is 100k RS thermistor 198-961 (4.7k pullup)
//
-// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k
+// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k
// (but gives greater accuracy and more stable PID)
// 51 is 100k thermistor - EPCOS (1k pullup)
// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
@@ -90,12 +90,12 @@
#define TEMP_SENSOR_BED 0
// Actual temperature must be close to target for this long before M109 returns success
-#define TEMP_RESIDENCY_TIME 10 // (seconds)
+#define TEMP_RESIDENCY_TIME 10 // (seconds)
#define TEMP_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one
#define TEMP_WINDOW 1 // (degC) Window around target to start the recidency timer x degC early.
// The minimal temperature defines the temperature below which the heater will not be enabled It is used
-// to check that the wiring to the thermistor is not broken.
+// to check that the wiring to the thermistor is not broken.
// Otherwise this would lead to the heater being powered on all the time.
#define HEATER_0_MINTEMP 5
#define HEATER_1_MINTEMP 5
@@ -121,7 +121,7 @@
#define BANG_MAX 256 // limits current to nozzle while in bang-bang mode; 256=full current
#define PID_MAX 256 // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 256=full current
#ifdef PIDTEMP
- //#define PID_DEBUG // Sends debug data to the serial port.
+ //#define PID_DEBUG // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
// is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
@@ -132,15 +132,15 @@
// If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it
// Ultimaker
#define DEFAULT_Kp 22.2
- #define DEFAULT_Ki 1.08
- #define DEFAULT_Kd 114
+ #define DEFAULT_Ki 1.08
+ #define DEFAULT_Kd 114
// Makergear
// #define DEFAULT_Kp 7.0
-// #define DEFAULT_Ki 0.1
-// #define DEFAULT_Kd 12
+// #define DEFAULT_Ki 0.1
+// #define DEFAULT_Kd 12
-// Mendel Parts V9 on 12V
+// Mendel Parts V9 on 12V
// #define DEFAULT_Kp 63.0
// #define DEFAULT_Ki 2.25
// #define DEFAULT_Kd 440
@@ -149,11 +149,11 @@
// Bed Temperature Control
// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis
//
-// uncomment this to enable PID on the bed. It uses the same ferquency PWM as the extruder.
+// uncomment this to enable PID on the bed. It uses the same ferquency PWM as the extruder.
// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz,
// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating.
-// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater.
-// If your configuration is significantly different than this and you don't understand the issues involved, you proabaly
+// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater.
+// If your configuration is significantly different than this and you don't understand the issues involved, you proabaly
// shouldn't use bed PID until someone else verifies your hardware works.
// If this is enabled, find your own PID constants below.
//#define PIDTEMPBED
@@ -223,9 +223,9 @@
#endif
// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
-const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
-const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
-const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
+const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
+const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
+const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
//#define DISABLE_MAX_ENDSTOPS
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
@@ -280,13 +280,13 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0} // set the homing speeds (mm/min)
-// default settings
+// default settings
-#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1} // default steps per unit for ultimaker
-#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 25} // (mm/sec)
+#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200.0*8/3,760*1.1} // default steps per unit for ultimaker
+#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 25} // (mm/sec)
#define DEFAULT_MAX_ACCELERATION {9000,9000,100,10000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
-#define DEFAULT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
+#define DEFAULT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
#define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts
// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
@@ -307,7 +307,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
// EEPROM
// the microcontroller can store settings in the EEPROM, e.g. max velocity...
// M500 - stores paramters in EEPROM
-// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
+// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
//define this to enable eeprom support
//#define EEPROM_SETTINGS
@@ -318,15 +318,15 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
// Preheat Constants
#define PLA_PREHEAT_HOTEND_TEMP 180
#define PLA_PREHEAT_HPB_TEMP 70
-#define PLA_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
+#define PLA_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
#define ABS_PREHEAT_HOTEND_TEMP 240
#define ABS_PREHEAT_HPB_TEMP 100
-#define ABS_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
+#define ABS_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
//LCD and SD support
//#define ULTRA_LCD //general lcd support, also 16x2
-//#define DOGLCD // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
+//#define DOGLCD // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
//#define SDSUPPORT // Enable SD Card Support in Hardware Console
//#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error)
@@ -347,6 +347,11 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
+// The RepRapWorld REPRAPWORLD_KEYPAD v1.1
+// http://reprapworld.com/?products_details&products_id=202&cPath=1591_1626
+//#define REPRAPWORLD_KEYPAD
+//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // how much should be moved when a key is pressed, eg 10.0 means 10mm per click
+
//automatic expansion
#if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
#define DOGLCD
@@ -357,7 +362,12 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
#if defined(ULTIMAKERCONTROLLER) || defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
#define ULTIPANEL
#define NEWPANEL
-#endif
+#endif
+
+#if defined(REPRAPWORLD_KEYPAD)
+ #define NEWPANEL
+ #define ULTIPANEL
+#endif
//I2C PANELS
@@ -404,22 +414,22 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
// #define NEWPANEL //enable this if you have a click-encoder panel
#define SDSUPPORT
#define ULTRA_LCD
- #ifdef DOGLCD // Change number of lines to match the DOG graphic display
- #define LCD_WIDTH 20
- #define LCD_HEIGHT 5
- #else
- #define LCD_WIDTH 20
- #define LCD_HEIGHT 4
- #endif
-#else //no panel but just lcd
+ #ifdef DOGLCD // Change number of lines to match the DOG graphic display
+ #define LCD_WIDTH 20
+ #define LCD_HEIGHT 5
+ #else
+ #define LCD_WIDTH 20
+ #define LCD_HEIGHT 4
+ #endif
+#else //no panel but just lcd
#ifdef ULTRA_LCD
- #ifdef DOGLCD // Change number of lines to match the 128x64 graphics display
- #define LCD_WIDTH 20
- #define LCD_HEIGHT 5
- #else
- #define LCD_WIDTH 16
- #define LCD_HEIGHT 2
- #endif
+ #ifdef DOGLCD // Change number of lines to match the 128x64 graphics display
+ #define LCD_WIDTH 20
+ #define LCD_HEIGHT 5
+ #else
+ #define LCD_WIDTH 16
+ #define LCD_HEIGHT 2
+ #endif
#endif
#endif
@@ -433,6 +443,26 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
// SF send wrong arc g-codes when using Arc Point as fillet procedure
//#define SF_ARC_FIX
+// Support for the BariCUDA Paste Extruder.
+//#define BARICUDA
+
+/*********************************************************************\
+*
+* R/C SERVO support
+*
+* Sponsored by TrinityLabs, Reworked by codexmas
+*
+**********************************************************************/
+
+// Number of servos
+//
+// If you select a configuration below, this will receive a default value and does not need to be set manually
+// set it manually if you have more servos than extruders and wish to manually control some
+// leaving it undefined or defining as 0 will disable the servo subsystem
+// If unsure, leave commented / disabled
+//
+// #define NUM_SERVOS 3
+
#include "Configuration_adv.h"
#include "thermistortables.h"
diff --git a/Marlin/Makefile b/Marlin/Makefile
index e09d15f06..c23173525 100644
--- a/Marlin/Makefile
+++ b/Marlin/Makefile
@@ -1,12 +1,12 @@
# Sprinter Arduino Project Makefile
-#
+#
# Makefile Based on:
# Arduino 0011 Makefile
# Arduino adaptation by mellis, eighthave, oli.keller
# Marlin adaption by Daid
#
# This has been tested with Arduino 0022.
-#
+#
# This makefile allows you to build sketches from the command line
# without the Arduino environment (or Java).
#
@@ -21,7 +21,7 @@
# (e.g. UPLOAD_PORT = /dev/tty.USB0). If the exact name of this file
# changes, you can use * as a wildcard (e.g. UPLOAD_PORT = /dev/tty.usb*).
#
-# 3. Set the line containing "MCU" to match your board's processor.
+# 3. Set the line containing "MCU" to match your board's processor.
# Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
# or Diecimila have the atmega168. If you're using a LilyPad Arduino,
# change F_CPU to 8000000. If you are using Gen7 electronics, you
@@ -44,7 +44,7 @@ ARDUINO_INSTALL_DIR ?= ../../arduino-0022
ARDUINO_VERSION ?= 22
# You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
-AVR_TOOLS_PATH ?=
+AVR_TOOLS_PATH ?=
#Programmer configuration
UPLOAD_RATE ?= 115200
@@ -213,7 +213,7 @@ CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \
SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp \
stepper.cpp temperature.cpp cardreader.cpp ConfigurationStore.cpp \
watchdog.cpp
-CXXSRC += LiquidCrystal.cpp ultralcd.cpp SPI.cpp
+CXXSRC += LiquidCrystal.cpp ultralcd.cpp SPI.cpp Servo.cpp
#Check for Arduino 1.0.0 or higher and use the correct sourcefiles for that version
ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
@@ -317,19 +317,19 @@ endif
# Default target.
all: sizeafter
-build: $(BUILD_DIR) elf hex
+build: $(BUILD_DIR) elf hex
# Creates the object directory
-$(BUILD_DIR):
+$(BUILD_DIR):
$P mkdir -p $(BUILD_DIR)
elf: $(BUILD_DIR)/$(TARGET).elf
hex: $(BUILD_DIR)/$(TARGET).hex
eep: $(BUILD_DIR)/$(TARGET).eep
-lss: $(BUILD_DIR)/$(TARGET).lss
+lss: $(BUILD_DIR)/$(TARGET).lss
sym: $(BUILD_DIR)/$(TARGET).sym
-# Program the device.
+# Program the device.
# Do not try to reset an arduino if it's not one
upload: $(BUILD_DIR)/$(TARGET).hex
ifeq (${AVRDUDE_PROGRAMMER}, arduino)
@@ -356,7 +356,7 @@ COFFCONVERT=$(OBJCOPY) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
- --change-section-address .eeprom-0x810000
+ --change-section-address .eeprom-0x810000
coff: $(BUILD_DIR)/$(TARGET).elf
diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h
index 25c5aca63..551a55390 100644
--- a/Marlin/Marlin.h
+++ b/Marlin/Marlin.h
@@ -186,6 +186,10 @@ extern float add_homeing[3];
extern float min_pos[3];
extern float max_pos[3];
extern int fanSpeed;
+#ifdef BARICUDA
+extern int ValvePressure;
+extern int EtoPPressure;
+#endif
#ifdef FWRETRACT
extern bool autoretract_enabled;
diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp
index abe27d32b..71e6aa6e6 100644
--- a/Marlin/Marlin_main.cpp
+++ b/Marlin/Marlin_main.cpp
@@ -3,17 +3,17 @@
/*
Reprap firmware based on Sprinter and grbl.
Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
-
+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
@@ -22,8 +22,8 @@
This firmware is a mashup between Sprinter and grbl.
(https://github.com/kliment/Sprinter)
(https://github.com/simen/grbl/tree)
-
- It has preliminary support for Matthew Roberts advance algorithm
+
+ It has preliminary support for Matthew Roberts advance algorithm
http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
*/
@@ -40,7 +40,11 @@
#include "language.h"
#include "pins_arduino.h"
-#if DIGIPOTSS_PIN > -1
+#if NUM_SERVOS > 0
+#include "Servo.h"
+#endif
+
+#if DIGIPOTSS_PIN > 0
#include
#endif
@@ -93,14 +97,18 @@
// M81 - Turn off Power Supply
// M82 - Set E codes absolute (default)
// M83 - Set E codes relative while in Absolute Coordinates (G90) mode
-// M84 - Disable steppers until next move,
+// M84 - Disable steppers until next move,
// or use S to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout.
// M85 - Set inactivity shutdown timer with parameter S. To disable set zero (default)
// M92 - Set axis_steps_per_unit - same syntax as G92
-// M114 - Output current position to serial port
-// M115 - Capabilities string
+// M114 - Output current position to serial port
+// M115 - Capabilities string
// M117 - display message
// M119 - Output Endstop status to serial port
+// M126 - Solenoid Air Valve Open (BariCUDA support by jmil)
+// M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure by jmil)
+// M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
+// M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil)
// M140 - Set bed target temp
// M190 - Wait for bed current temp to reach target temp.
// M200 - Set filament diameter
@@ -117,6 +125,7 @@
// M220 S- set speed factor override percentage
// M221 S- set extrude factor override percentage
// M240 - Trigger a camera to take a photograph
+// M280 - set servo position absolute. P: servo index, S: angle or microseconds
// M300 - Play beepsound S P
// M301 - Set PID parameters P I and D
// M302 - Allow cold extrudes
@@ -124,7 +133,7 @@
// M304 - Set bed PID parameters P I and D
// M400 - Finish all moves
// M500 - stores paramters in EEPROM
-// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
+// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
// M503 - print the current settings (from memory not from eeprom)
// M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
@@ -160,14 +169,18 @@ float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
// Extruder offset, only in XY plane
#if EXTRUDERS > 1
-float extruder_offset[2][EXTRUDERS] = {
+float extruder_offset[2][EXTRUDERS] = {
#if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y)
- EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y
+ EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y
#endif
-};
+};
#endif
uint8_t active_extruder = 0;
int fanSpeed=0;
+#ifdef BARICUDA
+int ValvePressure=0;
+int EtoPPressure=0;
+#endif
#ifdef FWRETRACT
bool autoretract_enabled=true;
@@ -217,6 +230,10 @@ static uint8_t tmp_extruder;
bool Stopped=false;
+#if NUM_SERVOS > 0
+ Servo servos[NUM_SERVOS];
+#endif
+
//===========================================================================
//=============================ROUTINES=============================
//===========================================================================
@@ -288,15 +305,15 @@ void setup_killpin()
WRITE(KILL_PIN,HIGH);
#endif
}
-
+
void setup_photpin()
{
#ifdef PHOTOGRAPH_PIN
- #if (PHOTOGRAPH_PIN > -1)
+ #if (PHOTOGRAPH_PIN > 0)
SET_OUTPUT(PHOTOGRAPH_PIN);
WRITE(PHOTOGRAPH_PIN, LOW);
#endif
- #endif
+ #endif
}
void setup_powerhold()
@@ -307,7 +324,7 @@ void setup_powerhold()
WRITE(SUICIDE_PIN, HIGH);
#endif
#endif
- #if (PS_ON_PIN > -1)
+ #if (PS_ON_PIN > 0)
SET_OUTPUT(PS_ON_PIN);
WRITE(PS_ON_PIN, PS_ON_AWAKE);
#endif
@@ -316,16 +333,35 @@ void setup_powerhold()
void suicide()
{
#ifdef SUICIDE_PIN
- #if (SUICIDE_PIN> -1)
+ #if (SUICIDE_PIN > 0)
SET_OUTPUT(SUICIDE_PIN);
WRITE(SUICIDE_PIN, LOW);
#endif
#endif
}
+void servo_init()
+{
+ #if (NUM_SERVOS >= 1) && (SERVO0_PIN > 0)
+ servos[0].attach(SERVO0_PIN);
+ #endif
+ #if (NUM_SERVOS >= 2) && (SERVO1_PIN > 0)
+ servos[1].attach(SERVO1_PIN);
+ #endif
+ #if (NUM_SERVOS >= 3) && (SERVO2_PIN > 0)
+ servos[2].attach(SERVO2_PIN);
+ #endif
+ #if (NUM_SERVOS >= 4) && (SERVO3_PIN > 0)
+ servos[3].attach(SERVO3_PIN);
+ #endif
+ #if (NUM_SERVOS >= 5)
+ #error "TODO: enter initalisation code for more servos"
+ #endif
+}
+
void setup()
{
- setup_killpin();
+ setup_killpin();
setup_powerhold();
MYSERIAL.begin(BAUDRATE);
SERIAL_PROTOCOLLNPGM("start");
@@ -362,22 +398,23 @@ void setup()
{
fromsd[i] = false;
}
-
- // loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
- Config_RetrieveSettings();
- tp_init(); // Initialize temperature loop
+ // loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
+ Config_RetrieveSettings();
+
+ tp_init(); // Initialize temperature loop
plan_init(); // Initialize planner;
watchdog_init();
st_init(); // Initialize stepper, this enables interrupts!
setup_photpin();
-
+ servo_init();
+
lcd_init();
-
+
#ifdef CONTROLLERFAN_PIN
SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
#endif
-
+
#ifdef EXTRUDERFAN_PIN
SET_OUTPUT(EXTRUDERFAN_PIN); //Set pin used for extruder cooling fan
#endif
@@ -396,9 +433,9 @@ void loop()
#ifdef SDSUPPORT
if(card.saving)
{
- if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
- {
- card.write_command(cmdbuffer[bufindr]);
+ if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
+ {
+ card.write_command(cmdbuffer[bufindr]);
if(card.logging)
{
process_commands();
@@ -407,16 +444,16 @@ void loop()
{
SERIAL_PROTOCOLLNPGM(MSG_OK);
}
- }
- else
- {
- card.closefile();
- SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED);
- }
+ }
+ else
+ {
+ card.closefile();
+ SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED);
+ }
}
else
{
- process_commands();
+ process_commands();
}
#else
process_commands();
@@ -431,14 +468,14 @@ void loop()
lcd_update();
}
-void get_command()
-{
+void get_command()
+{
while( MYSERIAL.available() > 0 && buflen < BUFSIZE) {
serial_char = MYSERIAL.read();
- if(serial_char == '\n' ||
- serial_char == '\r' ||
- (serial_char == ':' && comment_mode == false) ||
- serial_count >= (MAX_CMD_SIZE - 1) )
+ if(serial_char == '\n' ||
+ serial_char == '\r' ||
+ (serial_char == ':' && comment_mode == false) ||
+ serial_count >= (MAX_CMD_SIZE - 1) )
{
if(!serial_count) { //if empty line
comment_mode = false; //for new command
@@ -479,7 +516,7 @@ void get_command()
}
//if no errors, continue parsing
}
- else
+ else
{
SERIAL_ERROR_START;
SERIAL_ERRORPGM(MSG_ERR_NO_CHECKSUM);
@@ -511,11 +548,11 @@ void get_command()
case 2:
case 3:
if(Stopped == false) { // If printer is stopped by an error the G[0-3] codes are ignored.
- #ifdef SDSUPPORT
+ #ifdef SDSUPPORT
if(card.saving)
break;
- #endif //SDSUPPORT
- SERIAL_PROTOCOLLNPGM(MSG_OK);
+ #endif //SDSUPPORT
+ SERIAL_PROTOCOLLNPGM(MSG_OK);
}
else {
SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
@@ -545,10 +582,10 @@ void get_command()
while( !card.eof() && buflen < BUFSIZE) {
int16_t n=card.get();
serial_char = (char)n;
- if(serial_char == '\n' ||
- serial_char == '\r' ||
- (serial_char == ':' && comment_mode == false) ||
- serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
+ if(serial_char == '\n' ||
+ serial_char == '\r' ||
+ (serial_char == ':' && comment_mode == false) ||
+ serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
{
if(card.eof()){
SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
@@ -564,7 +601,7 @@ void get_command()
lcd_setstatus(time);
card.printingHasFinished();
card.checkautostart(true);
-
+
}
if(!serial_count)
{
@@ -576,7 +613,7 @@ void get_command()
fromsd[bufindw] = true;
buflen += 1;
bufindw = (bufindw + 1)%BUFSIZE;
-// }
+// }
comment_mode = false; //for new command
serial_count = 0; //clear buffer
}
@@ -586,20 +623,20 @@ void get_command()
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
}
}
-
+
#endif //SDSUPPORT
}
-float code_value()
-{
- return (strtod(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL));
+float code_value()
+{
+ return (strtod(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL));
}
-long code_value_long()
-{
- return (strtol(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL, 10));
+long code_value_long()
+{
+ return (strtol(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL, 10));
}
bool code_seen(char code)
@@ -608,17 +645,17 @@ bool code_seen(char code)
return (strchr_pointer != NULL); //Return True if a character was found
}
-#define DEFINE_PGM_READ_ANY(type, reader) \
- static inline type pgm_read_any(const type *p) \
- { return pgm_read_##reader##_near(p); }
+#define DEFINE_PGM_READ_ANY(type, reader) \
+ static inline type pgm_read_any(const type *p) \
+ { return pgm_read_##reader##_near(p); }
DEFINE_PGM_READ_ANY(float, float);
DEFINE_PGM_READ_ANY(signed char, byte);
-#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
-static const PROGMEM type array##_P[3] = \
- { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
-static inline type array(int axis) \
+#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
+static const PROGMEM type array##_P[3] = \
+ { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
+static inline type array(int axis) \
{ return pgm_read_any(&array##_P[axis]); }
XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS);
@@ -636,7 +673,7 @@ static void axis_is_at_home(int axis) {
static void homeaxis(int axis) {
#define HOMEAXIS_DO(LETTER) \
- ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
+ ((LETTER##_MIN_PIN > 0 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > 0 && LETTER##_HOME_DIR==1))
if (axis==X_AXIS ? HOMEAXIS_DO(X) :
axis==Y_AXIS ? HOMEAXIS_DO(Y) :
@@ -648,19 +685,19 @@ static void homeaxis(int axis) {
feedrate = homing_feedrate[axis];
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
st_synchronize();
-
+
current_position[axis] = 0;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
destination[axis] = -home_retract_mm(axis) * home_dir(axis);
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
st_synchronize();
-
+
destination[axis] = 2*home_retract_mm(axis) * home_dir(axis);
- feedrate = homing_feedrate[axis]/2 ;
+ feedrate = homing_feedrate[axis]/2 ;
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
st_synchronize();
-
- axis_is_at_home(axis);
+
+ axis_is_at_home(axis);
destination[axis] = current_position[axis];
feedrate = 0.0;
endstops_hit_on_purpose();
@@ -703,7 +740,7 @@ void process_commands()
codenum = 0;
if(code_seen('P')) codenum = code_value(); // milliseconds to wait
if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
-
+
st_synchronize();
codenum += millis(); // keep track of when we started waiting
previous_millis_cmd = millis();
@@ -713,30 +750,30 @@ void process_commands()
lcd_update();
}
break;
- #ifdef FWRETRACT
+ #ifdef FWRETRACT
case 10: // G10 retract
- if(!retracted)
+ if(!retracted)
{
destination[X_AXIS]=current_position[X_AXIS];
destination[Y_AXIS]=current_position[Y_AXIS];
- destination[Z_AXIS]=current_position[Z_AXIS];
+ destination[Z_AXIS]=current_position[Z_AXIS];
current_position[Z_AXIS]+=-retract_zlift;
- destination[E_AXIS]=current_position[E_AXIS]-retract_length;
+ destination[E_AXIS]=current_position[E_AXIS]-retract_length;
feedrate=retract_feedrate;
retracted=true;
prepare_move();
}
-
+
break;
case 11: // G10 retract_recover
- if(!retracted)
+ if(!retracted)
{
destination[X_AXIS]=current_position[X_AXIS];
destination[Y_AXIS]=current_position[Y_AXIS];
- destination[Z_AXIS]=current_position[Z_AXIS];
-
+ destination[Z_AXIS]=current_position[Z_AXIS];
+
current_position[Z_AXIS]+=retract_zlift;
- current_position[E_AXIS]+=-retract_recover_length;
+ current_position[E_AXIS]+=-retract_recover_length;
feedrate=retract_recover_feedrate;
retracted=false;
prepare_move();
@@ -748,34 +785,34 @@ void process_commands()
saved_feedmultiply = feedmultiply;
feedmultiply = 100;
previous_millis_cmd = millis();
-
+
enable_endstops(true);
-
+
for(int8_t i=0; i < NUM_AXIS; i++) {
destination[i] = current_position[i];
}
feedrate = 0.0;
home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
-
+
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
HOMEAXIS(Z);
}
#endif
-
+
#ifdef QUICK_HOME
if((home_all_axis)||( code_seen(axis_codes[X_AXIS]) && code_seen(axis_codes[Y_AXIS])) ) //first diagonal move
{
- current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0;
+ current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0;
- plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
- destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;
- feedrate = homing_feedrate[X_AXIS];
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
+ destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;
+ feedrate = homing_feedrate[X_AXIS];
if(homing_feedrate[Y_AXIS] 0){
@@ -892,12 +929,12 @@ void process_commands()
#endif
case 17:
LCD_MESSAGEPGM(MSG_NO_MOVE);
- enable_x();
- enable_y();
- enable_z();
- enable_e0();
- enable_e1();
- enable_e2();
+ enable_x();
+ enable_y();
+ enable_z();
+ enable_e0();
+ enable_e1();
+ enable_e2();
break;
#ifdef SDSUPPORT
@@ -907,9 +944,9 @@ void process_commands()
SERIAL_PROTOCOLLNPGM(MSG_END_FILE_LIST);
break;
case 21: // M21 - init SD card
-
+
card.initsd();
-
+
break;
case 22: //M22 - release SD card
card.release();
@@ -949,18 +986,18 @@ void process_commands()
//processed in write to file routine above
//card,saving = false;
break;
- case 30: //M30 Delete File
- if (card.cardOK){
- card.closefile();
- starpos = (strchr(strchr_pointer + 4,'*'));
- if(starpos != NULL){
- char* npos = strchr(cmdbuffer[bufindr], 'N');
- strchr_pointer = strchr(npos,' ') + 1;
- *(starpos-1) = '\0';
- }
- card.removeFile(strchr_pointer + 4);
- }
- break;
+ case 30: //M30 Delete File
+ if (card.cardOK){
+ card.closefile();
+ starpos = (strchr(strchr_pointer + 4,'*'));
+ if(starpos != NULL){
+ char* npos = strchr(cmdbuffer[bufindr], 'N');
+ strchr_pointer = strchr(npos,' ') + 1;
+ *(starpos-1) = '\0';
+ }
+ card.removeFile(strchr_pointer + 4);
+ }
+ break;
case 928: //M928 - Start SD write
starpos = (strchr(strchr_pointer + 5,'*'));
if(starpos != NULL){
@@ -970,7 +1007,7 @@ void process_commands()
}
card.openLogFile(strchr_pointer+5);
break;
-
+
#endif //SDSUPPORT
case 31: //M31 take time since the start of the SD print or an M109 command
@@ -1025,13 +1062,13 @@ void process_commands()
if(setTargetedHotend(105)){
break;
}
- #if (TEMP_0_PIN > -1)
+ #if (TEMP_0_PIN > 0)
SERIAL_PROTOCOLPGM("ok T:");
- SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
+ SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
SERIAL_PROTOCOLPGM(" /");
- SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1);
- #if TEMP_BED_PIN > -1
- SERIAL_PROTOCOLPGM(" B:");
+ SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1);
+ #if TEMP_BED_PIN > 0
+ SERIAL_PROTOCOLPGM(" B:");
SERIAL_PROTOCOL_F(degBed(),1);
SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(degTargetBed(),1);
@@ -1042,20 +1079,20 @@ void process_commands()
#endif
SERIAL_PROTOCOLPGM(" @:");
- SERIAL_PROTOCOL(getHeaterPower(tmp_extruder));
+ SERIAL_PROTOCOL(getHeaterPower(tmp_extruder));
SERIAL_PROTOCOLPGM(" B@:");
- SERIAL_PROTOCOL(getHeaterPower(-1));
+ SERIAL_PROTOCOL(getHeaterPower(-1));
SERIAL_PROTOCOLLN("");
return;
break;
- case 109:
+ case 109:
{// M109 - Wait for extruder heater to reach target.
if(setTargetedHotend(109)){
break;
}
- LCD_MESSAGEPGM(MSG_HEATING);
+ LCD_MESSAGEPGM(MSG_HEATING);
#ifdef AUTOTEMP
autotemp_enabled=false;
#endif
@@ -1063,15 +1100,15 @@ void process_commands()
#ifdef AUTOTEMP
if (code_seen('S')) autotemp_min=code_value();
if (code_seen('B')) autotemp_max=code_value();
- if (code_seen('F'))
+ if (code_seen('F'))
{
autotemp_factor=code_value();
autotemp_enabled=true;
}
#endif
-
+
setWatch();
- codenum = millis();
+ codenum = millis();
/* See if we are heating up or cooling down */
bool target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
@@ -1079,7 +1116,7 @@ void process_commands()
#ifdef TEMP_RESIDENCY_TIME
long residencyStart;
residencyStart = -1;
- /* continue to loop until we have reached the target temp
+ /* continue to loop until we have reached the target temp
_and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
while((residencyStart == -1) ||
(residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL))) ) {
@@ -1089,9 +1126,9 @@ void process_commands()
if( (millis() - codenum) > 1000UL )
{ //Print Temp Reading and remaining time every 1 second while heating up/cooling down
SERIAL_PROTOCOLPGM("T:");
- SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
+ SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
SERIAL_PROTOCOLPGM(" E:");
- SERIAL_PROTOCOL((int)tmp_extruder);
+ SERIAL_PROTOCOL((int)tmp_extruder);
#ifdef TEMP_RESIDENCY_TIME
SERIAL_PROTOCOLPGM(" W:");
if(residencyStart > -1)
@@ -1099,7 +1136,7 @@ void process_commands()
codenum = ((TEMP_RESIDENCY_TIME * 1000UL) - (millis() - residencyStart)) / 1000UL;
SERIAL_PROTOCOLLN( codenum );
}
- else
+ else
{
SERIAL_PROTOCOLLN( "?" );
}
@@ -1116,7 +1153,7 @@ void process_commands()
or when current temp falls outside the hysteresis after target temp was reached */
if ((residencyStart == -1 && target_direction && (degHotend(tmp_extruder) >= (degTargetHotend(tmp_extruder)-TEMP_WINDOW))) ||
(residencyStart == -1 && !target_direction && (degHotend(tmp_extruder) <= (degTargetHotend(tmp_extruder)+TEMP_WINDOW))) ||
- (residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS) )
+ (residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS) )
{
residencyStart = millis();
}
@@ -1128,11 +1165,11 @@ void process_commands()
}
break;
case 190: // M190 - Wait for bed heater to reach target.
- #if TEMP_BED_PIN > -1
+ #if TEMP_BED_PIN > 0
LCD_MESSAGEPGM(MSG_BED_HEATING);
if (code_seen('S')) setTargetBed(code_value());
- codenum = millis();
- while(isHeatingBed())
+ codenum = millis();
+ while(isHeatingBed())
{
if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
{
@@ -1140,11 +1177,11 @@ void process_commands()
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOL(tt);
SERIAL_PROTOCOLPGM(" E:");
- SERIAL_PROTOCOL((int)active_extruder);
+ SERIAL_PROTOCOL((int)active_extruder);
SERIAL_PROTOCOLPGM(" B:");
- SERIAL_PROTOCOL_F(degBed(),1);
- SERIAL_PROTOCOLLN("");
- codenum = millis();
+ SERIAL_PROTOCOL_F(degBed(),1);
+ SERIAL_PROTOCOLLN("");
+ codenum = millis();
}
manage_heater();
manage_inactivity();
@@ -1155,38 +1192,69 @@ void process_commands()
#endif
break;
- #if FAN_PIN > -1
+ #if FAN_PIN > 0
case 106: //M106 Fan On
if (code_seen('S')){
fanSpeed=constrain(code_value(),0,255);
}
else {
- fanSpeed=255;
+ fanSpeed=255;
}
break;
case 107: //M107 Fan Off
fanSpeed = 0;
break;
#endif //FAN_PIN
+ #ifdef BARICUDA
+ // PWM for HEATER_1_PIN
+ #if HEATER_1_PIN > 0
+ case 126: //M126 valve open
+ if (code_seen('S')){
+ ValvePressure=constrain(code_value(),0,255);
+ }
+ else {
+ ValvePressure=255;
+ }
+ break;
+ case 127: //M127 valve closed
+ ValvePressure = 0;
+ break;
+ #endif //HEATER_1_PIN
- #if (PS_ON_PIN > -1)
+ // PWM for HEATER_2_PIN
+ #if HEATER_2_PIN > 0
+ case 128: //M128 valve open
+ if (code_seen('S')){
+ EtoPPressure=constrain(code_value(),0,255);
+ }
+ else {
+ EtoPPressure=255;
+ }
+ break;
+ case 129: //M129 valve closed
+ EtoPPressure = 0;
+ break;
+ #endif //HEATER_2_PIN
+ #endif
+
+ #if (PS_ON_PIN > 0)
case 80: // M80 - ATX Power On
SET_OUTPUT(PS_ON_PIN); //GND
WRITE(PS_ON_PIN, PS_ON_AWAKE);
break;
#endif
-
+
case 81: // M81 - ATX Power Off
-
- #if defined SUICIDE_PIN && SUICIDE_PIN > -1
+
+ #if defined SUICIDE_PIN && SUICIDE_PIN > 0
st_synchronize();
suicide();
- #elif (PS_ON_PIN > -1)
- SET_OUTPUT(PS_ON_PIN);
+ #elif (PS_ON_PIN > 0)
+ SET_OUTPUT(PS_ON_PIN);
WRITE(PS_ON_PIN, PS_ON_ASLEEP);
#endif
- break;
-
+ break;
+
case 82:
axis_relative_modes[3] = false;
break;
@@ -1195,11 +1263,11 @@ void process_commands()
break;
case 18: //compatibility
case 84: // M84
- if(code_seen('S')){
- stepper_inactive_time = code_value() * 1000;
+ if(code_seen('S')){
+ stepper_inactive_time = code_value() * 1000;
}
else
- {
+ {
bool all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2]))|| (code_seen(axis_codes[3])));
if(all_axis)
{
@@ -1221,18 +1289,18 @@ void process_commands()
disable_e1();
disable_e2();
}
- #endif
+ #endif
}
}
break;
case 85: // M85
code_seen('S');
- max_inactive_time = code_value() * 1000;
+ max_inactive_time = code_value() * 1000;
break;
case 92: // M92
- for(int8_t i=0; i < NUM_AXIS; i++)
+ for(int8_t i=0; i < NUM_AXIS; i++)
{
- if(code_seen(axis_codes[i]))
+ if(code_seen(axis_codes[i]))
{
if(i == 3) { // E
float value = code_value();
@@ -1266,16 +1334,16 @@ void process_commands()
SERIAL_PROTOCOL(current_position[Y_AXIS]);
SERIAL_PROTOCOLPGM("Z:");
SERIAL_PROTOCOL(current_position[Z_AXIS]);
- SERIAL_PROTOCOLPGM("E:");
+ SERIAL_PROTOCOLPGM("E:");
SERIAL_PROTOCOL(current_position[E_AXIS]);
-
+
SERIAL_PROTOCOLPGM(MSG_COUNT_X);
SERIAL_PROTOCOL(float(st_get_position(X_AXIS))/axis_steps_per_unit[X_AXIS]);
SERIAL_PROTOCOLPGM("Y:");
SERIAL_PROTOCOL(float(st_get_position(Y_AXIS))/axis_steps_per_unit[Y_AXIS]);
SERIAL_PROTOCOLPGM("Z:");
SERIAL_PROTOCOL(float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]);
-
+
SERIAL_PROTOCOLLN("");
break;
case 120: // M120
@@ -1286,34 +1354,34 @@ void process_commands()
break;
case 119: // M119
SERIAL_PROTOCOLLN(MSG_M119_REPORT);
- #if (X_MIN_PIN > -1)
+ #if (X_MIN_PIN > 0)
SERIAL_PROTOCOLPGM(MSG_X_MIN);
SERIAL_PROTOCOLLN(((READ(X_MIN_PIN)^X_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
- #if (X_MAX_PIN > -1)
+ #if (X_MAX_PIN > 0)
SERIAL_PROTOCOLPGM(MSG_X_MAX);
SERIAL_PROTOCOLLN(((READ(X_MAX_PIN)^X_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
- #if (Y_MIN_PIN > -1)
+ #if (Y_MIN_PIN > 0)
SERIAL_PROTOCOLPGM(MSG_Y_MIN);
SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
- #if (Y_MAX_PIN > -1)
+ #if (Y_MAX_PIN > 0)
SERIAL_PROTOCOLPGM(MSG_Y_MAX);
SERIAL_PROTOCOLLN(((READ(Y_MAX_PIN)^Y_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
- #if (Z_MIN_PIN > -1)
+ #if (Z_MIN_PIN > 0)
SERIAL_PROTOCOLPGM(MSG_Z_MIN);
SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
- #if (Z_MAX_PIN > -1)
+ #if (Z_MAX_PIN > 0)
SERIAL_PROTOCOLPGM(MSG_Z_MAX);
SERIAL_PROTOCOLLN(((READ(Z_MAX_PIN)^Z_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
break;
//TODO: update for all axis, use for loop
case 201: // M201
- for(int8_t i=0; i < NUM_AXIS; i++)
+ for(int8_t i=0; i < NUM_AXIS; i++)
{
if(code_seen(axis_codes[i]))
{
@@ -1321,7 +1389,7 @@ void process_commands()
}
}
// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
- reset_acceleration_rates();
+ reset_acceleration_rates();
break;
#if 0 // Not used for Sprinter/grbl gen6
case 202: // M202
@@ -1352,7 +1420,7 @@ void process_commands()
}
break;
case 206: // M206 additional homeing offset
- for(int8_t i=0; i < 3; i++)
+ for(int8_t i=0; i < 3; i++)
{
if(code_seen(axis_codes[i])) add_homeing[i] = code_value();
}
@@ -1360,47 +1428,47 @@ void process_commands()
#ifdef FWRETRACT
case 207: //M207 - set retract length S[positive mm] F[feedrate mm/sec] Z[additional zlift/hop]
{
- if(code_seen('S'))
+ if(code_seen('S'))
{
retract_length = code_value() ;
}
- if(code_seen('F'))
+ if(code_seen('F'))
{
retract_feedrate = code_value() ;
}
- if(code_seen('Z'))
+ if(code_seen('Z'))
{
retract_zlift = code_value() ;
}
}break;
case 208: // M208 - set retract recover length S[positive mm surplus to the M207 S*] F[feedrate mm/sec]
{
- if(code_seen('S'))
+ if(code_seen('S'))
{
retract_recover_length = code_value() ;
}
- if(code_seen('F'))
+ if(code_seen('F'))
{
retract_recover_feedrate = code_value() ;
}
}break;
case 209: // M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction.
{
- if(code_seen('S'))
+ if(code_seen('S'))
{
int t= code_value() ;
switch(t)
{
case 0: autoretract_enabled=false;retracted=false;break;
case 1: autoretract_enabled=true;retracted=false;break;
- default:
+ default:
SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_UNKNOWN_COMMAND);
SERIAL_ECHO(cmdbuffer[bufindr]);
SERIAL_ECHOLNPGM("\"");
}
}
-
+
}break;
#endif // FWRETRACT
#if EXTRUDERS > 1
@@ -1409,7 +1477,7 @@ void process_commands()
if(setTargetedHotend(218)){
break;
}
- if(code_seen('X'))
+ if(code_seen('X'))
{
extruder_offset[X_AXIS][tmp_extruder] = code_value();
}
@@ -1419,7 +1487,7 @@ void process_commands()
}
SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
- for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
+ for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
{
SERIAL_ECHO(" ");
SERIAL_ECHO(extruder_offset[X_AXIS][tmp_extruder]);
@@ -1431,7 +1499,7 @@ void process_commands()
#endif
case 220: // M220 S- set speed factor override percentage
{
- if(code_seen('S'))
+ if(code_seen('S'))
{
feedmultiply = code_value() ;
}
@@ -1439,21 +1507,52 @@ void process_commands()
break;
case 221: // M221 S- set extrude factor override percentage
{
- if(code_seen('S'))
+ if(code_seen('S'))
{
extrudemultiply = code_value() ;
}
}
break;
- #if defined(LARGE_FLASH) && LARGE_FLASH == true
+ #if NUM_SERVOS > 0
+ case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
+ {
+ int servo_index = -1;
+ int servo_position = 0;
+ if (code_seen('P'))
+ servo_index = code_value();
+ if (code_seen('S')) {
+ servo_position = code_value();
+ if ((servo_index >= 0) && (servo_index < NUM_SERVOS)) {
+ servos[servo_index].write(servo_position);
+ }
+ else {
+ SERIAL_ECHO_START;
+ SERIAL_ECHO("Servo ");
+ SERIAL_ECHO(servo_index);
+ SERIAL_ECHOLN(" out of range");
+ }
+ }
+ else if (servo_index >= 0) {
+ SERIAL_PROTOCOL(MSG_OK);
+ SERIAL_PROTOCOL(" Servo ");
+ SERIAL_PROTOCOL(servo_index);
+ SERIAL_PROTOCOL(": ");
+ SERIAL_PROTOCOL(servos[servo_index].read());
+ SERIAL_PROTOCOLLN("");
+ }
+ }
+ break;
+ #endif // NUM_SERVOS > 0
+
+ #if LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) )
case 300: // M300
{
int beepS = 400;
int beepP = 1000;
if(code_seen('S')) beepS = code_value();
if(code_seen('P')) beepP = code_value();
- #if defined(BEEPER) && BEEPER > -1
+ #if BEEPER > 0
tone(BEEPER, beepS);
delay(beepP);
noTone(BEEPER);
@@ -1474,10 +1573,10 @@ void process_commands()
#ifdef PID_ADD_EXTRUSION_RATE
if(code_seen('C')) Kc = code_value();
#endif
-
+
updatePID();
SERIAL_PROTOCOL(MSG_OK);
- SERIAL_PROTOCOL(" p:");
+ SERIAL_PROTOCOL(" p:");
SERIAL_PROTOCOL(Kp);
SERIAL_PROTOCOL(" i:");
SERIAL_PROTOCOL(unscalePID_i(Ki));
@@ -1501,7 +1600,7 @@ void process_commands()
updatePID();
SERIAL_PROTOCOL(MSG_OK);
- SERIAL_PROTOCOL(" p:");
+ SERIAL_PROTOCOL(" p:");
SERIAL_PROTOCOL(bedKp);
SERIAL_PROTOCOL(" i:");
SERIAL_PROTOCOL(unscalePID_i(bedKi));
@@ -1514,7 +1613,7 @@ void process_commands()
case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
{
#ifdef PHOTOGRAPH_PIN
- #if (PHOTOGRAPH_PIN > -1)
+ #if (PHOTOGRAPH_PIN > 0)
const uint8_t NUM_PULSES=16;
const float PULSE_LENGTH=0.01524;
for(int i=0; i < NUM_PULSES; i++) {
@@ -1534,7 +1633,7 @@ void process_commands()
#endif
}
break;
-
+
case 302: // allow cold extrudes
{
allow_cold_extrudes(true);
@@ -1546,8 +1645,8 @@ void process_commands()
int e=0;
int c=5;
if (code_seen('E')) e=code_value();
- if (e<0)
- temp=70;
+ if (e<0)
+ temp=70;
if (code_seen('S')) temp=code_value();
if (code_seen('C')) c=code_value();
PID_autotune(temp, e, c);
@@ -1599,7 +1698,7 @@ void process_commands()
lastpos[Z_AXIS]=current_position[Z_AXIS];
lastpos[E_AXIS]=current_position[E_AXIS];
//retract by E
- if(code_seen('E'))
+ if(code_seen('E'))
{
target[E_AXIS]+= code_value();
}
@@ -1610,9 +1709,9 @@ void process_commands()
#endif
}
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
-
+
//lift Z
- if(code_seen('Z'))
+ if(code_seen('Z'))
{
target[Z_AXIS]+= code_value();
}
@@ -1623,9 +1722,9 @@ void process_commands()
#endif
}
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
-
+
//move xy
- if(code_seen('X'))
+ if(code_seen('X'))
{
target[X_AXIS]+= code_value();
}
@@ -1635,7 +1734,7 @@ void process_commands()
target[X_AXIS]= FILAMENTCHANGE_XPOS ;
#endif
}
- if(code_seen('Y'))
+ if(code_seen('Y'))
{
target[Y_AXIS]= code_value();
}
@@ -1645,9 +1744,9 @@ void process_commands()
target[Y_AXIS]= FILAMENTCHANGE_YPOS ;
#endif
}
-
+
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
-
+
if(code_seen('L'))
{
target[E_AXIS]+= code_value();
@@ -1658,9 +1757,9 @@ void process_commands()
target[E_AXIS]+= FILAMENTCHANGE_FINALRETRACT ;
#endif
}
-
+
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
-
+
//finish moves
st_synchronize();
//disable extruder steppers so filament can be removed
@@ -1675,12 +1774,11 @@ void process_commands()
manage_heater();
manage_inactivity();
lcd_update();
-
if(cnt==0)
{
- #if defined(BEEPER) && BEEPER > -1
+ #if BEEPER > 0
SET_OUTPUT(BEEPER);
-
+
WRITE(BEEPER,HIGH);
delay(3);
WRITE(BEEPER,LOW);
@@ -1690,9 +1788,9 @@ void process_commands()
#endif
}
}
-
+
//return to normal
- if(code_seen('L'))
+ if(code_seen('L'))
{
target[E_AXIS]+= -code_value();
}
@@ -1710,18 +1808,19 @@ void process_commands()
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], feedrate/60, active_extruder); //final untretract
}
break;
- #endif //FILAMENTCHANGEENABLE
+ #endif //FILAMENTCHANGEENABLE
case 907: // M907 Set digital trimpot motor current using axis codes.
{
- #if DIGIPOTSS_PIN > -1
- for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) digipot_current(i,code_value());
+ #if DIGIPOTSS_PIN > 0
+ for(int i=0;i -1
+ #if DIGIPOTSS_PIN > 0
uint8_t channel,current;
if(code_seen('P')) channel=code_value();
if(code_seen('S')) current=code_value();
@@ -1731,9 +1830,9 @@ void process_commands()
break;
case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
{
- #if X_MS1_PIN > -1
- if(code_seen('S')) for(int i=0;i<=4;i++) microstep_mode(i,code_value());
- for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_mode(i,(uint8_t)code_value());
+ #if X_MS1_PIN > 0
+ if(code_seen('S')) for(int i=0;i<=4;i++) microstep_mode(i,code_value());
+ for(int i=0;i -1
+ #if X_MS1_PIN > 0
if(code_seen('S')) switch((int)code_value())
{
case 1:
- for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,code_value(),-1);
+ for(int i=0;i= EXTRUDERS) {
@@ -1791,7 +1890,7 @@ void process_commands()
// Offset extruder (only by XY)
int i;
for(i = 0; i < 2; i++) {
- current_position[i] = current_position[i] -
+ current_position[i] = current_position[i] -
extruder_offset[i][active_extruder] +
extruder_offset[i][tmp_extruder];
}
@@ -1837,14 +1936,14 @@ void ClearToSend()
if(fromsd[bufindr])
return;
#endif //SDSUPPORT
- SERIAL_PROTOCOLLNPGM(MSG_OK);
+ SERIAL_PROTOCOLLNPGM(MSG_OK);
}
void get_coordinates()
{
bool seen[4]={false,false,false,false};
for(int8_t i=0; i < NUM_AXIS; i++) {
- if(code_seen(axis_codes[i]))
+ if(code_seen(axis_codes[i]))
{
destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
seen[i]=true;
@@ -1862,23 +1961,23 @@ void get_coordinates()
float echange=destination[E_AXIS]-current_position[E_AXIS];
if(echange<-MIN_RETRACT) //retract
{
- if(!retracted)
+ if(!retracted)
{
-
+
destination[Z_AXIS]+=retract_zlift; //not sure why chaninging current_position negatively does not work.
//if slicer retracted by echange=-1mm and you want to retract 3mm, corrrectede=-2mm additionally
float correctede=-echange-retract_length;
//to generate the additional steps, not the destination is changed, but inversely the current position
- current_position[E_AXIS]+=-correctede;
+ current_position[E_AXIS]+=-correctede;
feedrate=retract_feedrate;
retracted=true;
}
-
+
}
- else
+ else
if(echange>MIN_RETRACT) //retract_recover
{
- if(retracted)
+ if(retracted)
{
//current_position[Z_AXIS]+=-retract_zlift;
//if slicer retracted_recovered by echange=+1mm and you want to retract_recover 3mm, corrrectede=2mm additionally
@@ -1888,7 +1987,7 @@ void get_coordinates()
retracted=false;
}
}
-
+
}
#endif //FWRETRACT
}
@@ -1906,7 +2005,7 @@ void get_arc_coordinates()
if(code_seen('I')) {
offset[0] = code_value();
- }
+ }
else {
offset[0] = 0.0;
}
@@ -1937,7 +2036,7 @@ void prepare_move()
{
clamp_to_software_endstops(destination);
- previous_millis_cmd = millis();
+ previous_millis_cmd = millis();
// Do not use feedmultiply for E or Z only moves
if( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) {
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
@@ -1955,7 +2054,7 @@ void prepare_arc_move(char isclockwise) {
// Trace the arc
mc_arc(current_position, destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate*feedmultiply/60/100.0, r, isclockwise, active_extruder);
-
+
// As far as the parser is concerned, the position is now == target. In reality the
// motion control system might still be processing the action and the real tool position
// in any intermediate location.
@@ -1974,20 +2073,20 @@ void controllerFan()
if ((millis() - lastMotorCheck) >= 2500) //Not a time critical function, so we only check every 2500ms
{
lastMotorCheck = millis();
-
+
if(!READ(X_ENABLE_PIN) || !READ(Y_ENABLE_PIN) || !READ(Z_ENABLE_PIN)
#if EXTRUDERS > 2
|| !READ(E2_ENABLE_PIN)
#endif
#if EXTRUDER > 1
- || !READ(E2_ENABLE_PIN)
+ || !READ(E1_ENABLE_PIN)
#endif
- || !READ(E0_ENABLE_PIN)) //If any of the drivers are enabled...
+ || !READ(E0_ENABLE_PIN)) //If any of the drivers are enabled...
{
lastMotor = millis(); //... set time to NOW so the fan will turn on
}
-
- if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000UL) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC...
+
+ if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000UL) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC...
{
WRITE(CONTROLLERFAN_PIN, LOW); //... turn the fan off
}
@@ -2007,7 +2106,7 @@ void extruderFan()
if ((millis() - lastExtruderCheck) >= 2500) //Not a time critical function, so we only check every 2500ms
{
lastExtruderCheck = millis();
-
+
if (degHotend(active_extruder) < EXTRUDERFAN_DEC)
{
WRITE(EXTRUDERFAN_PIN, LOW); //... turn the fan off
@@ -2020,13 +2119,13 @@ void extruderFan()
}
#endif
-void manage_inactivity()
-{
- if( (millis() - previous_millis_cmd) > max_inactive_time )
- if(max_inactive_time)
- kill();
+void manage_inactivity()
+{
+ if( (millis() - previous_millis_cmd) > max_inactive_time )
+ if(max_inactive_time)
+ kill();
if(stepper_inactive_time) {
- if( (millis() - previous_millis_cmd) > stepper_inactive_time )
+ if( (millis() - previous_millis_cmd) > stepper_inactive_time )
{
if(blocks_queued() == false) {
disable_x();
@@ -2046,15 +2145,15 @@ void manage_inactivity()
controllerFan(); //Check if fan should be turned on to cool stepper drivers down
#endif
#ifdef EXTRUDER_RUNOUT_PREVENT
- if( (millis() - previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 )
+ if( (millis() - previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 )
if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP)
{
bool oldstatus=READ(E0_ENABLE_PIN);
enable_e0();
float oldepos=current_position[E_AXIS];
float oldedes=destination[E_AXIS];
- plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
- current_position[E_AXIS]+EXTRUDER_RUNOUT_EXTRUDE*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS],
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
+ current_position[E_AXIS]+EXTRUDER_RUNOUT_EXTRUDE*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS],
EXTRUDER_RUNOUT_SPEED/60.*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS], active_extruder);
current_position[E_AXIS]=oldepos;
destination[E_AXIS]=oldedes;
@@ -2078,8 +2177,8 @@ void kill()
disable_e0();
disable_e1();
disable_e2();
-
- if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
+
+ if(PS_ON_PIN > 0) pinMode(PS_ON_PIN,INPUT);
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
LCD_ALERTMESSAGEPGM(MSG_KILLED);
@@ -2107,7 +2206,7 @@ void setPwmFrequency(uint8_t pin, int val)
val &= 0x07;
switch(digitalPinToTimer(pin))
{
-
+
#if defined(TCCR0A)
case TIMER0A:
case TIMER0B:
@@ -2149,7 +2248,7 @@ void setPwmFrequency(uint8_t pin, int val)
break;
#endif
- #if defined(TCCR4A)
+ #if defined(TCCR4A)
case TIMER4A:
case TIMER4B:
case TIMER4C:
@@ -2158,7 +2257,7 @@ void setPwmFrequency(uint8_t pin, int val)
break;
#endif
- #if defined(TCCR5A)
+ #if defined(TCCR5A)
case TIMER5A:
case TIMER5B:
case TIMER5C:
diff --git a/Marlin/Servo.cpp b/Marlin/Servo.cpp
new file mode 100644
index 000000000..02138b582
--- /dev/null
+++ b/Marlin/Servo.cpp
@@ -0,0 +1,337 @@
+/*
+ Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
+ Copyright (c) 2009 Michael Margolis. All right reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+
+ A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
+ The servos are pulsed in the background using the value most recently written using the write() method
+
+ Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
+ Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
+
+ The methods are:
+
+ Servo - Class for manipulating servo motors connected to Arduino pins.
+
+ attach(pin ) - Attaches a servo motor to an i/o pin.
+ attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds
+ default min is 544, max is 2400
+
+ write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds)
+ writeMicroseconds() - Sets the servo pulse width in microseconds
+ read() - Gets the last written servo pulse width as an angle between 0 and 180.
+ readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
+ attached() - Returns true if there is a servo attached.
+ detach() - Stops an attached servos from pulsing its i/o pin.
+
+*/
+
+#include
+#include
+
+#include "Servo.h"
+
+#define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009
+#define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds
+
+
+#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009
+
+//#define NBR_TIMERS (MAX_SERVOS / SERVOS_PER_TIMER)
+
+static servo_t servos[MAX_SERVOS]; // static array of servo structures
+static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval)
+
+uint8_t ServoCount = 0; // the total number of attached servos
+
+
+// convenience macros
+#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo
+#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer
+#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel
+#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel
+
+#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo
+#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo
+
+/************ static functions common to all instances ***********************/
+
+static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t *TCNTn, volatile uint16_t* OCRnA)
+{
+ if( Channel[timer] < 0 )
+ *TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer
+ else{
+ if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true )
+ digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW); // pulse this channel low if activated
+ }
+
+ Channel[timer]++; // increment to the next channel
+ if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
+ *OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks;
+ if(SERVO(timer,Channel[timer]).Pin.isActive == true) // check if activated
+ digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high
+ }
+ else {
+ // finished all channels so wait for the refresh period to expire before starting over
+ if( ((unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) ) // allow a few ticks to ensure the next OCR1A not missed
+ *OCRnA = (unsigned int)usToTicks(REFRESH_INTERVAL);
+ else
+ *OCRnA = *TCNTn + 4; // at least REFRESH_INTERVAL has elapsed
+ Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel
+ }
+}
+
+#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform
+// Interrupt handlers for Arduino
+#if defined(_useTimer1)
+SIGNAL (TIMER1_COMPA_vect)
+{
+ handle_interrupts(_timer1, &TCNT1, &OCR1A);
+}
+#endif
+
+#if defined(_useTimer3)
+SIGNAL (TIMER3_COMPA_vect)
+{
+ handle_interrupts(_timer3, &TCNT3, &OCR3A);
+}
+#endif
+
+#if defined(_useTimer4)
+SIGNAL (TIMER4_COMPA_vect)
+{
+ handle_interrupts(_timer4, &TCNT4, &OCR4A);
+}
+#endif
+
+#if defined(_useTimer5)
+SIGNAL (TIMER5_COMPA_vect)
+{
+ handle_interrupts(_timer5, &TCNT5, &OCR5A);
+}
+#endif
+
+#elif defined WIRING
+// Interrupt handlers for Wiring
+#if defined(_useTimer1)
+void Timer1Service()
+{
+ handle_interrupts(_timer1, &TCNT1, &OCR1A);
+}
+#endif
+#if defined(_useTimer3)
+void Timer3Service()
+{
+ handle_interrupts(_timer3, &TCNT3, &OCR3A);
+}
+#endif
+#endif
+
+
+static void initISR(timer16_Sequence_t timer)
+{
+#if defined (_useTimer1)
+ if(timer == _timer1) {
+ TCCR1A = 0; // normal counting mode
+ TCCR1B = _BV(CS11); // set prescaler of 8
+ TCNT1 = 0; // clear the timer count
+#if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__)
+ TIFR |= _BV(OCF1A); // clear any pending interrupts;
+ TIMSK |= _BV(OCIE1A) ; // enable the output compare interrupt
+#else
+ // here if not ATmega8 or ATmega128
+ TIFR1 |= _BV(OCF1A); // clear any pending interrupts;
+ TIMSK1 |= _BV(OCIE1A) ; // enable the output compare interrupt
+#endif
+#if defined(WIRING)
+ timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
+#endif
+ }
+#endif
+
+#if defined (_useTimer3)
+ if(timer == _timer3) {
+ TCCR3A = 0; // normal counting mode
+ TCCR3B = _BV(CS31); // set prescaler of 8
+ TCNT3 = 0; // clear the timer count
+#if defined(__AVR_ATmega128__)
+ TIFR |= _BV(OCF3A); // clear any pending interrupts;
+ ETIMSK |= _BV(OCIE3A); // enable the output compare interrupt
+#else
+ TIFR3 = _BV(OCF3A); // clear any pending interrupts;
+ TIMSK3 = _BV(OCIE3A) ; // enable the output compare interrupt
+#endif
+#if defined(WIRING)
+ timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only
+#endif
+ }
+#endif
+
+#if defined (_useTimer4)
+ if(timer == _timer4) {
+ TCCR4A = 0; // normal counting mode
+ TCCR4B = _BV(CS41); // set prescaler of 8
+ TCNT4 = 0; // clear the timer count
+ TIFR4 = _BV(OCF4A); // clear any pending interrupts;
+ TIMSK4 = _BV(OCIE4A) ; // enable the output compare interrupt
+ }
+#endif
+
+#if defined (_useTimer5)
+ if(timer == _timer5) {
+ TCCR5A = 0; // normal counting mode
+ TCCR5B = _BV(CS51); // set prescaler of 8
+ TCNT5 = 0; // clear the timer count
+ TIFR5 = _BV(OCF5A); // clear any pending interrupts;
+ TIMSK5 = _BV(OCIE5A) ; // enable the output compare interrupt
+ }
+#endif
+}
+
+static void finISR(timer16_Sequence_t timer)
+{
+ //disable use of the given timer
+#if defined WIRING // Wiring
+ if(timer == _timer1) {
+ #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
+ TIMSK1 &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
+ #else
+ TIMSK &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
+ #endif
+ timerDetach(TIMER1OUTCOMPAREA_INT);
+ }
+ else if(timer == _timer3) {
+ #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
+ TIMSK3 &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
+ #else
+ ETIMSK &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
+ #endif
+ timerDetach(TIMER3OUTCOMPAREA_INT);
+ }
+#else
+ //For arduino - in future: call here to a currently undefined function to reset the timer
+#endif
+}
+
+static boolean isTimerActive(timer16_Sequence_t timer)
+{
+ // returns true if any servo is active on this timer
+ for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) {
+ if(SERVO(timer,channel).Pin.isActive == true)
+ return true;
+ }
+ return false;
+}
+
+
+/****************** end of static functions ******************************/
+
+Servo::Servo()
+{
+ if( ServoCount < MAX_SERVOS) {
+ this->servoIndex = ServoCount++; // assign a servo index to this instance
+ servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - 12 Aug 2009
+ }
+ else
+ this->servoIndex = INVALID_SERVO ; // too many servos
+}
+
+uint8_t Servo::attach(int pin)
+{
+ return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
+}
+
+uint8_t Servo::attach(int pin, int min, int max)
+{
+ if(this->servoIndex < MAX_SERVOS ) {
+ pinMode( pin, OUTPUT) ; // set servo pin to output
+ servos[this->servoIndex].Pin.nbr = pin;
+ // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128
+ this->min = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS
+ this->max = (MAX_PULSE_WIDTH - max)/4;
+ // initialize the timer if it has not already been initialized
+ timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
+ if(isTimerActive(timer) == false)
+ initISR(timer);
+ servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive
+ }
+ return this->servoIndex ;
+}
+
+void Servo::detach()
+{
+ servos[this->servoIndex].Pin.isActive = false;
+ timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
+ if(isTimerActive(timer) == false) {
+ finISR(timer);
+ }
+}
+
+void Servo::write(int value)
+{
+ if(value < MIN_PULSE_WIDTH)
+ { // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
+ if(value < 0) value = 0;
+ if(value > 180) value = 180;
+ value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX());
+ }
+ this->writeMicroseconds(value);
+}
+
+void Servo::writeMicroseconds(int value)
+{
+ // calculate and store the values for the given channel
+ byte channel = this->servoIndex;
+ if( (channel < MAX_SERVOS) ) // ensure channel is valid
+ {
+ if( value < SERVO_MIN() ) // ensure pulse width is valid
+ value = SERVO_MIN();
+ else if( value > SERVO_MAX() )
+ value = SERVO_MAX();
+
+ value = value - TRIM_DURATION;
+ value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009
+
+ uint8_t oldSREG = SREG;
+ cli();
+ servos[channel].ticks = value;
+ SREG = oldSREG;
+ }
+}
+
+int Servo::read() // return the value as degrees
+{
+ return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180);
+}
+
+int Servo::readMicroseconds()
+{
+ unsigned int pulsewidth;
+ if( this->servoIndex != INVALID_SERVO )
+ pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION ; // 12 aug 2009
+ else
+ pulsewidth = 0;
+
+ return pulsewidth;
+}
+
+bool Servo::attached()
+{
+ return servos[this->servoIndex].Pin.isActive ;
+}
diff --git a/Marlin/Servo.h b/Marlin/Servo.h
new file mode 100644
index 000000000..17c99f797
--- /dev/null
+++ b/Marlin/Servo.h
@@ -0,0 +1,132 @@
+/*
+ Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
+ Copyright (c) 2009 Michael Margolis. All right reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+/*
+
+ A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
+ The servos are pulsed in the background using the value most recently written using the write() method
+
+ Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
+ Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
+ The sequence used to sieze timers is defined in timers.h
+
+ The methods are:
+
+ Servo - Class for manipulating servo motors connected to Arduino pins.
+
+ attach(pin ) - Attaches a servo motor to an i/o pin.
+ attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds
+ default min is 544, max is 2400
+
+ write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds)
+ writeMicroseconds() - Sets the servo pulse width in microseconds
+ read() - Gets the last written servo pulse width as an angle between 0 and 180.
+ readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
+ attached() - Returns true if there is a servo attached.
+ detach() - Stops an attached servos from pulsing its i/o pin.
+ */
+
+#ifndef Servo_h
+#define Servo_h
+
+#include
+
+/*
+ * Defines for 16 bit timers used with Servo library
+ *
+ * If _useTimerX is defined then TimerX is a 16 bit timer on the curent board
+ * timer16_Sequence_t enumerates the sequence that the timers should be allocated
+ * _Nbr_16timers indicates how many 16 bit timers are available.
+ *
+ */
+
+// Say which 16 bit timers can be used and in what order
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
+#define _useTimer5
+//#define _useTimer1
+#define _useTimer3
+#define _useTimer4
+//typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
+typedef enum { _timer5, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
+
+#elif defined(__AVR_ATmega32U4__)
+//#define _useTimer1
+#define _useTimer3
+//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
+typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
+
+#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
+#define _useTimer3
+//#define _useTimer1
+//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
+typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
+
+#elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
+#define _useTimer3
+//#define _useTimer1
+//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
+typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
+
+#else // everything else
+//#define _useTimer1
+//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
+typedef enum { _Nbr_16timers } timer16_Sequence_t ;
+#endif
+
+#define Servo_VERSION 2 // software version of this library
+
+#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo
+#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo
+#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached
+#define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds
+
+#define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer
+#define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER)
+
+#define INVALID_SERVO 255 // flag indicating an invalid servo index
+
+typedef struct {
+ uint8_t nbr :6 ; // a pin number from 0 to 63
+ uint8_t isActive :1 ; // true if this channel is enabled, pin not pulsed if false
+} ServoPin_t ;
+
+typedef struct {
+ ServoPin_t Pin;
+ unsigned int ticks;
+} servo_t;
+
+class Servo
+{
+public:
+ Servo();
+ uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
+ uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
+ void detach();
+ void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
+ void writeMicroseconds(int value); // Write pulse width in microseconds
+ int read(); // returns current pulse width as an angle between 0 and 180 degrees
+ int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release)
+ bool attached(); // return true if this servo is attached, otherwise false
+private:
+ uint8_t servoIndex; // index into the channel data for this servo
+ int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH
+ int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH
+};
+
+#endif
diff --git a/Marlin/pins.h b/Marlin/pins.h
index e752b8380..c8275e477 100644
--- a/Marlin/pins.h
+++ b/Marlin/pins.h
@@ -248,14 +248,14 @@
#define E0_STEP_PIN 28
#define E0_DIR_PIN 27
#define E0_ENABLE_PIN 24
-
+
#define TEMP_0_PIN 2
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define TEMP_BED_PIN 1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 34 bed)
-
+
#define HEATER_0_PIN 4
- #define HEATER_1_PIN -1
+ #define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define HEATER_BED_PIN 3 // (bed)
@@ -272,24 +272,25 @@
//our RS485 pins
//#define TX_ENABLE_PIN 12
//#define RX_ENABLE_PIN 13
-
- #define BEEPER -1
- #define SDCARDDETECT -1
- #define SUICIDE_PIN -1 //has to be defined; otherwise Power_off doesn't work
-
+
+ #define BEEPER -1
+ #define SDCARDDETECT -1
+ #define SUICIDE_PIN -1 //has to be defined; otherwise Power_off doesn't work
+
#define KILL_PIN -1
- //Pins for 4bit LCD Support
- #define LCD_PINS_RS 18
+ //Pins for 4bit LCD Support
+ #define LCD_PINS_RS 18
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 16
- #define LCD_PINS_D5 15
+ #define LCD_PINS_D5 15
#define LCD_PINS_D6 13
#define LCD_PINS_D7 14
-
+
//buttons are directly attached
#define BTN_EN1 11
#define BTN_EN2 10
#define BTN_ENC 12 //the click
+
#endif
/****************************************************************************************
@@ -367,23 +368,28 @@
#else
#define HEATER_1_PIN 9 // EXTRUDER 2 (FAN On Sprinter)
#endif
-#define HEATER_2_PIN -1
+#define HEATER_2_PIN -1
#define TEMP_0_PIN 13 // ANALOG NUMBERING
#define TEMP_1_PIN 15 // ANALOG NUMBERING
#define TEMP_2_PIN -1 // ANALOG NUMBERING
#define HEATER_BED_PIN 8 // BED
#define TEMP_BED_PIN 14 // ANALOG NUMBERING
+#define SERVO0_PIN 11
+#define SERVO1_PIN 6
+#define SERVO2_PIN 5
+#define SERVO3_PIN 4
+
#ifdef ULTRA_LCD
#ifdef NEWPANEL
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
- #define LCD_PINS_D5 25
+ #define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
-
+
#ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
#define BEEPER 37
@@ -397,9 +403,18 @@
#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
+ #ifdef REPRAPWORLD_KEYPAD
+ #define BTN_EN1 64 // encoder
+ #define BTN_EN2 59 // encoder
+ #define BTN_ENC 63 // enter button
+ #define SHIFT_OUT 40 // shift register
+ #define SHIFT_CLK 44 // shift register
+ #define SHIFT_LD 42 // shift register
+ #else
+ #define BTN_EN1 37
+ #define BTN_EN2 35
+ #define BTN_ENC 31 //the click
+ #endif
#ifdef G3D_PANEL
#define SDCARDDETECT 49
@@ -418,11 +433,11 @@
//#define SHIFT_LD 42
//#define SHIFT_OUT 40
//#define SHIFT_EN 17
-
- #define LCD_PINS_RS 16
+
+ #define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
- #define LCD_PINS_D5 25
+ #define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif
@@ -470,15 +485,15 @@
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 2 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
-#define TEMP_1_PIN -1
-#define TEMP_2_PIN -1
+#define TEMP_1_PIN -1
+#define TEMP_2_PIN -1
#define TEMP_BED_PIN 1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#endif// MOTHERBOARD == 33 || MOTHERBOARD == 34
-// SPI for Max6675 Thermocouple
+// SPI for Max6675 Thermocouple
#ifndef SDSUPPORT
-// these pins are defined in the SD library if building with SD support
+// these pins are defined in the SD library if building with SD support
#define MAX_SCK_PIN 52
#define MAX_MISO_PIN 50
#define MAX_MOSI_PIN 51
@@ -530,8 +545,8 @@
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define TEMP_0_PIN 0 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
-#define TEMP_1_PIN -1
-#define TEMP_2_PIN -1
+#define TEMP_1_PIN -1
+#define TEMP_2_PIN -1
#define HEATER_BED_PIN -1
#define TEMP_BED_PIN -1
@@ -594,14 +609,14 @@
#define PS_ON_PIN -1 //changed @ rkoeppl 20110410
#define KILL_PIN -1 //changed @ drakelive 20120830
//our pin for debugging.
-
+
#define DEBUG_PIN 0
-
+
//our RS485 pins
#define TX_ENABLE_PIN 12
#define RX_ENABLE_PIN 13
-
+
#endif
/****************************************************************************************
@@ -617,7 +632,7 @@
#if MOTHERBOARD == 62 || MOTHERBOARD == 63 || MOTHERBOARD == 64
#undef MOTHERBOARD
#define MOTHERBOARD 6
-#define SANGUINOLOLU_V_1_2
+#define SANGUINOLOLU_V_1_2
#endif
#if MOTHERBOARD == 6
#define KNOWN_BOARD 1
@@ -644,7 +659,7 @@
#define LED_PIN -1
-#define FAN_PIN -1
+#define FAN_PIN -1
#if FAN_PIN == 12 || FAN_PIN ==13
#define FAN_SOFT_PWM
#endif
@@ -726,7 +741,7 @@
#endif //Newpanel
#endif //Ultipanel
-
+
#endif
@@ -756,17 +771,17 @@
#define Y_MAX_PIN 28
#define Y_ENABLE_PIN 29
-#define Z_STEP_PIN 37
+#define Z_STEP_PIN 37
#define Z_DIR_PIN 39
#define Z_MIN_PIN 30
#define Z_MAX_PIN 32
#define Z_ENABLE_PIN 35
-#define HEATER_BED_PIN 4
-#define TEMP_BED_PIN 10
+#define HEATER_BED_PIN 4
+#define TEMP_BED_PIN 10
#define HEATER_0_PIN 2
-#define TEMP_0_PIN 8
+#define TEMP_0_PIN 8
#define HEATER_1_PIN 3
#define TEMP_1_PIN 9
@@ -796,13 +811,13 @@
//arduino pin witch triggers an piezzo beeper
#define BEEPER 18
- #define LCD_PINS_RS 20
+ #define LCD_PINS_RS 20
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 16
- #define LCD_PINS_D5 21
+ #define LCD_PINS_D5 21
#define LCD_PINS_D6 5
#define LCD_PINS_D7 6
-
+
//buttons are directly attached
#define BTN_EN1 40
#define BTN_EN2 42
@@ -819,11 +834,11 @@
#define SHIFT_LD 42
#define SHIFT_OUT 40
#define SHIFT_EN 17
-
- #define LCD_PINS_RS 16
+
+ #define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 5
#define LCD_PINS_D4 6
- #define LCD_PINS_D5 21
+ #define LCD_PINS_D5 21
#define LCD_PINS_D6 20
#define LCD_PINS_D7 19
@@ -859,17 +874,17 @@
#define Y_MAX_PIN 16
#define Y_ENABLE_PIN 29
-#define Z_STEP_PIN 37
+#define Z_STEP_PIN 37
#define Z_DIR_PIN 39
#define Z_MIN_PIN 19
#define Z_MAX_PIN 18
#define Z_ENABLE_PIN 35
-#define HEATER_BED_PIN -1
-#define TEMP_BED_PIN -1
+#define HEATER_BED_PIN -1
+#define TEMP_BED_PIN -1
#define HEATER_0_PIN 2
-#define TEMP_0_PIN 8
+#define TEMP_0_PIN 8
#define HEATER_1_PIN 1
#define TEMP_1_PIN 1
@@ -893,10 +908,10 @@
#define KILL_PIN -1
#define SUICIDE_PIN -1 //PIN that has to be turned on right after start, to keep power flowing.
-#define LCD_PINS_RS 24
+#define LCD_PINS_RS 24
#define LCD_PINS_ENABLE 22
#define LCD_PINS_D4 36
-#define LCD_PINS_D5 34
+#define LCD_PINS_D5 34
#define LCD_PINS_D6 32
#define LCD_PINS_D7 30
@@ -918,17 +933,17 @@
#define X_DIR_PIN 16
#define X_ENABLE_PIN 48
#define X_MIN_PIN 37
-#define X_MAX_PIN 36
+#define X_MAX_PIN 36
#define Y_STEP_PIN 54
-#define Y_DIR_PIN 47
+#define Y_DIR_PIN 47
#define Y_ENABLE_PIN 55
#define Y_MIN_PIN 35
-#define Y_MAX_PIN 34
+#define Y_MAX_PIN 34
-#define Z_STEP_PIN 57
+#define Z_STEP_PIN 57
#define Z_DIR_PIN 56
-#define Z_ENABLE_PIN 62
+#define Z_ENABLE_PIN 62
#define Z_MIN_PIN 33
#define Z_MAX_PIN 32
@@ -946,32 +961,71 @@
#define LED_PIN 13
-#define FAN_PIN 7
+#define FAN_PIN 7
//additional FAN1 PIN (e.g. useful for electronics fan or light on/off) on PIN 8
#define PS_ON_PIN 45
#define KILL_PIN 46
-#define HEATER_0_PIN 2 // EXTRUDER 1
-#define HEATER_1_PIN 3 // EXTRUDER 2
-#define HEATER_2_PIN 6 // EXTRUDER 3
-//optional FAN1 can be used as 4th heater output: #define HEATER_3_PIN 8 // EXTRUDER 4
-#define HEATER_BED_PIN 9 // BED
+#if (TEMP_SENSOR_0==0)
+ #define TEMP_0_PIN -1
+ #define HEATER_0_PIN -1
+#else
+ #define HEATER_0_PIN 2 // EXTRUDER 1
+ #if (TEMP_SENSOR_0==-1)
+ #define TEMP_0_PIN 6 // ANALOG NUMBERING - connector *K1* on RUMBA thermocouple ADD ON is used
+ #else
+ #define TEMP_0_PIN 15 // ANALOG NUMBERING - default connector for thermistor *T0* on rumba board is used
+ #endif
+#endif
-#define TEMP_0_PIN 15 // ANALOG NUMBERING
-#define TEMP_1_PIN 14 // ANALOG NUMBERING
-#define TEMP_2_PIN 13 // ANALOG NUMBERING
-//optional for extruder 4 or chamber: #define TEMP_2_PIN 12 // ANALOG NUMBERING
-#define TEMP_BED_PIN 11 // ANALOG NUMBERING
+#if (TEMP_SENSOR_1==0)
+ #define TEMP_1_PIN -1
+ #define HEATER_1_PIN -1
+#else
+ #define HEATER_1_PIN 3 // EXTRUDER 2
+ #if (TEMP_SENSOR_1==-1)
+ #define TEMP_1_PIN 5 // ANALOG NUMBERING - connector *K2* on RUMBA thermocouple ADD ON is used
+ #else
+ #define TEMP_1_PIN 14 // ANALOG NUMBERING - default connector for thermistor *T1* on rumba board is used
+ #endif
+#endif
+
+#if (TEMP_SENSOR_2==0)
+ #define TEMP_2_PIN -1
+ #define HEATER_2_PIN -1
+#else
+ #define HEATER_2_PIN 6 // EXTRUDER 3
+ #if (TEMP_SENSOR_2==-1)
+ #define TEMP_2_PIN 7 // ANALOG NUMBERING - connector *K3* on RUMBA thermocouple ADD ON is used <-- this can not be used when TEMP_SENSOR_BED is defined as thermocouple
+ #else
+ #define TEMP_2_PIN 13 // ANALOG NUMBERING - default connector for thermistor *T2* on rumba board is used
+ #endif
+#endif
+
+//optional for extruder 4 or chamber: #define TEMP_X_PIN 12 // ANALOG NUMBERING - default connector for thermistor *T3* on rumba board is used
+//optional FAN1 can be used as 4th heater output: #define HEATER_3_PIN 8 // EXTRUDER 4
+
+#if (TEMP_SENSOR_BED==0)
+ #define TEMP_BED_PIN -1
+ #define HEATER_BED_PIN -1
+#else
+ #define HEATER_BED_PIN 9 // BED
+ #if (TEMP_SENSOR_BED==-1)
+ #define TEMP_BED_PIN 7 // ANALOG NUMBERING - connector *K3* on RUMBA thermocouple ADD ON is used <-- this can not be used when TEMP_SENSOR_2 is defined as thermocouple
+ #else
+ #define TEMP_BED_PIN 11 // ANALOG NUMBERING - default connector for thermistor *THB* on rumba board is used
+ #endif
+#endif
#define SDPOWER -1
#define SDSS 53
#define SDCARDDETECT 49
#define BEEPER 44
-#define LCD_PINS_RS 19
+#define LCD_PINS_RS 19
#define LCD_PINS_ENABLE 42
#define LCD_PINS_D4 18
-#define LCD_PINS_D5 38
+#define LCD_PINS_D5 38
#define LCD_PINS_D6 41
#define LCD_PINS_D7 40
#define BTN_EN1 11
@@ -1147,7 +1201,7 @@
#define LED_PIN -1
-#define FAN_PIN -1
+#define FAN_PIN -1
#define PS_ON_PIN 14
#define KILL_PIN -1
@@ -1186,7 +1240,7 @@
* MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25)
* SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24)
* RST 9| |32 AREF
-* VCC 10| |31 GND
+* VCC 10| |31 GND
* GND 11| |30 AVCC
* XTAL2 12| |29 PC7 (D 23)
* XTAL1 13| |28 PC6 (D 22)
@@ -1243,7 +1297,7 @@
#define KILL_PIN -1
#define HEATER_0_PIN 4
-#define HEATER_1_PIN -1 // 12
+#define HEATER_1_PIN -1 // 12
#define HEATER_2_PIN -1 // 13
#define TEMP_0_PIN 0 //D27 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1 // 1
@@ -1305,11 +1359,11 @@
#define KILL_PIN -1
#define HEATER_0_PIN 3 /*DONE PWM on RIGHT connector */
-#define HEATER_1_PIN -1
+#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
-#define HEATER_1_PIN -1
+#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
-#define TEMP_0_PIN 0 // ANALOG INPUT NUMBERING
+#define TEMP_0_PIN 0 // ANALOG INPUT NUMBERING
#define TEMP_1_PIN 1 // ANALOG
#define TEMP_2_PIN -1 // 2
#define HEATER_BED_PIN 4
@@ -1357,7 +1411,7 @@
#define Z_MS2_PIN 67
#define HEATER_BED_PIN 3
-#define TEMP_BED_PIN 2
+#define TEMP_BED_PIN 2
#define HEATER_0_PIN 9
#define TEMP_0_PIN 0
@@ -1365,7 +1419,11 @@
#define HEATER_1_PIN 7
#define TEMP_1_PIN 1
+#ifdef BARICUDA
+#define HEATER_2_PIN 6
+#else
#define HEATER_2_PIN -1
+#endif
#define TEMP_2_PIN -1
#define E0_STEP_PIN 34
@@ -1446,9 +1504,9 @@
#define HEATER_0_PIN 9 // EXTRUDER 1
#define HEATER_1_PIN 8 // EXTRUDER 2 (FAN On Sprinter)
-#define HEATER_2_PIN -1
+#define HEATER_2_PIN -1
-#if TEMP_SENSOR_0 == -1
+#if TEMP_SENSOR_0 == -1
#define TEMP_0_PIN 8 // ANALOG NUMBERING
#else
#define TEMP_0_PIN 13 // ANALOG NUMBERING
@@ -1467,14 +1525,14 @@
#ifdef NEWPANEL
//arduino pin which triggers an piezzo beeper
-
- #define LCD_PINS_RS 16
+
+ #define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
- #define LCD_PINS_D5 25
+ #define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
-
+
//buttons are directly attached using AUX-2
#define BTN_EN1 59
#define BTN_EN2 64
@@ -1491,7 +1549,7 @@
#endif
//List of pins which to ignore when asked to change by gcode, 0 and 1 are RX and TX, do not mess with those!
-#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, HEATER_0_PIN,
+#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, HEATER_0_PIN,
#if EXTRUDERS > 1
#define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, HEATER_1_PIN,
#else
diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp
index e45c9d7ff..35bda428f 100644
--- a/Marlin/planner.cpp
+++ b/Marlin/planner.cpp
@@ -439,12 +439,20 @@ void check_axes_activity()
unsigned char z_active = 0;
unsigned char e_active = 0;
unsigned char tail_fan_speed = fanSpeed;
+ #ifdef BARICUDA
+ unsigned char tail_valve_pressure = ValvePressure;
+ unsigned char tail_e_to_p_pressure = EtoPPressure;
+ #endif
block_t *block;
if(block_buffer_tail != block_buffer_head)
{
uint8_t block_index = block_buffer_tail;
tail_fan_speed = block_buffer[block_index].fan_speed;
+ #ifdef BARICUDA
+ tail_valve_pressure = block_buffer[block_index].valve_pressure;
+ tail_e_to_p_pressure = block_buffer[block_index].e_to_p_pressure;
+ #endif
while(block_index != block_buffer_head)
{
block = &block_buffer[block_index];
@@ -486,6 +494,16 @@ void check_axes_activity()
#ifdef AUTOTEMP
getHighESpeed();
#endif
+
+#ifdef BARICUDA
+ #if HEATER_1_PIN > -1
+ analogWrite(HEATER_1_PIN,tail_valve_pressure);
+ #endif
+
+ #if HEATER_2_PIN > -1
+ analogWrite(HEATER_2_PIN,tail_e_to_p_pressure);
+ #endif
+#endif
}
@@ -559,6 +577,10 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
}
block->fan_speed = fanSpeed;
+ #ifdef BARICUDA
+ block->valve_pressure = ValvePressure;
+ block->e_to_p_pressure = EtoPPressure;
+ #endif
// Compute direction bits for this block
block->direction_bits = 0;
@@ -582,8 +604,16 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
block->active_extruder = extruder;
//enable active axes
+ #ifdef COREXY
+ if((block->steps_x != 0) || (block->steps_y != 0))
+ {
+ enable_x();
+ enable_y();
+ }
+ #else
if(block->steps_x != 0) enable_x();
if(block->steps_y != 0) enable_y();
+ #endif
#ifndef Z_LATE_ENABLE
if(block->steps_z != 0) enable_z();
#endif
diff --git a/Marlin/planner.h b/Marlin/planner.h
index 9a904e577..703646eb1 100644
--- a/Marlin/planner.h
+++ b/Marlin/planner.h
@@ -60,6 +60,10 @@ typedef struct {
unsigned long final_rate; // The minimal rate at exit
unsigned long acceleration_st; // acceleration steps/sec^2
unsigned long fan_speed;
+ #ifdef BARICUDA
+ unsigned long valve_pressure;
+ unsigned long e_to_p_pressure;
+ #endif
volatile char busy;
} block_t;
diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp
index 85017750b..18cdec65f 100644
--- a/Marlin/temperature.cpp
+++ b/Marlin/temperature.cpp
@@ -571,6 +571,12 @@ static void updateTemperaturesFromRawValues()
void tp_init()
{
+#if (MOTHERBOARD == 80) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
+ //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
+ MCUCR=(1< -1)
@@ -689,7 +695,7 @@ void tp_init()
#if (EXTRUDERS > 1) && defined(HEATER_1_MINTEMP)
minttemp[1] = HEATER_1_MINTEMP;
- while(analog2temp(minttemp_raw[1], 1) > HEATER_1_MINTEMP) {
+ while(analog2temp(minttemp_raw[1], 1) < HEATER_1_MINTEMP) {
#if HEATER_1_RAW_LO_TEMP < HEATER_1_RAW_HI_TEMP
minttemp_raw[1] += OVERSAMPLENR;
#else
@@ -710,7 +716,7 @@ void tp_init()
#if (EXTRUDERS > 2) && defined(HEATER_2_MINTEMP)
minttemp[2] = HEATER_2_MINTEMP;
- while(analog2temp(minttemp_raw[2], 2) > HEATER_2_MINTEMP) {
+ while(analog2temp(minttemp_raw[2], 2) < HEATER_2_MINTEMP) {
#if HEATER_2_RAW_LO_TEMP < HEATER_2_RAW_HI_TEMP
minttemp_raw[2] += OVERSAMPLENR;
#else
diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp
index 72404da03..92c659209 100644
--- a/Marlin/ultralcd.cpp
+++ b/Marlin/ultralcd.cpp
@@ -116,14 +116,18 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
} } while(0)
/** Used variables to keep track of the menu */
+#ifndef REPRAPWORLD_KEYPAD
volatile uint8_t buttons;//Contains the bits of the currently pressed buttons.
+#else
+volatile uint16_t buttons;//Contains the bits of the currently pressed buttons (extended).
+#endif
uint8_t currentMenuViewOffset; /* scroll offset in the current menu */
uint32_t blocking_enc;
uint8_t lastEncoderBits;
int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
uint32_t encoderPosition;
-#if (SDCARDDETECT > -1)
+#if (SDCARDDETECT > 0)
bool lcd_oldcardstatus;
#endif
#endif//ULTIPANEL
@@ -225,14 +229,14 @@ static void lcd_main_menu()
}else{
MENU_ITEM(submenu, MSG_CARD_MENU, lcd_sdcard_menu);
#if SDCARDDETECT < 1
- MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21")); // SD-card changed by user
-#endif
+ MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21")); // SD-card changed by user
+#endif
}
}else{
MENU_ITEM(submenu, MSG_NO_CARD, lcd_sdcard_menu);
-#if SDCARDDETECT < 1
- MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
-#endif
+#if SDCARDDETECT < 1
+ MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
+#endif
}
#endif
END_MENU();
@@ -255,6 +259,7 @@ void lcd_preheat_pla()
setTargetBed(plaPreheatHPBTemp);
fanSpeed = plaPreheatFanSpeed;
lcd_return_to_status();
+ setWatch(); // heater sanity check timer
}
void lcd_preheat_abs()
@@ -265,6 +270,16 @@ void lcd_preheat_abs()
setTargetBed(absPreheatHPBTemp);
fanSpeed = absPreheatFanSpeed;
lcd_return_to_status();
+ setWatch(); // heater sanity check timer
+}
+
+static void lcd_cooldown()
+{
+ setTargetHotend0(0);
+ setTargetHotend1(0);
+ setTargetHotend2(0);
+ setTargetBed(0);
+ lcd_return_to_status();
}
static void lcd_tune_menu()
@@ -302,7 +317,7 @@ static void lcd_prepare_menu()
//MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
MENU_ITEM(function, MSG_PREHEAT_PLA, lcd_preheat_pla);
MENU_ITEM(function, MSG_PREHEAT_ABS, lcd_preheat_abs);
- MENU_ITEM(gcode, MSG_COOLDOWN, PSTR("M104 S0\nM140 S0"));
+ MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);
END_MENU();
}
@@ -463,10 +478,10 @@ static void lcd_control_menu()
static void lcd_control_temperature_menu()
{
- // set up temp variables - undo the default scaling
- raw_Ki = unscalePID_i(Ki);
- raw_Kd = unscalePID_d(Kd);
-
+ // set up temp variables - undo the default scaling
+ raw_Ki = unscalePID_i(Ki);
+ raw_Kd = unscalePID_d(Kd);
+
START_MENU();
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
@@ -488,7 +503,7 @@ static void lcd_control_temperature_menu()
#endif
#ifdef PIDTEMP
MENU_ITEM_EDIT(float52, MSG_PID_P, &Kp, 1, 9990);
- // i is typically a small value so allows values below 1
+ // i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d);
# ifdef PID_ADD_EXTRUSION_RATE
@@ -691,6 +706,24 @@ menu_edit_type(float, float51, ftostr51, 10)
menu_edit_type(float, float52, ftostr52, 100)
menu_edit_type(unsigned long, long5, ftostr5, 0.01)
+#ifdef REPRAPWORLD_KEYPAD
+ static void reprapworld_keypad_move_y_down() {
+ encoderPosition = 1;
+ move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
+ lcd_move_y();
+ }
+ static void reprapworld_keypad_move_y_up() {
+ encoderPosition = -1;
+ move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
+ lcd_move_y();
+ }
+ static void reprapworld_keypad_move_home() {
+ //enquecommand_P((PSTR("G28"))); // move all axis home
+ // TODO gregor: move all axis home, i have currently only one axis on my prusa i3
+ enquecommand_P((PSTR("G28 Y")));
+ }
+#endif
+
/** End of menus **/
static void lcd_quick_feedback()
@@ -752,10 +785,17 @@ void lcd_init()
pinMode(SDCARDDETECT,INPUT);
WRITE(BTN_EN1,HIGH);
WRITE(BTN_EN2,HIGH);
- #if defined(BTN_ENC) && BTN_ENC > -1
+ #if BTN_ENC > 0
pinMode(BTN_ENC,INPUT);
WRITE(BTN_ENC,HIGH);
#endif
+ #ifdef REPRAPWORLD_KEYPAD
+ pinMode(SHIFT_CLK,OUTPUT);
+ pinMode(SHIFT_LD,OUTPUT);
+ pinMode(SHIFT_OUT,INPUT);
+ WRITE(SHIFT_OUT,HIGH);
+ WRITE(SHIFT_LD,HIGH);
+ #endif
#else
pinMode(SHIFT_CLK,OUTPUT);
pinMode(SHIFT_LD,OUTPUT);
@@ -765,10 +805,10 @@ void lcd_init()
WRITE(SHIFT_LD,HIGH);
WRITE(SHIFT_EN,LOW);
#endif//!NEWPANEL
-#if (SDCARDDETECT > -1)
+#if (SDCARDDETECT > 0)
WRITE(SDCARDDETECT, HIGH);
lcd_oldcardstatus = IS_SD_INSERTED;
-#endif//(SDCARDDETECT > -1)
+#endif//(SDCARDDETECT > 0)
lcd_buttons_update();
#ifdef ULTIPANEL
encoderDiff = 0;
@@ -785,7 +825,7 @@ void lcd_update()
buttons |= lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
#endif
- #if (SDCARDDETECT > -1)
+ #if (SDCARDDETECT > 0)
if((IS_SD_INSERTED != lcd_oldcardstatus))
{
lcdDrawUpdate = 2;
@@ -808,6 +848,17 @@ void lcd_update()
if (lcd_next_update_millis < millis())
{
#ifdef ULTIPANEL
+ #ifdef REPRAPWORLD_KEYPAD
+ if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) {
+ reprapworld_keypad_move_y_down();
+ }
+ if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) {
+ reprapworld_keypad_move_y_up();
+ }
+ if (REPRAPWORLD_KEYPAD_MOVE_HOME) {
+ reprapworld_keypad_move_home();
+ }
+ #endif
if (encoderDiff)
{
lcdDrawUpdate = 1;
@@ -890,10 +941,24 @@ void lcd_buttons_update()
uint8_t newbutton=0;
if(READ(BTN_EN1)==0) newbutton|=EN_A;
if(READ(BTN_EN2)==0) newbutton|=EN_B;
- #if defined(BTN_ENC) && BTN_ENC > -1
+ #if BTN_ENC > 0
if((blocking_enc>1;
+ if(READ(SHIFT_OUT))
+ newbutton_reprapworld_keypad|=(1<<7);
+ WRITE(SHIFT_CLK,HIGH);
+ WRITE(SHIFT_CLK,LOW);
+ }
+ newbutton |= ((~newbutton_reprapworld_keypad) << REPRAPWORLD_BTN_OFFSET); //invert it, because a pressed switch produces a logical 0
+ #endif
buttons = newbutton;
#else //read it from the shift register
uint8_t newbutton=0;
@@ -1162,7 +1227,7 @@ void copy_and_scalePID_i()
{
Ki = scalePID_i(raw_Ki);
updatePID();
-}
+}
// Callback for after editing PID d value
// grab the pid d value out of the temp variable; scale it; then update the PID driver
@@ -1170,6 +1235,6 @@ void copy_and_scalePID_d()
{
Kd = scalePID_d(raw_Kd);
updatePID();
-}
-
+}
+
#endif //ULTRA_LCD
diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h
index ed9c10978..5d3c3c0be 100644
--- a/Marlin/ultralcd.h
+++ b/Marlin/ultralcd.h
@@ -35,7 +35,6 @@
extern int absPreheatFanSpeed;
void lcd_buzz(long duration,uint16_t freq);
-
bool lcd_clicked();
#else //no lcd
diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h
index 58a66dba3..23fa8b421 100644
--- a/Marlin/ultralcd_implementation_hitachi_HD44780.h
+++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h
@@ -6,7 +6,11 @@
* When selecting the rusian language, a slightly different LCD implementation is used to handle UTF8 characters.
**/
+#ifndef REPRAPWORLD_KEYPAD
extern volatile uint8_t buttons; //the last checked buttons in a bit array.
+#else
+extern volatile uint16_t buttons; //an extended version of the last checked buttons in a bit array.
+#endif
////////////////////////////////////
// Setup button and encode mappings for each panel (into 'buttons' variable)
@@ -55,7 +59,7 @@ extern volatile uint8_t buttons; //the last checked buttons in a bit array.
#elif defined(LCD_I2C_PANELOLU2)
// encoder click can be read through I2C if not directly connected
- #if !defined(BTN_ENC) || BTN_ENC == -1
+ #if BTN_ENC <= 0
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
#define B_MI (PANELOLU2_ENCODER_C<