@ -3,17 +3,17 @@
/*
/*
Reprap firmware based on Sprinter and grbl .
Reprap firmware based on Sprinter and grbl .
Copyright ( C ) 2011 Camiel Gubbels / Erik van der Zalm
Copyright ( C ) 2011 Camiel Gubbels / Erik van der Zalm
This program is free software : you can redistribute it and / or modify
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
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 3 of the License , or
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
*/
@ -22,8 +22,8 @@
This firmware is a mashup between Sprinter and grbl .
This firmware is a mashup between Sprinter and grbl .
( https : //github.com/kliment/Sprinter)
( https : //github.com/kliment/Sprinter)
( https : //github.com/simen/grbl/tree)
( 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
http : //reprap.org/pipermail/reprap-dev/2011-May/003323.html
*/
*/
@ -40,7 +40,11 @@
# include "language.h"
# include "language.h"
# include "pins_arduino.h"
# include "pins_arduino.h"
# if DIGIPOTSS_PIN > -1
# if NUM_SERVOS > 0
# include "Servo.h"
# endif
# if DIGIPOTSS_PIN > 0
# include <SPI.h>
# include <SPI.h>
# endif
# endif
@ -93,14 +97,18 @@
// M81 - Turn off Power Supply
// M81 - Turn off Power Supply
// M82 - Set E codes absolute (default)
// M82 - Set E codes absolute (default)
// M83 - Set E codes relative while in Absolute Coordinates (G90) mode
// 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<seconds> to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout.
// or use S<seconds> 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<seconds>. To disable set zero (default)
// M85 - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
// M92 - Set axis_steps_per_unit - same syntax as G92
// M92 - Set axis_steps_per_unit - same syntax as G92
// M114 - Output current position to serial port
// M114 - Output current position to serial port
// M115 - Capabilities string
// M115 - Capabilities string
// M117 - display message
// M117 - display message
// M119 - Output Endstop status to serial port
// 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
// M140 - Set bed target temp
// M190 - Wait for bed current temp to reach target temp.
// M190 - Wait for bed current temp to reach target temp.
// M200 - Set filament diameter
// M200 - Set filament diameter
@ -117,6 +125,7 @@
// M220 S<factor in percent>- set speed factor override percentage
// M220 S<factor in percent>- set speed factor override percentage
// M221 S<factor in percent>- set extrude factor override percentage
// M221 S<factor in percent>- set extrude factor override percentage
// M240 - Trigger a camera to take a photograph
// M240 - Trigger a camera to take a photograph
// M280 - set servo position absolute. P: servo index, S: angle or microseconds
// M300 - Play beepsound S<frequency Hz> P<duration ms>
// M300 - Play beepsound S<frequency Hz> P<duration ms>
// M301 - Set PID parameters P I and D
// M301 - Set PID parameters P I and D
// M302 - Allow cold extrudes
// M302 - Allow cold extrudes
@ -124,7 +133,7 @@
// M304 - Set bed PID parameters P I and D
// M304 - Set bed PID parameters P I and D
// M400 - Finish all moves
// M400 - Finish all moves
// M500 - stores paramters in EEPROM
// 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.
// 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)
// 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)
// 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 } ;
float max_pos [ 3 ] = { X_MAX_POS , Y_MAX_POS , Z_MAX_POS } ;
// Extruder offset, only in XY plane
// Extruder offset, only in XY plane
# if EXTRUDERS > 1
# if EXTRUDERS > 1
float extruder_offset [ 2 ] [ EXTRUDERS ] = {
float extruder_offset [ 2 ] [ EXTRUDERS ] = {
# if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y)
# if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y)
EXTRUDER_OFFSET_X , EXTRUDER_OFFSET_Y
EXTRUDER_OFFSET_X , EXTRUDER_OFFSET_Y
# endif
# endif
} ;
} ;
# endif
# endif
uint8_t active_extruder = 0 ;
uint8_t active_extruder = 0 ;
int fanSpeed = 0 ;
int fanSpeed = 0 ;
# ifdef BARICUDA
int ValvePressure = 0 ;
int EtoPPressure = 0 ;
# endif
# ifdef FWRETRACT
# ifdef FWRETRACT
bool autoretract_enabled = true ;
bool autoretract_enabled = true ;
@ -217,6 +230,10 @@ static uint8_t tmp_extruder;
bool Stopped = false ;
bool Stopped = false ;
# if NUM_SERVOS > 0
Servo servos [ NUM_SERVOS ] ;
# endif
//===========================================================================
//===========================================================================
//=============================ROUTINES=============================
//=============================ROUTINES=============================
//===========================================================================
//===========================================================================
@ -288,15 +305,15 @@ void setup_killpin()
WRITE ( KILL_PIN , HIGH ) ;
WRITE ( KILL_PIN , HIGH ) ;
# endif
# endif
}
}
void setup_photpin ( )
void setup_photpin ( )
{
{
# ifdef PHOTOGRAPH_PIN
# ifdef PHOTOGRAPH_PIN
# if (PHOTOGRAPH_PIN > -1 )
# if (PHOTOGRAPH_PIN > 0 )
SET_OUTPUT ( PHOTOGRAPH_PIN ) ;
SET_OUTPUT ( PHOTOGRAPH_PIN ) ;
WRITE ( PHOTOGRAPH_PIN , LOW ) ;
WRITE ( PHOTOGRAPH_PIN , LOW ) ;
# endif
# endif
# endif
# endif
}
}
void setup_powerhold ( )
void setup_powerhold ( )
@ -307,7 +324,7 @@ void setup_powerhold()
WRITE ( SUICIDE_PIN , HIGH ) ;
WRITE ( SUICIDE_PIN , HIGH ) ;
# endif
# endif
# endif
# endif
# if (PS_ON_PIN > -1 )
# if (PS_ON_PIN > 0 )
SET_OUTPUT ( PS_ON_PIN ) ;
SET_OUTPUT ( PS_ON_PIN ) ;
WRITE ( PS_ON_PIN , PS_ON_AWAKE ) ;
WRITE ( PS_ON_PIN , PS_ON_AWAKE ) ;
# endif
# endif
@ -316,16 +333,35 @@ void setup_powerhold()
void suicide ( )
void suicide ( )
{
{
# ifdef SUICIDE_PIN
# ifdef SUICIDE_PIN
# if (SUICIDE_PIN > -1)
# if (SUICIDE_PIN > 0)
SET_OUTPUT ( SUICIDE_PIN ) ;
SET_OUTPUT ( SUICIDE_PIN ) ;
WRITE ( SUICIDE_PIN , LOW ) ;
WRITE ( SUICIDE_PIN , LOW ) ;
# endif
# endif
# 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 ( )
void setup ( )
{
{
setup_killpin ( ) ;
setup_killpin ( ) ;
setup_powerhold ( ) ;
setup_powerhold ( ) ;
MYSERIAL . begin ( BAUDRATE ) ;
MYSERIAL . begin ( BAUDRATE ) ;
SERIAL_PROTOCOLLNPGM ( " start " ) ;
SERIAL_PROTOCOLLNPGM ( " start " ) ;
@ -362,22 +398,23 @@ void setup()
{
{
fromsd [ i ] = false ;
fromsd [ i ] = false ;
}
}
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
Config_RetrieveSettings ( ) ;
Config_RetrieveSettings ( ) ;
tp_init ( ) ; // Initialize temperature loop
tp_init ( ) ; // Initialize temperature loop
plan_init ( ) ; // Initialize planner;
plan_init ( ) ; // Initialize planner;
watchdog_init ( ) ;
watchdog_init ( ) ;
st_init ( ) ; // Initialize stepper, this enables interrupts!
st_init ( ) ; // Initialize stepper, this enables interrupts!
setup_photpin ( ) ;
setup_photpin ( ) ;
servo_init ( ) ;
lcd_init ( ) ;
lcd_init ( ) ;
# ifdef CONTROLLERFAN_PIN
# ifdef CONTROLLERFAN_PIN
SET_OUTPUT ( CONTROLLERFAN_PIN ) ; //Set pin used for driver cooling fan
SET_OUTPUT ( CONTROLLERFAN_PIN ) ; //Set pin used for driver cooling fan
# endif
# endif
# ifdef EXTRUDERFAN_PIN
# ifdef EXTRUDERFAN_PIN
SET_OUTPUT ( EXTRUDERFAN_PIN ) ; //Set pin used for extruder cooling fan
SET_OUTPUT ( EXTRUDERFAN_PIN ) ; //Set pin used for extruder cooling fan
# endif
# endif
@ -396,9 +433,9 @@ void loop()
# ifdef SDSUPPORT
# ifdef SDSUPPORT
if ( card . saving )
if ( card . saving )
{
{
if ( strstr_P ( cmdbuffer [ bufindr ] , PSTR ( " M29 " ) ) = = NULL )
if ( strstr_P ( cmdbuffer [ bufindr ] , PSTR ( " M29 " ) ) = = NULL )
{
{
card . write_command ( cmdbuffer [ bufindr ] ) ;
card . write_command ( cmdbuffer [ bufindr ] ) ;
if ( card . logging )
if ( card . logging )
{
{
process_commands ( ) ;
process_commands ( ) ;
@ -407,16 +444,16 @@ void loop()
{
{
SERIAL_PROTOCOLLNPGM ( MSG_OK ) ;
SERIAL_PROTOCOLLNPGM ( MSG_OK ) ;
}
}
}
}
else
else
{
{
card . closefile ( ) ;
card . closefile ( ) ;
SERIAL_PROTOCOLLNPGM ( MSG_FILE_SAVED ) ;
SERIAL_PROTOCOLLNPGM ( MSG_FILE_SAVED ) ;
}
}
}
}
else
else
{
{
process_commands ( ) ;
process_commands ( ) ;
}
}
# else
# else
process_commands ( ) ;
process_commands ( ) ;
@ -431,14 +468,14 @@ void loop()
lcd_update ( ) ;
lcd_update ( ) ;
}
}
void get_command ( )
void get_command ( )
{
{
while ( MYSERIAL . available ( ) > 0 & & buflen < BUFSIZE ) {
while ( MYSERIAL . available ( ) > 0 & & buflen < BUFSIZE ) {
serial_char = MYSERIAL . read ( ) ;
serial_char = MYSERIAL . read ( ) ;
if ( serial_char = = ' \n ' | |
if ( serial_char = = ' \n ' | |
serial_char = = ' \r ' | |
serial_char = = ' \r ' | |
( serial_char = = ' : ' & & comment_mode = = false ) | |
( serial_char = = ' : ' & & comment_mode = = false ) | |
serial_count > = ( MAX_CMD_SIZE - 1 ) )
serial_count > = ( MAX_CMD_SIZE - 1 ) )
{
{
if ( ! serial_count ) { //if empty line
if ( ! serial_count ) { //if empty line
comment_mode = false ; //for new command
comment_mode = false ; //for new command
@ -479,7 +516,7 @@ void get_command()
}
}
//if no errors, continue parsing
//if no errors, continue parsing
}
}
else
else
{
{
SERIAL_ERROR_START ;
SERIAL_ERROR_START ;
SERIAL_ERRORPGM ( MSG_ERR_NO_CHECKSUM ) ;
SERIAL_ERRORPGM ( MSG_ERR_NO_CHECKSUM ) ;
@ -511,11 +548,11 @@ void get_command()
case 2 :
case 2 :
case 3 :
case 3 :
if ( Stopped = = false ) { // If printer is stopped by an error the G[0-3] codes are ignored.
if ( Stopped = = false ) { // If printer is stopped by an error the G[0-3] codes are ignored.
# ifdef SDSUPPORT
# ifdef SDSUPPORT
if ( card . saving )
if ( card . saving )
break ;
break ;
# endif //SDSUPPORT
# endif //SDSUPPORT
SERIAL_PROTOCOLLNPGM ( MSG_OK ) ;
SERIAL_PROTOCOLLNPGM ( MSG_OK ) ;
}
}
else {
else {
SERIAL_ERRORLNPGM ( MSG_ERR_STOPPED ) ;
SERIAL_ERRORLNPGM ( MSG_ERR_STOPPED ) ;
@ -545,10 +582,10 @@ void get_command()
while ( ! card . eof ( ) & & buflen < BUFSIZE ) {
while ( ! card . eof ( ) & & buflen < BUFSIZE ) {
int16_t n = card . get ( ) ;
int16_t n = card . get ( ) ;
serial_char = ( char ) n ;
serial_char = ( char ) n ;
if ( serial_char = = ' \n ' | |
if ( serial_char = = ' \n ' | |
serial_char = = ' \r ' | |
serial_char = = ' \r ' | |
( serial_char = = ' : ' & & comment_mode = = false ) | |
( serial_char = = ' : ' & & comment_mode = = false ) | |
serial_count > = ( MAX_CMD_SIZE - 1 ) | | n = = - 1 )
serial_count > = ( MAX_CMD_SIZE - 1 ) | | n = = - 1 )
{
{
if ( card . eof ( ) ) {
if ( card . eof ( ) ) {
SERIAL_PROTOCOLLNPGM ( MSG_FILE_PRINTED ) ;
SERIAL_PROTOCOLLNPGM ( MSG_FILE_PRINTED ) ;
@ -564,7 +601,7 @@ void get_command()
lcd_setstatus ( time ) ;
lcd_setstatus ( time ) ;
card . printingHasFinished ( ) ;
card . printingHasFinished ( ) ;
card . checkautostart ( true ) ;
card . checkautostart ( true ) ;
}
}
if ( ! serial_count )
if ( ! serial_count )
{
{
@ -576,7 +613,7 @@ void get_command()
fromsd [ bufindw ] = true ;
fromsd [ bufindw ] = true ;
buflen + = 1 ;
buflen + = 1 ;
bufindw = ( bufindw + 1 ) % BUFSIZE ;
bufindw = ( bufindw + 1 ) % BUFSIZE ;
// }
// }
comment_mode = false ; //for new command
comment_mode = false ; //for new command
serial_count = 0 ; //clear buffer
serial_count = 0 ; //clear buffer
}
}
@ -586,20 +623,20 @@ void get_command()
if ( ! comment_mode ) cmdbuffer [ bufindw ] [ serial_count + + ] = serial_char ;
if ( ! comment_mode ) cmdbuffer [ bufindw ] [ serial_count + + ] = serial_char ;
}
}
}
}
# endif //SDSUPPORT
# endif //SDSUPPORT
}
}
float code_value ( )
float code_value ( )
{
{
return ( strtod ( & cmdbuffer [ bufindr ] [ strchr_pointer - cmdbuffer [ bufindr ] + 1 ] , NULL ) ) ;
return ( strtod ( & cmdbuffer [ bufindr ] [ strchr_pointer - cmdbuffer [ bufindr ] + 1 ] , NULL ) ) ;
}
}
long code_value_long ( )
long code_value_long ( )
{
{
return ( strtol ( & cmdbuffer [ bufindr ] [ strchr_pointer - cmdbuffer [ bufindr ] + 1 ] , NULL , 10 ) ) ;
return ( strtol ( & cmdbuffer [ bufindr ] [ strchr_pointer - cmdbuffer [ bufindr ] + 1 ] , NULL , 10 ) ) ;
}
}
bool code_seen ( char code )
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
return ( strchr_pointer ! = NULL ) ; //Return True if a character was found
}
}
# define DEFINE_PGM_READ_ANY(type, reader) \
# define DEFINE_PGM_READ_ANY(type, reader) \
static inline type pgm_read_any ( const type * p ) \
static inline type pgm_read_any ( const type * p ) \
{ return pgm_read_ # # reader # # _near ( p ) ; }
{ return pgm_read_ # # reader # # _near ( p ) ; }
DEFINE_PGM_READ_ANY ( float , float ) ;
DEFINE_PGM_READ_ANY ( float , float ) ;
DEFINE_PGM_READ_ANY ( signed char , byte ) ;
DEFINE_PGM_READ_ANY ( signed char , byte ) ;
# define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
# define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
static const PROGMEM type array # # _P [ 3 ] = \
static const PROGMEM type array # # _P [ 3 ] = \
{ X_ # # CONFIG , Y_ # # CONFIG , Z_ # # CONFIG } ; \
{ X_ # # CONFIG , Y_ # # CONFIG , Z_ # # CONFIG } ; \
static inline type array ( int axis ) \
static inline type array ( int axis ) \
{ return pgm_read_any ( & array # # _P [ axis ] ) ; }
{ return pgm_read_any ( & array # # _P [ axis ] ) ; }
XYZ_CONSTS_FROM_CONFIG ( float , base_min_pos , MIN_POS ) ;
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 ) {
static void homeaxis ( int axis ) {
# define HOMEAXIS_DO(LETTER) \
# 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 ) :
if ( axis = = X_AXIS ? HOMEAXIS_DO ( X ) :
axis = = Y_AXIS ? HOMEAXIS_DO ( Y ) :
axis = = Y_AXIS ? HOMEAXIS_DO ( Y ) :
@ -648,19 +685,19 @@ static void homeaxis(int axis) {
feedrate = homing_feedrate [ axis ] ;
feedrate = homing_feedrate [ axis ] ;
plan_buffer_line ( destination [ X_AXIS ] , destination [ Y_AXIS ] , destination [ Z_AXIS ] , destination [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
plan_buffer_line ( destination [ X_AXIS ] , destination [ Y_AXIS ] , destination [ Z_AXIS ] , destination [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
st_synchronize ( ) ;
st_synchronize ( ) ;
current_position [ axis ] = 0 ;
current_position [ axis ] = 0 ;
plan_set_position ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] , current_position [ E_AXIS ] ) ;
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 ) ;
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 ) ;
plan_buffer_line ( destination [ X_AXIS ] , destination [ Y_AXIS ] , destination [ Z_AXIS ] , destination [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
st_synchronize ( ) ;
st_synchronize ( ) ;
destination [ axis ] = 2 * home_retract_mm ( axis ) * home_dir ( axis ) ;
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 ) ;
plan_buffer_line ( destination [ X_AXIS ] , destination [ Y_AXIS ] , destination [ Z_AXIS ] , destination [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
st_synchronize ( ) ;
st_synchronize ( ) ;
axis_is_at_home ( axis ) ;
axis_is_at_home ( axis ) ;
destination [ axis ] = current_position [ axis ] ;
destination [ axis ] = current_position [ axis ] ;
feedrate = 0.0 ;
feedrate = 0.0 ;
endstops_hit_on_purpose ( ) ;
endstops_hit_on_purpose ( ) ;
@ -703,7 +740,7 @@ void process_commands()
codenum = 0 ;
codenum = 0 ;
if ( code_seen ( ' P ' ) ) codenum = code_value ( ) ; // milliseconds to wait
if ( code_seen ( ' P ' ) ) codenum = code_value ( ) ; // milliseconds to wait
if ( code_seen ( ' S ' ) ) codenum = code_value ( ) * 1000 ; // seconds to wait
if ( code_seen ( ' S ' ) ) codenum = code_value ( ) * 1000 ; // seconds to wait
st_synchronize ( ) ;
st_synchronize ( ) ;
codenum + = millis ( ) ; // keep track of when we started waiting
codenum + = millis ( ) ; // keep track of when we started waiting
previous_millis_cmd = millis ( ) ;
previous_millis_cmd = millis ( ) ;
@ -713,30 +750,30 @@ void process_commands()
lcd_update ( ) ;
lcd_update ( ) ;
}
}
break ;
break ;
# ifdef FWRETRACT
# ifdef FWRETRACT
case 10 : // G10 retract
case 10 : // G10 retract
if ( ! retracted )
if ( ! retracted )
{
{
destination [ X_AXIS ] = current_position [ X_AXIS ] ;
destination [ X_AXIS ] = current_position [ X_AXIS ] ;
destination [ Y_AXIS ] = current_position [ Y_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 [ 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 ;
feedrate = retract_feedrate ;
retracted = true ;
retracted = true ;
prepare_move ( ) ;
prepare_move ( ) ;
}
}
break ;
break ;
case 11 : // G10 retract_recover
case 11 : // G10 retract_recover
if ( ! retracted )
if ( ! retracted )
{
{
destination [ X_AXIS ] = current_position [ X_AXIS ] ;
destination [ X_AXIS ] = current_position [ X_AXIS ] ;
destination [ Y_AXIS ] = current_position [ Y_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 [ Z_AXIS ] + = retract_zlift ;
current_position [ E_AXIS ] + = - retract_recover_length ;
current_position [ E_AXIS ] + = - retract_recover_length ;
feedrate = retract_recover_feedrate ;
feedrate = retract_recover_feedrate ;
retracted = false ;
retracted = false ;
prepare_move ( ) ;
prepare_move ( ) ;
@ -748,34 +785,34 @@ void process_commands()
saved_feedmultiply = feedmultiply ;
saved_feedmultiply = feedmultiply ;
feedmultiply = 100 ;
feedmultiply = 100 ;
previous_millis_cmd = millis ( ) ;
previous_millis_cmd = millis ( ) ;
enable_endstops ( true ) ;
enable_endstops ( true ) ;
for ( int8_t i = 0 ; i < NUM_AXIS ; i + + ) {
for ( int8_t i = 0 ; i < NUM_AXIS ; i + + ) {
destination [ i ] = current_position [ i ] ;
destination [ i ] = current_position [ i ] ;
}
}
feedrate = 0.0 ;
feedrate = 0.0 ;
home_all_axis = ! ( ( code_seen ( axis_codes [ 0 ] ) ) | | ( code_seen ( axis_codes [ 1 ] ) ) | | ( code_seen ( axis_codes [ 2 ] ) ) ) ;
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 Z_HOME_DIR > 0 // If homing away from BED do Z first
if ( ( home_all_axis ) | | ( code_seen ( axis_codes [ Z_AXIS ] ) ) ) {
if ( ( home_all_axis ) | | ( code_seen ( axis_codes [ Z_AXIS ] ) ) ) {
HOMEAXIS ( Z ) ;
HOMEAXIS ( Z ) ;
}
}
# endif
# endif
# ifdef QUICK_HOME
# ifdef QUICK_HOME
if ( ( home_all_axis ) | | ( code_seen ( axis_codes [ X_AXIS ] ) & & code_seen ( axis_codes [ Y_AXIS ] ) ) ) //first diagonal move
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 ] ) ;
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 ;
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 ] ;
feedrate = homing_feedrate [ X_AXIS ] ;
if ( homing_feedrate [ Y_AXIS ] < feedrate )
if ( homing_feedrate [ Y_AXIS ] < feedrate )
feedrate = homing_feedrate [ Y_AXIS ] ;
feedrate = homing_feedrate [ Y_AXIS ] ;
plan_buffer_line ( destination [ X_AXIS ] , destination [ Y_AXIS ] , destination [ Z_AXIS ] , destination [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
plan_buffer_line ( destination [ X_AXIS ] , destination [ Y_AXIS ] , destination [ Z_AXIS ] , destination [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
st_synchronize ( ) ;
st_synchronize ( ) ;
axis_is_at_home ( X_AXIS ) ;
axis_is_at_home ( X_AXIS ) ;
axis_is_at_home ( Y_AXIS ) ;
axis_is_at_home ( Y_AXIS ) ;
plan_set_position ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] , current_position [ E_AXIS ] ) ;
plan_set_position ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] , current_position [ E_AXIS ] ) ;
@ -787,8 +824,8 @@ void process_commands()
endstops_hit_on_purpose ( ) ;
endstops_hit_on_purpose ( ) ;
}
}
# endif
# endif
if ( ( home_all_axis ) | | ( code_seen ( axis_codes [ X_AXIS ] ) ) )
if ( ( home_all_axis ) | | ( code_seen ( axis_codes [ X_AXIS ] ) ) )
{
{
HOMEAXIS ( X ) ;
HOMEAXIS ( X ) ;
}
}
@ -796,14 +833,14 @@ void process_commands()
if ( ( home_all_axis ) | | ( code_seen ( axis_codes [ Y_AXIS ] ) ) ) {
if ( ( home_all_axis ) | | ( code_seen ( axis_codes [ Y_AXIS ] ) ) ) {
HOMEAXIS ( Y ) ;
HOMEAXIS ( Y ) ;
}
}
# if Z_HOME_DIR < 0 // If homing towards BED do Z last
# if Z_HOME_DIR < 0 // If homing towards BED do Z last
if ( ( home_all_axis ) | | ( code_seen ( axis_codes [ Z_AXIS ] ) ) ) {
if ( ( home_all_axis ) | | ( code_seen ( axis_codes [ Z_AXIS ] ) ) ) {
HOMEAXIS ( Z ) ;
HOMEAXIS ( Z ) ;
}
}
# endif
# endif
if ( code_seen ( axis_codes [ X_AXIS ] ) )
if ( code_seen ( axis_codes [ X_AXIS ] ) )
{
{
if ( code_value_long ( ) ! = 0 ) {
if ( code_value_long ( ) ! = 0 ) {
current_position [ X_AXIS ] = code_value ( ) + add_homeing [ 0 ] ;
current_position [ X_AXIS ] = code_value ( ) + add_homeing [ 0 ] ;
@ -822,11 +859,11 @@ void process_commands()
}
}
}
}
plan_set_position ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] , current_position [ E_AXIS ] ) ;
plan_set_position ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] , current_position [ E_AXIS ] ) ;
# ifdef ENDSTOPS_ONLY_FOR_HOMING
# ifdef ENDSTOPS_ONLY_FOR_HOMING
enable_endstops ( false ) ;
enable_endstops ( false ) ;
# endif
# endif
feedrate = saved_feedrate ;
feedrate = saved_feedrate ;
feedmultiply = saved_feedmultiply ;
feedmultiply = saved_feedmultiply ;
previous_millis_cmd = millis ( ) ;
previous_millis_cmd = millis ( ) ;
@ -842,13 +879,13 @@ void process_commands()
if ( ! code_seen ( axis_codes [ E_AXIS ] ) )
if ( ! code_seen ( axis_codes [ E_AXIS ] ) )
st_synchronize ( ) ;
st_synchronize ( ) ;
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 = = E_AXIS ) {
if ( i = = E_AXIS ) {
current_position [ i ] = code_value ( ) ;
current_position [ i ] = code_value ( ) ;
plan_set_e_position ( current_position [ E_AXIS ] ) ;
plan_set_e_position ( current_position [ E_AXIS ] ) ;
}
}
else {
else {
current_position [ i ] = code_value ( ) + add_homeing [ i ] ;
current_position [ i ] = code_value ( ) + add_homeing [ i ] ;
plan_set_position ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] , current_position [ E_AXIS ] ) ;
plan_set_position ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_AXIS ] , current_position [ E_AXIS ] ) ;
}
}
}
}
@ -859,7 +896,7 @@ void process_commands()
else if ( code_seen ( ' M ' ) )
else if ( code_seen ( ' M ' ) )
{
{
switch ( ( int ) code_value ( ) )
switch ( ( int ) code_value ( ) )
{
{
# ifdef ULTIPANEL
# ifdef ULTIPANEL
case 0 : // M0 - Unconditional stop - Wait for user button press on LCD
case 0 : // M0 - Unconditional stop - Wait for user button press on LCD
@ -869,7 +906,7 @@ void process_commands()
codenum = 0 ;
codenum = 0 ;
if ( code_seen ( ' P ' ) ) codenum = code_value ( ) ; // milliseconds to wait
if ( code_seen ( ' P ' ) ) codenum = code_value ( ) ; // milliseconds to wait
if ( code_seen ( ' S ' ) ) codenum = code_value ( ) * 1000 ; // seconds to wait
if ( code_seen ( ' S ' ) ) codenum = code_value ( ) * 1000 ; // seconds to wait
st_synchronize ( ) ;
st_synchronize ( ) ;
previous_millis_cmd = millis ( ) ;
previous_millis_cmd = millis ( ) ;
if ( codenum > 0 ) {
if ( codenum > 0 ) {
@ -892,12 +929,12 @@ void process_commands()
# endif
# endif
case 17 :
case 17 :
LCD_MESSAGEPGM ( MSG_NO_MOVE ) ;
LCD_MESSAGEPGM ( MSG_NO_MOVE ) ;
enable_x ( ) ;
enable_x ( ) ;
enable_y ( ) ;
enable_y ( ) ;
enable_z ( ) ;
enable_z ( ) ;
enable_e0 ( ) ;
enable_e0 ( ) ;
enable_e1 ( ) ;
enable_e1 ( ) ;
enable_e2 ( ) ;
enable_e2 ( ) ;
break ;
break ;
# ifdef SDSUPPORT
# ifdef SDSUPPORT
@ -907,9 +944,9 @@ void process_commands()
SERIAL_PROTOCOLLNPGM ( MSG_END_FILE_LIST ) ;
SERIAL_PROTOCOLLNPGM ( MSG_END_FILE_LIST ) ;
break ;
break ;
case 21 : // M21 - init SD card
case 21 : // M21 - init SD card
card . initsd ( ) ;
card . initsd ( ) ;
break ;
break ;
case 22 : //M22 - release SD card
case 22 : //M22 - release SD card
card . release ( ) ;
card . release ( ) ;
@ -949,18 +986,18 @@ void process_commands()
//processed in write to file routine above
//processed in write to file routine above
//card,saving = false;
//card,saving = false;
break ;
break ;
case 30 : //M30 <filename> Delete File
case 30 : //M30 <filename> Delete File
if ( card . cardOK ) {
if ( card . cardOK ) {
card . closefile ( ) ;
card . closefile ( ) ;
starpos = ( strchr ( strchr_pointer + 4 , ' * ' ) ) ;
starpos = ( strchr ( strchr_pointer + 4 , ' * ' ) ) ;
if ( starpos ! = NULL ) {
if ( starpos ! = NULL ) {
char * npos = strchr ( cmdbuffer [ bufindr ] , ' N ' ) ;
char * npos = strchr ( cmdbuffer [ bufindr ] , ' N ' ) ;
strchr_pointer = strchr ( npos , ' ' ) + 1 ;
strchr_pointer = strchr ( npos , ' ' ) + 1 ;
* ( starpos - 1 ) = ' \0 ' ;
* ( starpos - 1 ) = ' \0 ' ;
}
}
card . removeFile ( strchr_pointer + 4 ) ;
card . removeFile ( strchr_pointer + 4 ) ;
}
}
break ;
break ;
case 928 : //M928 - Start SD write
case 928 : //M928 - Start SD write
starpos = ( strchr ( strchr_pointer + 5 , ' * ' ) ) ;
starpos = ( strchr ( strchr_pointer + 5 , ' * ' ) ) ;
if ( starpos ! = NULL ) {
if ( starpos ! = NULL ) {
@ -970,7 +1007,7 @@ void process_commands()
}
}
card . openLogFile ( strchr_pointer + 5 ) ;
card . openLogFile ( strchr_pointer + 5 ) ;
break ;
break ;
# endif //SDSUPPORT
# endif //SDSUPPORT
case 31 : //M31 take time since the start of the SD print or an M109 command
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 ) ) {
if ( setTargetedHotend ( 105 ) ) {
break ;
break ;
}
}
# if (TEMP_0_PIN > -1 )
# if (TEMP_0_PIN > 0 )
SERIAL_PROTOCOLPGM ( " ok T: " ) ;
SERIAL_PROTOCOLPGM ( " ok T: " ) ;
SERIAL_PROTOCOL_F ( degHotend ( tmp_extruder ) , 1 ) ;
SERIAL_PROTOCOL_F ( degHotend ( tmp_extruder ) , 1 ) ;
SERIAL_PROTOCOLPGM ( " / " ) ;
SERIAL_PROTOCOLPGM ( " / " ) ;
SERIAL_PROTOCOL_F ( degTargetHotend ( tmp_extruder ) , 1 ) ;
SERIAL_PROTOCOL_F ( degTargetHotend ( tmp_extruder ) , 1 ) ;
# if TEMP_BED_PIN > -1
# if TEMP_BED_PIN > 0
SERIAL_PROTOCOLPGM ( " B: " ) ;
SERIAL_PROTOCOLPGM ( " B: " ) ;
SERIAL_PROTOCOL_F ( degBed ( ) , 1 ) ;
SERIAL_PROTOCOL_F ( degBed ( ) , 1 ) ;
SERIAL_PROTOCOLPGM ( " / " ) ;
SERIAL_PROTOCOLPGM ( " / " ) ;
SERIAL_PROTOCOL_F ( degTargetBed ( ) , 1 ) ;
SERIAL_PROTOCOL_F ( degTargetBed ( ) , 1 ) ;
@ -1042,20 +1079,20 @@ void process_commands()
# endif
# endif
SERIAL_PROTOCOLPGM ( " @: " ) ;
SERIAL_PROTOCOLPGM ( " @: " ) ;
SERIAL_PROTOCOL ( getHeaterPower ( tmp_extruder ) ) ;
SERIAL_PROTOCOL ( getHeaterPower ( tmp_extruder ) ) ;
SERIAL_PROTOCOLPGM ( " B@: " ) ;
SERIAL_PROTOCOLPGM ( " B@: " ) ;
SERIAL_PROTOCOL ( getHeaterPower ( - 1 ) ) ;
SERIAL_PROTOCOL ( getHeaterPower ( - 1 ) ) ;
SERIAL_PROTOCOLLN ( " " ) ;
SERIAL_PROTOCOLLN ( " " ) ;
return ;
return ;
break ;
break ;
case 109 :
case 109 :
{ // M109 - Wait for extruder heater to reach target.
{ // M109 - Wait for extruder heater to reach target.
if ( setTargetedHotend ( 109 ) ) {
if ( setTargetedHotend ( 109 ) ) {
break ;
break ;
}
}
LCD_MESSAGEPGM ( MSG_HEATING ) ;
LCD_MESSAGEPGM ( MSG_HEATING ) ;
# ifdef AUTOTEMP
# ifdef AUTOTEMP
autotemp_enabled = false ;
autotemp_enabled = false ;
# endif
# endif
@ -1063,15 +1100,15 @@ void process_commands()
# ifdef AUTOTEMP
# ifdef AUTOTEMP
if ( code_seen ( ' S ' ) ) autotemp_min = code_value ( ) ;
if ( code_seen ( ' S ' ) ) autotemp_min = code_value ( ) ;
if ( code_seen ( ' B ' ) ) autotemp_max = code_value ( ) ;
if ( code_seen ( ' B ' ) ) autotemp_max = code_value ( ) ;
if ( code_seen ( ' F ' ) )
if ( code_seen ( ' F ' ) )
{
{
autotemp_factor = code_value ( ) ;
autotemp_factor = code_value ( ) ;
autotemp_enabled = true ;
autotemp_enabled = true ;
}
}
# endif
# endif
setWatch ( ) ;
setWatch ( ) ;
codenum = millis ( ) ;
codenum = millis ( ) ;
/* See if we are heating up or cooling down */
/* See if we are heating up or cooling down */
bool target_direction = isHeatingHotend ( tmp_extruder ) ; // true if heating, false if cooling
bool target_direction = isHeatingHotend ( tmp_extruder ) ; // true if heating, false if cooling
@ -1079,7 +1116,7 @@ void process_commands()
# ifdef TEMP_RESIDENCY_TIME
# ifdef TEMP_RESIDENCY_TIME
long residencyStart ;
long residencyStart ;
residencyStart = - 1 ;
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 */
_and_ until TEMP_RESIDENCY_TIME hasn ' t passed since we reached it */
while ( ( residencyStart = = - 1 ) | |
while ( ( residencyStart = = - 1 ) | |
( residencyStart > = 0 & & ( ( ( unsigned int ) ( millis ( ) - residencyStart ) ) < ( TEMP_RESIDENCY_TIME * 1000UL ) ) ) ) {
( residencyStart > = 0 & & ( ( ( unsigned int ) ( millis ( ) - residencyStart ) ) < ( TEMP_RESIDENCY_TIME * 1000UL ) ) ) ) {
@ -1089,9 +1126,9 @@ void process_commands()
if ( ( millis ( ) - codenum ) > 1000UL )
if ( ( millis ( ) - codenum ) > 1000UL )
{ //Print Temp Reading and remaining time every 1 second while heating up/cooling down
{ //Print Temp Reading and remaining time every 1 second while heating up/cooling down
SERIAL_PROTOCOLPGM ( " T: " ) ;
SERIAL_PROTOCOLPGM ( " T: " ) ;
SERIAL_PROTOCOL_F ( degHotend ( tmp_extruder ) , 1 ) ;
SERIAL_PROTOCOL_F ( degHotend ( tmp_extruder ) , 1 ) ;
SERIAL_PROTOCOLPGM ( " E: " ) ;
SERIAL_PROTOCOLPGM ( " E: " ) ;
SERIAL_PROTOCOL ( ( int ) tmp_extruder ) ;
SERIAL_PROTOCOL ( ( int ) tmp_extruder ) ;
# ifdef TEMP_RESIDENCY_TIME
# ifdef TEMP_RESIDENCY_TIME
SERIAL_PROTOCOLPGM ( " W: " ) ;
SERIAL_PROTOCOLPGM ( " W: " ) ;
if ( residencyStart > - 1 )
if ( residencyStart > - 1 )
@ -1099,7 +1136,7 @@ void process_commands()
codenum = ( ( TEMP_RESIDENCY_TIME * 1000UL ) - ( millis ( ) - residencyStart ) ) / 1000UL ;
codenum = ( ( TEMP_RESIDENCY_TIME * 1000UL ) - ( millis ( ) - residencyStart ) ) / 1000UL ;
SERIAL_PROTOCOLLN ( codenum ) ;
SERIAL_PROTOCOLLN ( codenum ) ;
}
}
else
else
{
{
SERIAL_PROTOCOLLN ( " ? " ) ;
SERIAL_PROTOCOLLN ( " ? " ) ;
}
}
@ -1116,7 +1153,7 @@ void process_commands()
or when current temp falls outside the hysteresis after target temp was reached */
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 ) ) ) | |
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 & & ! 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 ( ) ;
residencyStart = millis ( ) ;
}
}
@ -1128,11 +1165,11 @@ void process_commands()
}
}
break ;
break ;
case 190 : // M190 - Wait for bed heater to reach target.
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 ) ;
LCD_MESSAGEPGM ( MSG_BED_HEATING ) ;
if ( code_seen ( ' S ' ) ) setTargetBed ( code_value ( ) ) ;
if ( code_seen ( ' S ' ) ) setTargetBed ( code_value ( ) ) ;
codenum = millis ( ) ;
codenum = millis ( ) ;
while ( isHeatingBed ( ) )
while ( isHeatingBed ( ) )
{
{
if ( ( millis ( ) - codenum ) > 1000 ) //Print Temp Reading every 1 second while heating up.
if ( ( millis ( ) - codenum ) > 1000 ) //Print Temp Reading every 1 second while heating up.
{
{
@ -1140,11 +1177,11 @@ void process_commands()
SERIAL_PROTOCOLPGM ( " T: " ) ;
SERIAL_PROTOCOLPGM ( " T: " ) ;
SERIAL_PROTOCOL ( tt ) ;
SERIAL_PROTOCOL ( tt ) ;
SERIAL_PROTOCOLPGM ( " E: " ) ;
SERIAL_PROTOCOLPGM ( " E: " ) ;
SERIAL_PROTOCOL ( ( int ) active_extruder ) ;
SERIAL_PROTOCOL ( ( int ) active_extruder ) ;
SERIAL_PROTOCOLPGM ( " B: " ) ;
SERIAL_PROTOCOLPGM ( " B: " ) ;
SERIAL_PROTOCOL_F ( degBed ( ) , 1 ) ;
SERIAL_PROTOCOL_F ( degBed ( ) , 1 ) ;
SERIAL_PROTOCOLLN ( " " ) ;
SERIAL_PROTOCOLLN ( " " ) ;
codenum = millis ( ) ;
codenum = millis ( ) ;
}
}
manage_heater ( ) ;
manage_heater ( ) ;
manage_inactivity ( ) ;
manage_inactivity ( ) ;
@ -1155,38 +1192,69 @@ void process_commands()
# endif
# endif
break ;
break ;
# if FAN_PIN > -1
# if FAN_PIN > 0
case 106 : //M106 Fan On
case 106 : //M106 Fan On
if ( code_seen ( ' S ' ) ) {
if ( code_seen ( ' S ' ) ) {
fanSpeed = constrain ( code_value ( ) , 0 , 255 ) ;
fanSpeed = constrain ( code_value ( ) , 0 , 255 ) ;
}
}
else {
else {
fanSpeed = 255 ;
fanSpeed = 255 ;
}
}
break ;
break ;
case 107 : //M107 Fan Off
case 107 : //M107 Fan Off
fanSpeed = 0 ;
fanSpeed = 0 ;
break ;
break ;
# endif //FAN_PIN
# 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
// 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 > -1)
# if (PS_ON_PIN > 0 )
case 80 : // M80 - ATX Power On
case 80 : // M80 - ATX Power On
SET_OUTPUT ( PS_ON_PIN ) ; //GND
SET_OUTPUT ( PS_ON_PIN ) ; //GND
WRITE ( PS_ON_PIN , PS_ON_AWAKE ) ;
WRITE ( PS_ON_PIN , PS_ON_AWAKE ) ;
break ;
break ;
# endif
# endif
case 81 : // M81 - ATX Power Off
case 81 : // M81 - ATX Power Off
# if defined SUICIDE_PIN && SUICIDE_PIN > -1
# if defined SUICIDE_PIN && SUICIDE_PIN > 0
st_synchronize ( ) ;
st_synchronize ( ) ;
suicide ( ) ;
suicide ( ) ;
# elif (PS_ON_PIN > -1)
# elif (PS_ON_PIN > 0 )
SET_OUTPUT ( PS_ON_PIN ) ;
SET_OUTPUT ( PS_ON_PIN ) ;
WRITE ( PS_ON_PIN , PS_ON_ASLEEP ) ;
WRITE ( PS_ON_PIN , PS_ON_ASLEEP ) ;
# endif
# endif
break ;
break ;
case 82 :
case 82 :
axis_relative_modes [ 3 ] = false ;
axis_relative_modes [ 3 ] = false ;
break ;
break ;
@ -1195,11 +1263,11 @@ void process_commands()
break ;
break ;
case 18 : //compatibility
case 18 : //compatibility
case 84 : // M84
case 84 : // M84
if ( code_seen ( ' S ' ) ) {
if ( code_seen ( ' S ' ) ) {
stepper_inactive_time = code_value ( ) * 1000 ;
stepper_inactive_time = code_value ( ) * 1000 ;
}
}
else
else
{
{
bool all_axis = ! ( ( code_seen ( axis_codes [ 0 ] ) ) | | ( code_seen ( axis_codes [ 1 ] ) ) | | ( code_seen ( axis_codes [ 2 ] ) ) | | ( code_seen ( axis_codes [ 3 ] ) ) ) ;
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 )
if ( all_axis )
{
{
@ -1221,18 +1289,18 @@ void process_commands()
disable_e1 ( ) ;
disable_e1 ( ) ;
disable_e2 ( ) ;
disable_e2 ( ) ;
}
}
# endif
# endif
}
}
}
}
break ;
break ;
case 85 : // M85
case 85 : // M85
code_seen ( ' S ' ) ;
code_seen ( ' S ' ) ;
max_inactive_time = code_value ( ) * 1000 ;
max_inactive_time = code_value ( ) * 1000 ;
break ;
break ;
case 92 : // M92
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
if ( i = = 3 ) { // E
float value = code_value ( ) ;
float value = code_value ( ) ;
@ -1266,16 +1334,16 @@ void process_commands()
SERIAL_PROTOCOL ( current_position [ Y_AXIS ] ) ;
SERIAL_PROTOCOL ( current_position [ Y_AXIS ] ) ;
SERIAL_PROTOCOLPGM ( " Z: " ) ;
SERIAL_PROTOCOLPGM ( " Z: " ) ;
SERIAL_PROTOCOL ( current_position [ Z_AXIS ] ) ;
SERIAL_PROTOCOL ( current_position [ Z_AXIS ] ) ;
SERIAL_PROTOCOLPGM ( " E: " ) ;
SERIAL_PROTOCOLPGM ( " E: " ) ;
SERIAL_PROTOCOL ( current_position [ E_AXIS ] ) ;
SERIAL_PROTOCOL ( current_position [ E_AXIS ] ) ;
SERIAL_PROTOCOLPGM ( MSG_COUNT_X ) ;
SERIAL_PROTOCOLPGM ( MSG_COUNT_X ) ;
SERIAL_PROTOCOL ( float ( st_get_position ( X_AXIS ) ) / axis_steps_per_unit [ X_AXIS ] ) ;
SERIAL_PROTOCOL ( float ( st_get_position ( X_AXIS ) ) / axis_steps_per_unit [ X_AXIS ] ) ;
SERIAL_PROTOCOLPGM ( " Y: " ) ;
SERIAL_PROTOCOLPGM ( " Y: " ) ;
SERIAL_PROTOCOL ( float ( st_get_position ( Y_AXIS ) ) / axis_steps_per_unit [ Y_AXIS ] ) ;
SERIAL_PROTOCOL ( float ( st_get_position ( Y_AXIS ) ) / axis_steps_per_unit [ Y_AXIS ] ) ;
SERIAL_PROTOCOLPGM ( " Z: " ) ;
SERIAL_PROTOCOLPGM ( " Z: " ) ;
SERIAL_PROTOCOL ( float ( st_get_position ( Z_AXIS ) ) / axis_steps_per_unit [ Z_AXIS ] ) ;
SERIAL_PROTOCOL ( float ( st_get_position ( Z_AXIS ) ) / axis_steps_per_unit [ Z_AXIS ] ) ;
SERIAL_PROTOCOLLN ( " " ) ;
SERIAL_PROTOCOLLN ( " " ) ;
break ;
break ;
case 120 : // M120
case 120 : // M120
@ -1286,34 +1354,34 @@ void process_commands()
break ;
break ;
case 119 : // M119
case 119 : // M119
SERIAL_PROTOCOLLN ( MSG_M119_REPORT ) ;
SERIAL_PROTOCOLLN ( MSG_M119_REPORT ) ;
# if (X_MIN_PIN > -1 )
# if (X_MIN_PIN > 0 )
SERIAL_PROTOCOLPGM ( MSG_X_MIN ) ;
SERIAL_PROTOCOLPGM ( MSG_X_MIN ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( X_MIN_PIN ) ^ X_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( X_MIN_PIN ) ^ X_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
# endif
# endif
# if (X_MAX_PIN > -1 )
# if (X_MAX_PIN > 0 )
SERIAL_PROTOCOLPGM ( MSG_X_MAX ) ;
SERIAL_PROTOCOLPGM ( MSG_X_MAX ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( X_MAX_PIN ) ^ X_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( X_MAX_PIN ) ^ X_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
# endif
# endif
# if (Y_MIN_PIN > -1 )
# if (Y_MIN_PIN > 0 )
SERIAL_PROTOCOLPGM ( MSG_Y_MIN ) ;
SERIAL_PROTOCOLPGM ( MSG_Y_MIN ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( Y_MIN_PIN ) ^ Y_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( Y_MIN_PIN ) ^ Y_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
# endif
# endif
# if (Y_MAX_PIN > -1 )
# if (Y_MAX_PIN > 0 )
SERIAL_PROTOCOLPGM ( MSG_Y_MAX ) ;
SERIAL_PROTOCOLPGM ( MSG_Y_MAX ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( Y_MAX_PIN ) ^ Y_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( Y_MAX_PIN ) ^ Y_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
# endif
# endif
# if (Z_MIN_PIN > -1 )
# if (Z_MIN_PIN > 0 )
SERIAL_PROTOCOLPGM ( MSG_Z_MIN ) ;
SERIAL_PROTOCOLPGM ( MSG_Z_MIN ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( Z_MIN_PIN ) ^ Z_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( Z_MIN_PIN ) ^ Z_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
# endif
# endif
# if (Z_MAX_PIN > -1 )
# if (Z_MAX_PIN > 0 )
SERIAL_PROTOCOLPGM ( MSG_Z_MAX ) ;
SERIAL_PROTOCOLPGM ( MSG_Z_MAX ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( Z_MAX_PIN ) ^ Z_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
SERIAL_PROTOCOLLN ( ( ( READ ( Z_MAX_PIN ) ^ Z_ENDSTOPS_INVERTING ) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN ) ) ;
# endif
# endif
break ;
break ;
//TODO: update for all axis, use for loop
//TODO: update for all axis, use for loop
case 201 : // M201
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 ] ) )
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)
// 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 ;
break ;
#if 0 // Not used for Sprinter/grbl gen6
#if 0 // Not used for Sprinter/grbl gen6
case 202 : // M202
case 202 : // M202
@ -1352,7 +1420,7 @@ void process_commands()
}
}
break ;
break ;
case 206 : // M206 additional homeing offset
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 ( ) ;
if ( code_seen ( axis_codes [ i ] ) ) add_homeing [ i ] = code_value ( ) ;
}
}
@ -1360,47 +1428,47 @@ void process_commands()
# ifdef FWRETRACT
# ifdef FWRETRACT
case 207 : //M207 - set retract length S[positive mm] F[feedrate mm/sec] Z[additional zlift/hop]
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 ( ) ;
retract_length = code_value ( ) ;
}
}
if ( code_seen ( ' F ' ) )
if ( code_seen ( ' F ' ) )
{
{
retract_feedrate = code_value ( ) ;
retract_feedrate = code_value ( ) ;
}
}
if ( code_seen ( ' Z ' ) )
if ( code_seen ( ' Z ' ) )
{
{
retract_zlift = code_value ( ) ;
retract_zlift = code_value ( ) ;
}
}
} break ;
} break ;
case 208 : // M208 - set retract recover length S[positive mm surplus to the M207 S*] F[feedrate mm/sec]
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 ( ) ;
retract_recover_length = code_value ( ) ;
}
}
if ( code_seen ( ' F ' ) )
if ( code_seen ( ' F ' ) )
{
{
retract_recover_feedrate = code_value ( ) ;
retract_recover_feedrate = code_value ( ) ;
}
}
} break ;
} 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.
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 ( ) ;
int t = code_value ( ) ;
switch ( t )
switch ( t )
{
{
case 0 : autoretract_enabled = false ; retracted = false ; break ;
case 0 : autoretract_enabled = false ; retracted = false ; break ;
case 1 : autoretract_enabled = true ; retracted = false ; break ;
case 1 : autoretract_enabled = true ; retracted = false ; break ;
default :
default :
SERIAL_ECHO_START ;
SERIAL_ECHO_START ;
SERIAL_ECHOPGM ( MSG_UNKNOWN_COMMAND ) ;
SERIAL_ECHOPGM ( MSG_UNKNOWN_COMMAND ) ;
SERIAL_ECHO ( cmdbuffer [ bufindr ] ) ;
SERIAL_ECHO ( cmdbuffer [ bufindr ] ) ;
SERIAL_ECHOLNPGM ( " \" " ) ;
SERIAL_ECHOLNPGM ( " \" " ) ;
}
}
}
}
} break ;
} break ;
# endif // FWRETRACT
# endif // FWRETRACT
# if EXTRUDERS > 1
# if EXTRUDERS > 1
@ -1409,7 +1477,7 @@ void process_commands()
if ( setTargetedHotend ( 218 ) ) {
if ( setTargetedHotend ( 218 ) ) {
break ;
break ;
}
}
if ( code_seen ( ' X ' ) )
if ( code_seen ( ' X ' ) )
{
{
extruder_offset [ X_AXIS ] [ tmp_extruder ] = code_value ( ) ;
extruder_offset [ X_AXIS ] [ tmp_extruder ] = code_value ( ) ;
}
}
@ -1419,7 +1487,7 @@ void process_commands()
}
}
SERIAL_ECHO_START ;
SERIAL_ECHO_START ;
SERIAL_ECHOPGM ( MSG_HOTEND_OFFSET ) ;
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 ( " " ) ;
SERIAL_ECHO ( extruder_offset [ X_AXIS ] [ tmp_extruder ] ) ;
SERIAL_ECHO ( extruder_offset [ X_AXIS ] [ tmp_extruder ] ) ;
@ -1431,7 +1499,7 @@ void process_commands()
# endif
# endif
case 220 : // M220 S<factor in percent>- set speed factor override percentage
case 220 : // M220 S<factor in percent>- set speed factor override percentage
{
{
if ( code_seen ( ' S ' ) )
if ( code_seen ( ' S ' ) )
{
{
feedmultiply = code_value ( ) ;
feedmultiply = code_value ( ) ;
}
}
@ -1439,21 +1507,52 @@ void process_commands()
break ;
break ;
case 221 : // M221 S<factor in percent>- set extrude factor override percentage
case 221 : // M221 S<factor in percent>- set extrude factor override percentage
{
{
if ( code_seen ( ' S ' ) )
if ( code_seen ( ' S ' ) )
{
{
extrudemultiply = code_value ( ) ;
extrudemultiply = code_value ( ) ;
}
}
}
}
break ;
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
case 300 : // M300
{
{
int beepS = 400 ;
int beepS = 400 ;
int beepP = 1000 ;
int beepP = 1000 ;
if ( code_seen ( ' S ' ) ) beepS = code_value ( ) ;
if ( code_seen ( ' S ' ) ) beepS = code_value ( ) ;
if ( code_seen ( ' P ' ) ) beepP = code_value ( ) ;
if ( code_seen ( ' P ' ) ) beepP = code_value ( ) ;
# if defined(BEEPER) && BEEPER > -1
# if BEEPER > 0
tone ( BEEPER , beepS ) ;
tone ( BEEPER , beepS ) ;
delay ( beepP ) ;
delay ( beepP ) ;
noTone ( BEEPER ) ;
noTone ( BEEPER ) ;
@ -1474,10 +1573,10 @@ void process_commands()
# ifdef PID_ADD_EXTRUSION_RATE
# ifdef PID_ADD_EXTRUSION_RATE
if ( code_seen ( ' C ' ) ) Kc = code_value ( ) ;
if ( code_seen ( ' C ' ) ) Kc = code_value ( ) ;
# endif
# endif
updatePID ( ) ;
updatePID ( ) ;
SERIAL_PROTOCOL ( MSG_OK ) ;
SERIAL_PROTOCOL ( MSG_OK ) ;
SERIAL_PROTOCOL ( " p: " ) ;
SERIAL_PROTOCOL ( " p: " ) ;
SERIAL_PROTOCOL ( Kp ) ;
SERIAL_PROTOCOL ( Kp ) ;
SERIAL_PROTOCOL ( " i: " ) ;
SERIAL_PROTOCOL ( " i: " ) ;
SERIAL_PROTOCOL ( unscalePID_i ( Ki ) ) ;
SERIAL_PROTOCOL ( unscalePID_i ( Ki ) ) ;
@ -1501,7 +1600,7 @@ void process_commands()
updatePID ( ) ;
updatePID ( ) ;
SERIAL_PROTOCOL ( MSG_OK ) ;
SERIAL_PROTOCOL ( MSG_OK ) ;
SERIAL_PROTOCOL ( " p: " ) ;
SERIAL_PROTOCOL ( " p: " ) ;
SERIAL_PROTOCOL ( bedKp ) ;
SERIAL_PROTOCOL ( bedKp ) ;
SERIAL_PROTOCOL ( " i: " ) ;
SERIAL_PROTOCOL ( " i: " ) ;
SERIAL_PROTOCOL ( unscalePID_i ( bedKi ) ) ;
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/
case 240 : // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
{
{
# ifdef PHOTOGRAPH_PIN
# ifdef PHOTOGRAPH_PIN
# if (PHOTOGRAPH_PIN > -1 )
# if (PHOTOGRAPH_PIN > 0 )
const uint8_t NUM_PULSES = 16 ;
const uint8_t NUM_PULSES = 16 ;
const float PULSE_LENGTH = 0.01524 ;
const float PULSE_LENGTH = 0.01524 ;
for ( int i = 0 ; i < NUM_PULSES ; i + + ) {
for ( int i = 0 ; i < NUM_PULSES ; i + + ) {
@ -1534,7 +1633,7 @@ void process_commands()
# endif
# endif
}
}
break ;
break ;
case 302 : // allow cold extrudes
case 302 : // allow cold extrudes
{
{
allow_cold_extrudes ( true ) ;
allow_cold_extrudes ( true ) ;
@ -1546,8 +1645,8 @@ void process_commands()
int e = 0 ;
int e = 0 ;
int c = 5 ;
int c = 5 ;
if ( code_seen ( ' E ' ) ) e = code_value ( ) ;
if ( code_seen ( ' E ' ) ) e = code_value ( ) ;
if ( e < 0 )
if ( e < 0 )
temp = 70 ;
temp = 70 ;
if ( code_seen ( ' S ' ) ) temp = code_value ( ) ;
if ( code_seen ( ' S ' ) ) temp = code_value ( ) ;
if ( code_seen ( ' C ' ) ) c = code_value ( ) ;
if ( code_seen ( ' C ' ) ) c = code_value ( ) ;
PID_autotune ( temp , e , c ) ;
PID_autotune ( temp , e , c ) ;
@ -1599,7 +1698,7 @@ void process_commands()
lastpos [ Z_AXIS ] = current_position [ Z_AXIS ] ;
lastpos [ Z_AXIS ] = current_position [ Z_AXIS ] ;
lastpos [ E_AXIS ] = current_position [ E_AXIS ] ;
lastpos [ E_AXIS ] = current_position [ E_AXIS ] ;
//retract by E
//retract by E
if ( code_seen ( ' E ' ) )
if ( code_seen ( ' E ' ) )
{
{
target [ E_AXIS ] + = code_value ( ) ;
target [ E_AXIS ] + = code_value ( ) ;
}
}
@ -1610,9 +1709,9 @@ void process_commands()
# endif
# endif
}
}
plan_buffer_line ( target [ X_AXIS ] , target [ Y_AXIS ] , target [ Z_AXIS ] , target [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
plan_buffer_line ( target [ X_AXIS ] , target [ Y_AXIS ] , target [ Z_AXIS ] , target [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
//lift Z
//lift Z
if ( code_seen ( ' Z ' ) )
if ( code_seen ( ' Z ' ) )
{
{
target [ Z_AXIS ] + = code_value ( ) ;
target [ Z_AXIS ] + = code_value ( ) ;
}
}
@ -1623,9 +1722,9 @@ void process_commands()
# endif
# endif
}
}
plan_buffer_line ( target [ X_AXIS ] , target [ Y_AXIS ] , target [ Z_AXIS ] , target [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
plan_buffer_line ( target [ X_AXIS ] , target [ Y_AXIS ] , target [ Z_AXIS ] , target [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
//move xy
//move xy
if ( code_seen ( ' X ' ) )
if ( code_seen ( ' X ' ) )
{
{
target [ X_AXIS ] + = code_value ( ) ;
target [ X_AXIS ] + = code_value ( ) ;
}
}
@ -1635,7 +1734,7 @@ void process_commands()
target [ X_AXIS ] = FILAMENTCHANGE_XPOS ;
target [ X_AXIS ] = FILAMENTCHANGE_XPOS ;
# endif
# endif
}
}
if ( code_seen ( ' Y ' ) )
if ( code_seen ( ' Y ' ) )
{
{
target [ Y_AXIS ] = code_value ( ) ;
target [ Y_AXIS ] = code_value ( ) ;
}
}
@ -1645,9 +1744,9 @@ void process_commands()
target [ Y_AXIS ] = FILAMENTCHANGE_YPOS ;
target [ Y_AXIS ] = FILAMENTCHANGE_YPOS ;
# endif
# endif
}
}
plan_buffer_line ( target [ X_AXIS ] , target [ Y_AXIS ] , target [ Z_AXIS ] , target [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
plan_buffer_line ( target [ X_AXIS ] , target [ Y_AXIS ] , target [ Z_AXIS ] , target [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
if ( code_seen ( ' L ' ) )
if ( code_seen ( ' L ' ) )
{
{
target [ E_AXIS ] + = code_value ( ) ;
target [ E_AXIS ] + = code_value ( ) ;
@ -1658,9 +1757,9 @@ void process_commands()
target [ E_AXIS ] + = FILAMENTCHANGE_FINALRETRACT ;
target [ E_AXIS ] + = FILAMENTCHANGE_FINALRETRACT ;
# endif
# endif
}
}
plan_buffer_line ( target [ X_AXIS ] , target [ Y_AXIS ] , target [ Z_AXIS ] , target [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
plan_buffer_line ( target [ X_AXIS ] , target [ Y_AXIS ] , target [ Z_AXIS ] , target [ E_AXIS ] , feedrate / 60 , active_extruder ) ;
//finish moves
//finish moves
st_synchronize ( ) ;
st_synchronize ( ) ;
//disable extruder steppers so filament can be removed
//disable extruder steppers so filament can be removed
@ -1675,12 +1774,11 @@ void process_commands()
manage_heater ( ) ;
manage_heater ( ) ;
manage_inactivity ( ) ;
manage_inactivity ( ) ;
lcd_update ( ) ;
lcd_update ( ) ;
if ( cnt = = 0 )
if ( cnt = = 0 )
{
{
# if defined(BEEPER) && BEEPER > -1
# if BEEPER > 0
SET_OUTPUT ( BEEPER ) ;
SET_OUTPUT ( BEEPER ) ;
WRITE ( BEEPER , HIGH ) ;
WRITE ( BEEPER , HIGH ) ;
delay ( 3 ) ;
delay ( 3 ) ;
WRITE ( BEEPER , LOW ) ;
WRITE ( BEEPER , LOW ) ;
@ -1690,9 +1788,9 @@ void process_commands()
# endif
# endif
}
}
}
}
//return to normal
//return to normal
if ( code_seen ( ' L ' ) )
if ( code_seen ( ' L ' ) )
{
{
target [ E_AXIS ] + = - code_value ( ) ;
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
plan_buffer_line ( lastpos [ X_AXIS ] , lastpos [ Y_AXIS ] , lastpos [ Z_AXIS ] , lastpos [ E_AXIS ] , feedrate / 60 , active_extruder ) ; //final untretract
}
}
break ;
break ;
# endif //FILAMENTCHANGEENABLE
# endif //FILAMENTCHANGEENABLE
case 907 : // M907 Set digital trimpot motor current using axis codes.
case 907 : // M907 Set digital trimpot motor current using axis codes.
{
{
# if DIGIPOTSS_PIN > -1
# if DIGIPOTSS_PIN > 0
for ( int i = 0 ; i < = NUM_AXIS ; i + + ) if ( code_seen ( axis_codes [ i ] ) ) digipot_current ( i , code_value ( ) ) ;
for ( int i = 0 ; i < NUM_AXIS ; i + + ) if ( code_seen ( axis_codes [ i ] ) ) digipot_current ( i , code_value ( ) ) ;
if ( code_seen ( ' B ' ) ) digipot_current ( 4 , code_value ( ) ) ;
if ( code_seen ( ' B ' ) ) digipot_current ( 4 , code_value ( ) ) ;
if ( code_seen ( ' S ' ) ) for ( int i = 0 ; i < = 4 ; i + + ) digipot_current ( i , code_value ( ) ) ;
if ( code_seen ( ' S ' ) ) for ( int i = 0 ; i < = 4 ; i + + ) digipot_current ( i , code_value ( ) ) ;
# endif
# endif
}
}
break ;
case 908 : // M908 Control digital trimpot directly.
case 908 : // M908 Control digital trimpot directly.
{
{
# if DIGIPOTSS_PIN > -1
# if DIGIPOTSS_PIN > 0
uint8_t channel , current ;
uint8_t channel , current ;
if ( code_seen ( ' P ' ) ) channel = code_value ( ) ;
if ( code_seen ( ' P ' ) ) channel = code_value ( ) ;
if ( code_seen ( ' S ' ) ) current = code_value ( ) ;
if ( code_seen ( ' S ' ) ) current = code_value ( ) ;
@ -1731,9 +1830,9 @@ void process_commands()
break ;
break ;
case 350 : // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
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 X_MS1_PIN > 0
if ( code_seen ( ' S ' ) ) for ( int i = 0 ; i < = 4 ; i + + ) microstep_mode ( i , code_value ( ) ) ;
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 ( ) ) ;
for ( int i = 0 ; i < NUM_AXIS ; i + + ) if ( code_seen ( axis_codes [ i ] ) ) microstep_mode ( i , ( uint8_t ) code_value ( ) ) ;
if ( code_seen ( ' B ' ) ) microstep_mode ( 4 , code_value ( ) ) ;
if ( code_seen ( ' B ' ) ) microstep_mode ( 4 , code_value ( ) ) ;
microstep_readings ( ) ;
microstep_readings ( ) ;
# endif
# endif
@ -1741,15 +1840,15 @@ void process_commands()
break ;
break ;
case 351 : // M351 Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
case 351 : // M351 Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
{
{
# if X_MS1_PIN > -1
# if X_MS1_PIN > 0
if ( code_seen ( ' S ' ) ) switch ( ( int ) code_value ( ) )
if ( code_seen ( ' S ' ) ) switch ( ( int ) code_value ( ) )
{
{
case 1 :
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 < NUM_AXIS ; i + + ) if ( code_seen ( axis_codes [ i ] ) ) microstep_ms ( i , code_value ( ) , - 1 ) ;
if ( code_seen ( ' B ' ) ) microstep_ms ( 4 , code_value ( ) , - 1 ) ;
if ( code_seen ( ' B ' ) ) microstep_ms ( 4 , code_value ( ) , - 1 ) ;
break ;
break ;
case 2 :
case 2 :
for ( int i = 0 ; i < = NUM_AXIS ; i + + ) if ( code_seen ( axis_codes [ i ] ) ) microstep_ms ( i , - 1 , code_value ( ) ) ;
for ( int i = 0 ; i < NUM_AXIS ; i + + ) if ( code_seen ( axis_codes [ i ] ) ) microstep_ms ( i , - 1 , code_value ( ) ) ;
if ( code_seen ( ' B ' ) ) microstep_ms ( 4 , - 1 , code_value ( ) ) ;
if ( code_seen ( ' B ' ) ) microstep_ms ( 4 , - 1 , code_value ( ) ) ;
break ;
break ;
}
}
@ -1766,7 +1865,7 @@ void process_commands()
}
}
}
}
else if ( code_seen ( ' T ' ) )
else if ( code_seen ( ' T ' ) )
{
{
tmp_extruder = code_value ( ) ;
tmp_extruder = code_value ( ) ;
if ( tmp_extruder > = EXTRUDERS ) {
if ( tmp_extruder > = EXTRUDERS ) {
@ -1791,7 +1890,7 @@ void process_commands()
// Offset extruder (only by XY)
// Offset extruder (only by XY)
int i ;
int i ;
for ( i = 0 ; i < 2 ; 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 ] [ active_extruder ] +
extruder_offset [ i ] [ tmp_extruder ] ;
extruder_offset [ i ] [ tmp_extruder ] ;
}
}
@ -1837,14 +1936,14 @@ void ClearToSend()
if ( fromsd [ bufindr ] )
if ( fromsd [ bufindr ] )
return ;
return ;
# endif //SDSUPPORT
# endif //SDSUPPORT
SERIAL_PROTOCOLLNPGM ( MSG_OK ) ;
SERIAL_PROTOCOLLNPGM ( MSG_OK ) ;
}
}
void get_coordinates ( )
void get_coordinates ( )
{
{
bool seen [ 4 ] = { false , false , false , false } ;
bool seen [ 4 ] = { false , false , false , false } ;
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 ] ) )
{
{
destination [ i ] = ( float ) code_value ( ) + ( axis_relative_modes [ i ] | | relative_mode ) * current_position [ i ] ;
destination [ i ] = ( float ) code_value ( ) + ( axis_relative_modes [ i ] | | relative_mode ) * current_position [ i ] ;
seen [ i ] = true ;
seen [ i ] = true ;
@ -1862,23 +1961,23 @@ void get_coordinates()
float echange = destination [ E_AXIS ] - current_position [ E_AXIS ] ;
float echange = destination [ E_AXIS ] - current_position [ E_AXIS ] ;
if ( echange < - MIN_RETRACT ) //retract
if ( echange < - MIN_RETRACT ) //retract
{
{
if ( ! retracted )
if ( ! retracted )
{
{
destination [ Z_AXIS ] + = retract_zlift ; //not sure why chaninging current_position negatively does not work.
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
//if slicer retracted by echange=-1mm and you want to retract 3mm, corrrectede=-2mm additionally
float correctede = - echange - retract_length ;
float correctede = - echange - retract_length ;
//to generate the additional steps, not the destination is changed, but inversely the current position
//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 ;
feedrate = retract_feedrate ;
retracted = true ;
retracted = true ;
}
}
}
}
else
else
if ( echange > MIN_RETRACT ) //retract_recover
if ( echange > MIN_RETRACT ) //retract_recover
{
{
if ( retracted )
if ( retracted )
{
{
//current_position[Z_AXIS]+=-retract_zlift;
//current_position[Z_AXIS]+=-retract_zlift;
//if slicer retracted_recovered by echange=+1mm and you want to retract_recover 3mm, corrrectede=2mm additionally
//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 ;
retracted = false ;
}
}
}
}
}
}
# endif //FWRETRACT
# endif //FWRETRACT
}
}
@ -1906,7 +2005,7 @@ void get_arc_coordinates()
if ( code_seen ( ' I ' ) ) {
if ( code_seen ( ' I ' ) ) {
offset [ 0 ] = code_value ( ) ;
offset [ 0 ] = code_value ( ) ;
}
}
else {
else {
offset [ 0 ] = 0.0 ;
offset [ 0 ] = 0.0 ;
}
}
@ -1937,7 +2036,7 @@ void prepare_move()
{
{
clamp_to_software_endstops ( destination ) ;
clamp_to_software_endstops ( destination ) ;
previous_millis_cmd = millis ( ) ;
previous_millis_cmd = millis ( ) ;
// Do not use feedmultiply for E or Z only moves
// 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 ] ) ) {
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 ) ;
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
// Trace the arc
mc_arc ( current_position , destination , offset , X_AXIS , Y_AXIS , Z_AXIS , feedrate * feedmultiply / 60 / 100.0 , r , isclockwise , active_extruder ) ;
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
// 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
// motion control system might still be processing the action and the real tool position
// in any intermediate location.
// 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
if ( ( millis ( ) - lastMotorCheck ) > = 2500 ) //Not a time critical function, so we only check every 2500ms
{
{
lastMotorCheck = millis ( ) ;
lastMotorCheck = millis ( ) ;
if ( ! READ ( X_ENABLE_PIN ) | | ! READ ( Y_ENABLE_PIN ) | | ! READ ( Z_ENABLE_PIN )
if ( ! READ ( X_ENABLE_PIN ) | | ! READ ( Y_ENABLE_PIN ) | | ! READ ( Z_ENABLE_PIN )
# if EXTRUDERS > 2
# if EXTRUDERS > 2
| | ! READ ( E2_ENABLE_PIN )
| | ! READ ( E2_ENABLE_PIN )
# endif
# endif
# if EXTRUDER > 1
# if EXTRUDER > 1
| | ! READ ( E 2 _ENABLE_PIN)
| | ! READ ( E 1 _ENABLE_PIN)
# endif
# 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
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
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
if ( ( millis ( ) - lastExtruderCheck ) > = 2500 ) //Not a time critical function, so we only check every 2500ms
{
{
lastExtruderCheck = millis ( ) ;
lastExtruderCheck = millis ( ) ;
if ( degHotend ( active_extruder ) < EXTRUDERFAN_DEC )
if ( degHotend ( active_extruder ) < EXTRUDERFAN_DEC )
{
{
WRITE ( EXTRUDERFAN_PIN , LOW ) ; //... turn the fan off
WRITE ( EXTRUDERFAN_PIN , LOW ) ; //... turn the fan off
@ -2020,13 +2119,13 @@ void extruderFan()
}
}
# endif
# endif
void manage_inactivity ( )
void manage_inactivity ( )
{
{
if ( ( millis ( ) - previous_millis_cmd ) > max_inactive_time )
if ( ( millis ( ) - previous_millis_cmd ) > max_inactive_time )
if ( max_inactive_time )
if ( max_inactive_time )
kill ( ) ;
kill ( ) ;
if ( stepper_inactive_time ) {
if ( stepper_inactive_time ) {
if ( ( millis ( ) - previous_millis_cmd ) > stepper_inactive_time )
if ( ( millis ( ) - previous_millis_cmd ) > stepper_inactive_time )
{
{
if ( blocks_queued ( ) = = false ) {
if ( blocks_queued ( ) = = false ) {
disable_x ( ) ;
disable_x ( ) ;
@ -2046,15 +2145,15 @@ void manage_inactivity()
controllerFan ( ) ; //Check if fan should be turned on to cool stepper drivers down
controllerFan ( ) ; //Check if fan should be turned on to cool stepper drivers down
# endif
# endif
# ifdef EXTRUDER_RUNOUT_PREVENT
# 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 )
if ( degHotend ( active_extruder ) > EXTRUDER_RUNOUT_MINTEMP )
{
{
bool oldstatus = READ ( E0_ENABLE_PIN ) ;
bool oldstatus = READ ( E0_ENABLE_PIN ) ;
enable_e0 ( ) ;
enable_e0 ( ) ;
float oldepos = current_position [ E_AXIS ] ;
float oldepos = current_position [ E_AXIS ] ;
float oldedes = destination [ E_AXIS ] ;
float oldedes = destination [ E_AXIS ] ;
plan_buffer_line ( current_position [ X_AXIS ] , current_position [ Y_AXIS ] , current_position [ Z_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 ] ,
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 ) ;
EXTRUDER_RUNOUT_SPEED / 60. * EXTRUDER_RUNOUT_ESTEPS / axis_steps_per_unit [ E_AXIS ] , active_extruder ) ;
current_position [ E_AXIS ] = oldepos ;
current_position [ E_AXIS ] = oldepos ;
destination [ E_AXIS ] = oldedes ;
destination [ E_AXIS ] = oldedes ;
@ -2078,8 +2177,8 @@ void kill()
disable_e0 ( ) ;
disable_e0 ( ) ;
disable_e1 ( ) ;
disable_e1 ( ) ;
disable_e2 ( ) ;
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_ERROR_START ;
SERIAL_ERRORLNPGM ( MSG_ERR_KILLED ) ;
SERIAL_ERRORLNPGM ( MSG_ERR_KILLED ) ;
LCD_ALERTMESSAGEPGM ( MSG_KILLED ) ;
LCD_ALERTMESSAGEPGM ( MSG_KILLED ) ;
@ -2107,7 +2206,7 @@ void setPwmFrequency(uint8_t pin, int val)
val & = 0x07 ;
val & = 0x07 ;
switch ( digitalPinToTimer ( pin ) )
switch ( digitalPinToTimer ( pin ) )
{
{
# if defined(TCCR0A)
# if defined(TCCR0A)
case TIMER0A :
case TIMER0A :
case TIMER0B :
case TIMER0B :
@ -2149,7 +2248,7 @@ void setPwmFrequency(uint8_t pin, int val)
break ;
break ;
# endif
# endif
# if defined(TCCR4A)
# if defined(TCCR4A)
case TIMER4A :
case TIMER4A :
case TIMER4B :
case TIMER4B :
case TIMER4C :
case TIMER4C :
@ -2158,7 +2257,7 @@ void setPwmFrequency(uint8_t pin, int val)
break ;
break ;
# endif
# endif
# if defined(TCCR5A)
# if defined(TCCR5A)
case TIMER5A :
case TIMER5A :
case TIMER5B :
case TIMER5B :
case TIMER5C :
case TIMER5C :