Commit e2038cc4 authored by MagoKimbra's avatar MagoKimbra

Update marlin_main.cpp

parent e9ab810f
...@@ -143,8 +143,8 @@ void manage_inactivity(bool ignore_stepper_queue=false); ...@@ -143,8 +143,8 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#endif #endif
#else #else
#define enable_z() ; #define enable_z();
#define disable_z() ; #define disable_z();
#endif #endif
#if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1) #if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
...@@ -179,6 +179,8 @@ void manage_inactivity(bool ignore_stepper_queue=false); ...@@ -179,6 +179,8 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#define disable_e3() /* nothing */ #define disable_e3() /* nothing */
#endif #endif
#define disable_e() {disable_e0(); disable_e1(); disable_e2(); disable_e3();}
enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3}; enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3};
......
...@@ -57,134 +57,135 @@ ...@@ -57,134 +57,135 @@
// look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html // look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html
// http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes // http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
//Implemented Codes /* Implemented Codes
//------------------- -------------------
// G0 -> G1 G0 -> G1
// G1 - Coordinated Movement X Y Z E G1 - Coordinated Movement X Y Z E
// G2 - CW ARC G2 - CW ARC
// G3 - CCW ARC G3 - CCW ARC
// G4 - Dwell S<seconds> or P<milliseconds> G4 - Dwell S<seconds> or P<milliseconds>
// G10 - retract filament according to settings of M207 G10 - retract filament according to settings of M207
// G11 - retract recover filament according to settings of M208 G11 - retract recover filament according to settings of M208
// G28 - Home all Axis G28 - Home all Axis
// G29 - Detailed Z-Probe, probes the bed at 3 or more points. Will fail if you haven't homed yet. G29 - Detailed Z-Probe, probes the bed at 3 or more points. Will fail if you haven't homed yet.
// G30 - Single Z Probe, probes bed at current XY location. - Bed Probe and Delta geometry Autocalibration G30 - Single Z Probe, probes bed at current XY location. - Bed Probe and Delta geometry Autocalibration
// G31 - Dock sled (Z_PROBE_SLED only) G31 - Dock sled (Z_PROBE_SLED only)
// G32 - Undock sled (Z_PROBE_SLED only) G32 - Undock sled (Z_PROBE_SLED only)
// G60 - Memory actual position G60 - Memory actual position
// G61 - Move X Y Z to position in memory G61 - Move X Y Z to position in memory
// G90 - Use Absolute Coordinates G90 - Use Absolute Coordinates
// G91 - Use Relative Coordinates G91 - Use Relative Coordinates
// G92 - Set current position to coordinates given G92 - Set current position to coordinates given
// M Codes M Codes
// M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled) M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled)
// M1 - Same as M0 M1 - Same as M0
// M03 - Put S<value> in laser beam control M03 - Put S<value> in laser beam control
// M04 - Turn on laser beam M04 - Turn on laser beam
// M05 - Turn off laser beam M05 - Turn off laser beam
// M17 - Enable/Power all stepper motors M17 - Enable/Power all stepper motors
// M18 - Disable all stepper motors; same as M84 M18 - Disable all stepper motors; same as M84
// M20 - List SD card M20 - List SD card
// M21 - Init SD card M21 - Init SD card
// M22 - Release SD card M22 - Release SD card
// M23 - Select SD file (M23 filename.g) M23 - Select SD file (M23 filename.g)
// M24 - Start/resume SD print M24 - Start/resume SD print
// M25 - Pause SD print M25 - Pause SD print
// M26 - Set SD position in bytes (M26 S12345) M26 - Set SD position in bytes (M26 S12345)
// M27 - Report SD print status M27 - Report SD print status
// M28 - Start SD write (M28 filename.g) M28 - Start SD write (M28 filename.g)
// M29 - Stop SD write M29 - Stop SD write
// M30 - Delete file from SD (M30 filename.g) M30 - Delete file from SD (M30 filename.g)
// M31 - Output time since last M109 or SD card start to serial M31 - Output time since last M109 or SD card start to serial
// M32 - Select file and start SD print (Can be used _while_ printing from SD card files): M32 - Select file and start SD print (Can be used _while_ printing from SD card files):
// syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#" syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#"
// Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include). Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include).
// The '#' is necessary when calling from within sd files, as it stops buffer prereading The '#' is necessary when calling from within sd files, as it stops buffer prereading
// M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used. M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used.
// M49 - Z probe repetability test M49 - Z probe repetability test
// M80 - Turn on Power Supply M80 - Turn on Power Supply
// 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
// M104 - Set extruder target temp M104 - Set extruder target temp
// M105 - Read current temp M105 - Read current temp
// M106 - Fan on M106 - Fan on
// M107 - Fan off M107 - Fan off
// M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating
// Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling
// IF AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F IF AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
// M111 - Debug mode M111 - Debug mode
// M112 - Emergency stop M112 - Emergency stop
// 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) M126 - Solenoid Air Valve Open (BariCUDA support by jmil)
// M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure 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) M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
// M129 - EtoP Closed (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
// M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work. M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work.
// M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
// Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
// M200 D<millimeters>- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters). M200 D<millimeters>- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).
// M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
// M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
// M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) in mm/sec^2 also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) in mm/sec^2 also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate
// M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk
// M206 - set additional homing offset M206 - set additional homing offset
// M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting
// M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec] M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec]
// 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. 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.
// M218 - set hotend offset (in mm): T<extruder_number> X<offset_on_X> Y<offset_on_Y> M218 - set hotend offset (in mm): T<extruder_number> X<offset_on_X> Y<offset_on_Y>
// 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
// M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
// M240 - Trigger a camera to take a photograph M240 - Trigger a camera to take a photograph
// M250 - Set LCD contrast C<contrast value> (value 0..63) M250 - Set LCD contrast C<contrast value> (value 0..63)
// M280 - set servo position absolute. P: servo index, S: angle or microseconds M280 - set servo position absolute. P: servo index, S: angle or microseconds
// M300 - Play beep sound S<frequency Hz> P<duration ms> M300 - Play beep sound 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, or set the minimum extrude S<temperature>. M302 - Allow cold extrudes, or set the minimum extrude S<temperature>.
// M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C) M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
// 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
// M401 - Lower z-probe if present M401 - Lower z-probe if present
// M402 - Raise z-probe if present M402 - Raise z-probe if present
// M404 - N<dia in mm> Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters M404 - N<dia in mm> Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters
// M405 - Turn on Filament Sensor extrusion control. Optional D<delay in cm> to set delay in centimeters between sensor and extruder M405 - Turn on Filament Sensor extrusion control. Optional D<delay in cm> to set delay in centimeters between sensor and extruder
// M406 - Turn off Filament Sensor extrusion control M406 - Turn off Filament Sensor extrusion control
// M407 - Displays measured filament diameter M407 - Displays measured filament diameter
// M500 - Store parameters in EEPROM M500 - Store parameters in EEPROM
// M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily).
// M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. M502 - Revert 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). Use S0 to leave off headings. M503 - Print the current settings (from memory not from EEPROM). Use S0 to leave off headings.
// 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)
// M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
// M605 - Set dual x-carriage movement mode: S<mode> [ X<duplication x-offset> R<duplication temp offset> ] M605 - Set dual x-carriage movement mode: S<mode> [ X<duplication x-offset> R<duplication temp offset> ]
// M666 - Set z probe offset or Endstop and delta geometry adjustment M666 - Set z probe offset or Endstop and delta geometry adjustment
// M907 - Set digital trimpot motor current using axis codes. M907 - Set digital trimpot motor current using axis codes.
// M908 - Control digital trimpot directly. M908 - Control digital trimpot directly.
// M350 - Set microstepping mode. M350 - Set microstepping mode.
// M351 - Toggle MS1 MS2 pins directly. M351 - Toggle MS1 MS2 pins directly.
// ************ SCARA Specific - This can change to suit future G-code regulations ************ SCARA Specific - This can change to suit future G-code regulations
// M360 - SCARA calibration: Move to calc-position ThetaA (0 deg calibration) M360 - SCARA calibration: Move to calc-position ThetaA (0 deg calibration)
// M361 - SCARA calibration: Move to calc-position ThetaB (90 deg calibration - steps per degree) M361 - SCARA calibration: Move to calc-position ThetaB (90 deg calibration - steps per degree)
// M362 - SCARA calibration: Move to calc-position PsiA (0 deg calibration) M362 - SCARA calibration: Move to calc-position PsiA (0 deg calibration)
// M363 - SCARA calibration: Move to calc-position PsiB (90 deg calibration - steps per degree) M363 - SCARA calibration: Move to calc-position PsiB (90 deg calibration - steps per degree)
// M364 - SCARA calibration: Move to calc-position PSIC (90 deg to Theta calibration position) M364 - SCARA calibration: Move to calc-position PSIC (90 deg to Theta calibration position)
// M365 - SCARA calibration: Scaling factor, X, Y, Z axis M365 - SCARA calibration: Scaling factor, X, Y, Z axis
//************* SCARA End *************** ************* SCARA End ***************
// M928 - Start SD logging (M928 filename.g) - ended by M29 M928 - Start SD logging (M928 filename.g) - ended by M29
// M997 - NPR2 Color rotate M997 - NPR2 Color rotate
// M999 - Restart after being stopped by error M999 - Restart after being stopped by error
*/
#ifdef SDSUPPORT #ifdef SDSUPPORT
CardReader card; CardReader card;
...@@ -234,6 +235,8 @@ float volumetric_multiplier[EXTRUDERS] = {1.0 ...@@ -234,6 +235,8 @@ float volumetric_multiplier[EXTRUDERS] = {1.0
float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 }; float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 }; float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
float add_homing[3]={ 0, 0, 0 }; float add_homing[3]={ 0, 0, 0 };
int fanSpeed = 0;
bool cancel_heatup = false;
#ifdef NPR2 #ifdef NPR2
int old_color = 99; int old_color = 99;
...@@ -296,18 +299,17 @@ float lastpos[4]; ...@@ -296,18 +299,17 @@ float lastpos[4];
uint8_t active_extruder = 0; uint8_t active_extruder = 0;
uint8_t active_driver = 0; uint8_t active_driver = 0;
uint8_t debugLevel = 0; uint8_t debugLevel = 0;
int fanSpeed = 0;
#ifdef SERVO_ENDSTOPS && (NUM_SERVOS > 0) #ifdef SERVO_ENDSTOPS && (NUM_SERVOS > 0)
int servo_endstops[] = SERVO_ENDSTOPS; int servo_endstops[] = SERVO_ENDSTOPS;
int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES; int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES;
#endif #endif //SERVO_ENDSTOPS && (NUM_SERVOS > 0)
#ifdef BARICUDA #ifdef BARICUDA
int ValvePressure = 0; int ValvePressure = 0;
int EtoPPressure = 0; int EtoPPressure = 0;
#endif #endif //BARICUDA
#ifdef FWRETRACT #ifdef FWRETRACT
bool autoretract_enabled = false; bool autoretract_enabled = false;
...@@ -340,7 +342,7 @@ int fanSpeed = 0; ...@@ -340,7 +342,7 @@ int fanSpeed = 0;
float retract_recover_length = RETRACT_RECOVER_LENGTH; float retract_recover_length = RETRACT_RECOVER_LENGTH;
float retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP; float retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
float retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE; float retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
#endif // FWRETRACT #endif //FWRETRACT
#ifdef ULTIPANEL #ifdef ULTIPANEL
#ifdef PS_DEFAULT_OFF #ifdef PS_DEFAULT_OFF
...@@ -354,8 +356,6 @@ int fanSpeed = 0; ...@@ -354,8 +356,6 @@ int fanSpeed = 0;
float axis_scaling[3] = { 1, 1, 1 }; // Build size scaling, default to 1 float axis_scaling[3] = { 1, 1, 1 }; // Build size scaling, default to 1
#endif //SCARA #endif //SCARA
bool cancel_heatup = false;
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
//Variables for Filament Sensor input //Variables for Filament Sensor input
float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404
...@@ -965,13 +965,13 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); ...@@ -965,13 +965,13 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
#error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions #error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
#endif #endif
#define DXC_FULL_CONTROL_MODE 0 #define DXC_FULL_CONTROL_MODE 0
#define DXC_AUTO_PARK_MODE 1 #define DXC_AUTO_PARK_MODE 1
#define DXC_DUPLICATION_MODE 2 #define DXC_DUPLICATION_MODE 2
static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE; static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
static float x_home_pos(int extruder) static float x_home_pos(int extruder)
{ {
if (extruder == 0) if (extruder == 0)
{ {
return base_home_pos(X_AXIS) + add_homing[X_AXIS]; return base_home_pos(X_AXIS) + add_homing[X_AXIS];
...@@ -984,20 +984,20 @@ static float x_home_pos(int extruder) ...@@ -984,20 +984,20 @@ static float x_home_pos(int extruder)
// (through the M218 command). // (through the M218 command).
return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS; return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS;
} }
} }
static int x_home_dir(int extruder) static int x_home_dir(int extruder)
{ {
return (extruder == 0) ? X_HOME_DIR : X2_HOME_DIR; return (extruder == 0) ? X_HOME_DIR : X2_HOME_DIR;
} }
static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1 static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1
static bool active_extruder_parked = false; // used in mode 1 & 2 static bool active_extruder_parked = false; // used in mode 1 & 2
static float raised_parked_position[NUM_AXIS]; // used in mode 1 static float raised_parked_position[NUM_AXIS]; // used in mode 1
static unsigned long delayed_move_time = 0; // used in mode 1 static unsigned long delayed_move_time = 0; // used in mode 1
static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2 static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
static float duplicate_extruder_temp_offset = 0; // used in mode 2 static float duplicate_extruder_temp_offset = 0; // used in mode 2
bool extruder_duplication_enabled = false; // used in mode 2 bool extruder_duplication_enabled = false; // used in mode 2
#endif //DUAL_X_CARRIAGE #endif //DUAL_X_CARRIAGE
#if defined(CARTESIAN) || defined(COREXY) || defined(SCARA) #if defined(CARTESIAN) || defined(COREXY) || defined(SCARA)
...@@ -1781,6 +1781,59 @@ bool extruder_duplication_enabled = false; // used in mode 2 ...@@ -1781,6 +1781,59 @@ bool extruder_duplication_enabled = false; // used in mode 2
} }
} }
void calculate_delta(float cartesian[3])
{
delta[X_AXIS] = sqrt(DELTA_DIAGONAL_ROD_2
- sq(delta_tower1_x-cartesian[X_AXIS])
- sq(delta_tower1_y-cartesian[Y_AXIS])
) + cartesian[Z_AXIS];
delta[Y_AXIS] = sqrt(DELTA_DIAGONAL_ROD_2
- sq(delta_tower2_x-cartesian[X_AXIS])
- sq(delta_tower2_y-cartesian[Y_AXIS])
) + cartesian[Z_AXIS];
delta[Z_AXIS] = sqrt(DELTA_DIAGONAL_ROD_2
- sq(delta_tower3_x-cartesian[X_AXIS])
- sq(delta_tower3_y-cartesian[Y_AXIS])
) + cartesian[Z_AXIS];
}
// Adjust print surface height by linear interpolation over the bed_level array.
void adjust_delta(float cartesian[3])
{
float grid_x = max(-2.999, min(2.999, cartesian[X_AXIS] / AUTOLEVEL_GRID));
float grid_y = max(-2.999, min(2.999, cartesian[Y_AXIS] / AUTOLEVEL_GRID));
int floor_x = floor(grid_x);
int floor_y = floor(grid_y);
float ratio_x = grid_x - floor_x;
float ratio_y = grid_y - floor_y;
float z1 = bed_level[floor_x+3][floor_y+3];
float z2 = bed_level[floor_x+3][floor_y+4];
float z3 = bed_level[floor_x+4][floor_y+3];
float z4 = bed_level[floor_x+4][floor_y+4];
float left = (1-ratio_y)*z1 + ratio_y*z2;
float right = (1-ratio_y)*z3 + ratio_y*z4;
float offset = (1-ratio_x)*left + ratio_x*right;
delta[X_AXIS] += offset;
delta[Y_AXIS] += offset;
delta[Z_AXIS] += offset;
/*
SERIAL_ECHOPGM("grid_x="); SERIAL_ECHO(grid_x);
SERIAL_ECHOPGM(" grid_y="); SERIAL_ECHO(grid_y);
SERIAL_ECHOPGM(" floor_x="); SERIAL_ECHO(floor_x);
SERIAL_ECHOPGM(" floor_y="); SERIAL_ECHO(floor_y);
SERIAL_ECHOPGM(" ratio_x="); SERIAL_ECHO(ratio_x);
SERIAL_ECHOPGM(" ratio_y="); SERIAL_ECHO(ratio_y);
SERIAL_ECHOPGM(" z1="); SERIAL_ECHO(z1);
SERIAL_ECHOPGM(" z2="); SERIAL_ECHO(z2);
SERIAL_ECHOPGM(" z3="); SERIAL_ECHO(z3);
SERIAL_ECHOPGM(" z4="); SERIAL_ECHO(z4);
SERIAL_ECHOPGM(" left="); SERIAL_ECHO(left);
SERIAL_ECHOPGM(" right="); SERIAL_ECHO(right);
SERIAL_ECHOPGM(" offset="); SERIAL_ECHOLN(offset);
*/
}
#endif //DELTA #endif //DELTA
void refresh_cmd_timeout(void) void refresh_cmd_timeout(void)
...@@ -3433,6 +3486,158 @@ void gcode_G92() ...@@ -3433,6 +3486,158 @@ void gcode_G92()
} }
#endif //defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST) #endif //defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
#ifdef FILAMENTCHANGEENABLE
//M600: Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
void gcode_M600()
{
float target[NUM_AXIS];
for (int i=0; i<NUM_AXIS; i++) target[i] = lastpos[i] = current_position[i];
//retract by E
if(code_seen('E'))
{
target[E_AXIS]+= code_value();
}
else
{
#ifdef FILAMENTCHANGE_FIRSTRETRACT
target[E_AXIS]+= FILAMENTCHANGE_FIRSTRETRACT;
#endif
}
#ifdef DELTA
calculate_delta(target);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#else
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#endif
//lift Z
if(code_seen('Z'))
{
target[Z_AXIS]+= code_value();
}
else
{
#ifdef FILAMENTCHANGE_ZADD
target[Z_AXIS]+= FILAMENTCHANGE_ZADD;
#endif
}
#ifdef DELTA
calculate_delta(target);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#else
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#endif
//move xy
if(code_seen('X'))
{
target[X_AXIS]= code_value();
}
else
{
#ifdef FILAMENTCHANGE_XPOS
target[X_AXIS]= FILAMENTCHANGE_XPOS;
#endif
}
if(code_seen('Y'))
{
target[Y_AXIS]= code_value();
}
else
{
#ifdef FILAMENTCHANGE_YPOS
target[Y_AXIS]= FILAMENTCHANGE_YPOS;
#endif
}
#ifdef DELTA
calculate_delta(target);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#else
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#endif
if(code_seen('L'))
{
target[E_AXIS]+= code_value();
}
else
{
#ifdef FILAMENTCHANGE_FINALRETRACT
target[E_AXIS]+= FILAMENTCHANGE_FINALRETRACT ;
#endif
}
#ifdef DELTA
calculate_delta(target);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#else
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#endif
//finish moves
st_synchronize();
//disable extruder steppers so filament can be removed
disable_e();
delay(100);
LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
uint8_t cnt=0;
while(!lcd_clicked())
{
cnt++;
manage_heater();
manage_inactivity(true);
lcd_update();
if(cnt==0)
{
#if BEEPER > 0
SET_OUTPUT(BEEPER);
WRITE(BEEPER,HIGH);
delay(3);
WRITE(BEEPER,LOW);
delay(3);
#else
#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
lcd_buzz(1000/6,100);
#else
lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS,LCD_FEEDBACK_FREQUENCY_HZ);
#endif
#endif
}
}
//return to normal
if(code_seen('L'))
{
target[E_AXIS]+= -code_value();
}
else
{
#ifdef FILAMENTCHANGE_FINALRETRACT
target[E_AXIS]+=(-1)*FILAMENTCHANGE_FINALRETRACT ;
#endif
}
#if defined(PAUSE_PIN) && PAUSE_PIN > -1
paused = false;
#endif
current_position[E_AXIS]=target[E_AXIS]; //the long retract of L is compensated by manual filament feeding
plan_set_e_position(current_position[E_AXIS]);
#ifdef DELTA
calculate_delta(lastpos);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver); //move xyz back
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], lastpos[E_AXIS], feedrate/60, active_extruder, active_driver); //final unretract
#else
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver); //move xy back
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver); //move z back
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], feedrate/60, active_extruder, active_driver); //final unretract
#endif
}
#endif //FILAMENTCHANGEENABLE
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
void gcode_M666() void gcode_M666()
{ {
...@@ -3785,7 +3990,7 @@ void process_commands() ...@@ -3785,7 +3990,7 @@ void process_commands()
//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)
{ {
...@@ -3860,7 +4065,7 @@ void process_commands() ...@@ -3860,7 +4065,7 @@ void process_commands()
autotempShutdown(); autotempShutdown();
} }
break; break;
case 42: //M42 -Change pin status via gcode case 42: //M42 - Change pin status via gcode
{ {
if (code_seen('S')) if (code_seen('S'))
{ {
...@@ -3896,32 +4101,146 @@ void process_commands() ...@@ -3896,32 +4101,146 @@ void process_commands()
break; break;
#endif //defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST) #endif //defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
case 104: //M104 #if defined(POWER_SUPPLY) && POWER_SUPPLY > 0 && defined(PS_ON_PIN) && PS_ON_PIN > -1
case 80: //M80 - Turn on Power Supply
{ {
if(setTargetedHotend(104)) break; SET_OUTPUT(PS_ON_PIN); //GND
if(debugDryrun()) break; WRITE(PS_ON_PIN, PS_ON_AWAKE);
if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
#ifdef DUAL_X_CARRIAGE // If you have a switch on suicide pin, this is useful
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0) // if you want to start another print with suicide feature after
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset); // a print without suicide...
#endif #if defined SUICIDE_PIN && SUICIDE_PIN > -1
setWatch(); SET_OUTPUT(SUICIDE_PIN);
WRITE(SUICIDE_PIN, HIGH);
#endif // SUICIDE_PIN
#ifdef ULTIPANEL
powersupply = true;
LCD_MESSAGEPGM(WELCOME_MSG);
lcd_update();
#endif // ULTIPANEL
} }
break; break;
case 105 : //M105 case 81: //M81 - Turn off Power Supply
{ {
if(setTargetedHotend(105)) break; disable_heater();
if(debugDryrun()) break; st_synchronize();
#if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 finishAndDisableSteppers();
SERIAL_PROTOCOLPGM("ok T:"); fanSpeed = 0;
SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1); delay(1000); // Wait a little before to switch off
SERIAL_PROTOCOLPGM(" /"); #if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1); st_synchronize();
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 suicide();
SERIAL_PROTOCOLPGM(" B:"); #elif defined(POWER_SUPPLY) && POWER_SUPPLY > 0 && defined(PS_ON_PIN) && PS_ON_PIN > -1
SERIAL_PROTOCOL_F(degBed(),1); SET_OUTPUT(PS_ON_PIN);
SERIAL_PROTOCOLPGM(" /"); WRITE(PS_ON_PIN, PS_ON_ASLEEP);
SERIAL_PROTOCOL_F(degTargetBed(),1); #endif
#ifdef ULTIPANEL
powersupply = false;
LCD_MESSAGEPGM(MACHINE_NAME" "MSG_OFF".");
lcd_update();
#endif
}
break;
#endif //POWER_SUPPLY
case 82: //M82
{
axis_relative_modes[3] = false;
}
break;
case 83: //M83
{
axis_relative_modes[3] = true;
}
break;
case 84: //M84
{
if(code_seen('S'))
{
stepper_inactive_time = code_value() * 1000;
}
else
{
bool all_axis = !((code_seen(axis_codes[X_AXIS])) || (code_seen(axis_codes[Y_AXIS])) || (code_seen(axis_codes[Z_AXIS]))|| (code_seen(axis_codes[E_AXIS])));
if(all_axis)
{
st_synchronize();
finishAndDisableSteppers();
}
else
{
st_synchronize();
if(code_seen('X')) disable_x();
if(code_seen('Y')) disable_y();
if(code_seen('Z')) disable_z();
#if ((E0_ENABLE_PIN != X_ENABLE_PIN) && (E1_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have separate ENABLE_PINS
if(code_seen('E'))
{
disable_e();
}
#endif
}
}
}
break;
case 85: //M85
{
if(code_seen('S'))
{
max_inactive_time = code_value() * 1000;
}
}
break;
case 92: //M92
{
for(int8_t i=0; i < NUM_AXIS; i++)
{
int e = 0;
if(code_seen(axis_codes[i]))
{
if (i == 3)
{
e = (int)code_value();
if(code_seen('S'))
{
if (e < EXTRUDERS) axis_steps_per_unit[e+3] = code_value();
}
}
else {
axis_steps_per_unit[i] = code_value();
}
}
}
}
break;
case 104: //M104
{
if(setTargetedHotend(104)) break;
if(debugDryrun()) break;
if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
#ifdef DUAL_X_CARRIAGE
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
#endif
setWatch();
}
break;
case 105 : //M105
{
if(setTargetedHotend(105)) break;
if(debugDryrun()) break;
#if defined(TEMP_0_PIN) && TEMP_0_PIN > -1
SERIAL_PROTOCOLPGM("ok T:");
SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1);
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
SERIAL_PROTOCOLPGM(" B:");
SERIAL_PROTOCOL_F(degBed(),1);
SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(degTargetBed(),1);
#endif //TEMP_BED_PIN #endif //TEMP_BED_PIN
for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder)
{ {
...@@ -4106,234 +4425,12 @@ void process_commands() ...@@ -4106,234 +4425,12 @@ void process_commands()
} }
} }
break; break;
case 112: //M112 -Emergency Stop case 112: //M112 - Emergency Stop
{ {
kill(); kill();
} }
break; break;
case 140: //M140 set bed temp case 114: //M114 - Output current position to serial port
{
if(debugDryrun()) break;
if (code_seen('S')) setTargetBed(code_value());
}
break;
case 190: //M190 - Wait for bed heater to reach target.
{
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
if(debugDryrun()) break;
LCD_MESSAGEPGM(MSG_BED_HEATING);
if (code_seen('S'))
{
setTargetBed(code_value());
CooldownNoWait = true;
}
else if (code_seen('R'))
{
setTargetBed(code_value());
CooldownNoWait = false;
}
codenum = millis();
cancel_heatup = false;
target_direction = isHeatingBed(); // true if heating, false if cooling
while ((target_direction)&&(!cancel_heatup) ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)))
{
if ((millis() - codenum) > 1000) //Print Temp Reading every 1 second while heating up.
{
float tt=degHotend(active_extruder);
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOL(tt);
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOL((int)active_extruder);
SERIAL_PROTOCOLPGM(" B:");
SERIAL_PROTOCOL_F(degBed(),1);
SERIAL_PROTOCOLLN("");
codenum = millis();
}
manage_heater();
manage_inactivity();
lcd_update();
}
LCD_MESSAGEPGM(MSG_BED_DONE);
refresh_cmd_timeout();
#endif
}
break;
#ifdef BARICUDA
// PWM for HEATER_1_PIN
#if defined(HEATER_1_PIN) && HEATER_1_PIN > -1
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 defined(HEATER_2_PIN) && HEATER_2_PIN > -1
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 //BARICUDA
#if defined(POWER_SUPPLY) && POWER_SUPPLY > 0 && defined(PS_ON_PIN) && PS_ON_PIN > -1
case 80: //M80 - Turn on Power Supply
{
SET_OUTPUT(PS_ON_PIN); //GND
WRITE(PS_ON_PIN, PS_ON_AWAKE);
// If you have a switch on suicide pin, this is useful
// if you want to start another print with suicide feature after
// a print without suicide...
#if defined SUICIDE_PIN && SUICIDE_PIN > -1
SET_OUTPUT(SUICIDE_PIN);
WRITE(SUICIDE_PIN, HIGH);
#endif // SUICIDE_PIN
#ifdef ULTIPANEL
powersupply = true;
LCD_MESSAGEPGM(WELCOME_MSG);
lcd_update();
#endif // ULTIPANEL
}
break;
case 81: //M81 - Turn off Power Supply
{
disable_heater();
st_synchronize();
finishAndDisableSteppers();
fanSpeed = 0;
delay(1000); // Wait a little before to switch off
#if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
st_synchronize();
suicide();
#elif defined(POWER_SUPPLY) && POWER_SUPPLY > 0 && defined(PS_ON_PIN) && PS_ON_PIN > -1
SET_OUTPUT(PS_ON_PIN);
WRITE(PS_ON_PIN, PS_ON_ASLEEP);
#endif
#ifdef ULTIPANEL
powersupply = false;
LCD_MESSAGEPGM(MACHINE_NAME" "MSG_OFF".");
lcd_update();
#endif
}
break;
#endif //POWER_SUPPLY
case 82: //M82
{
axis_relative_modes[3] = false;
}
break;
case 83: //M83
{
axis_relative_modes[3] = true;
}
break;
case 84: //M84
{
if(code_seen('S'))
{
stepper_inactive_time = code_value() * 1000;
}
else
{
bool all_axis = !((code_seen(axis_codes[X_AXIS])) || (code_seen(axis_codes[Y_AXIS])) || (code_seen(axis_codes[Z_AXIS]))|| (code_seen(axis_codes[E_AXIS])));
if(all_axis)
{
st_synchronize();
finishAndDisableSteppers();
}
else
{
st_synchronize();
if(code_seen('X')) disable_x();
if(code_seen('Y')) disable_y();
if(code_seen('Z')) disable_z();
#if ((E0_ENABLE_PIN != X_ENABLE_PIN) && (E1_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have separate ENABLE_PINS
if(code_seen('E'))
{
disable_e0();
disable_e1();
disable_e2();
disable_e3();
}
#endif
}
}
}
break;
case 85: //M85
{
if(code_seen('S'))
{
max_inactive_time = code_value() * 1000;
}
}
break;
case 92: //M92
{
for(int8_t i=0; i < NUM_AXIS; i++)
{
int e = 0;
if(code_seen(axis_codes[i]))
{
if (i == 3)
{
e = (int)code_value();
if(code_seen('S'))
{
if (e < EXTRUDERS) axis_steps_per_unit[e+3] = code_value();
}
}
else {
axis_steps_per_unit[i] = code_value();
}
}
}
}
break;
case 115: //M115
{
SERIAL_PROTOCOLPGM(MSG_M115_REPORT);
}
break;
case 117: //M117 display message
{
starpos = (strchr(strchr_pointer + 5,'*'));
if(starpos!=NULL)
*(starpos)='\0';
lcd_setstatus(strchr_pointer + 5);
}
break;
case 114: //M114
{ {
SERIAL_PROTOCOLPGM("X:"); SERIAL_PROTOCOLPGM("X:");
SERIAL_PROTOCOL(current_position[X_AXIS]); SERIAL_PROTOCOL(current_position[X_AXIS]);
...@@ -4374,17 +4471,20 @@ void process_commands() ...@@ -4374,17 +4471,20 @@ void process_commands()
#endif #endif
} }
break; break;
case 120: //M120 case 115: //M115 - Capabilities string
{ {
enable_endstops(false) ; SERIAL_PROTOCOLPGM(MSG_M115_REPORT);
} }
break; break;
case 121: //M121 case 117: //M117 - display message
{ {
enable_endstops(true) ; starpos = (strchr(strchr_pointer + 5,'*'));
if(starpos!=NULL)
*(starpos)='\0';
lcd_setstatus(strchr_pointer + 5);
} }
break; break;
case 119: //M119 case 119: //M119 - Output Endstop status to serial port
{ {
SERIAL_PROTOCOLLN(MSG_M119_REPORT); SERIAL_PROTOCOLLN(MSG_M119_REPORT);
#if defined(X_MIN_PIN) && X_MIN_PIN > -1 #if defined(X_MIN_PIN) && X_MIN_PIN > -1
...@@ -4417,23 +4517,126 @@ void process_commands() ...@@ -4417,23 +4517,126 @@ void process_commands()
#endif #endif
} }
break; break;
case 120: //M120 - Disable Endstop
{
enable_endstops(false) ;
}
break;
case 121: //M121 - Enable Endstop
{
enable_endstops(true) ;
}
break;
#ifdef BARICUDA
// PWM for HEATER_1_PIN
#if defined(HEATER_1_PIN) && HEATER_1_PIN > -1
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 defined(HEATER_2_PIN) && HEATER_2_PIN > -1
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 //BARICUDA
case 140: //M140 set bed temp
{
if(debugDryrun()) break;
if (code_seen('S')) setTargetBed(code_value());
}
break;
#ifdef BLINKM #ifdef BLINKM
case 150: //M150 case 150: //M150 - Send color to RGB led
{ {
byte red; byte red;
byte grn; byte grn;
byte blu; byte blu;
if(code_seen('R')) red = code_value(); if(code_seen('R')) red = code_value();
if(code_seen('U')) grn = code_value(); if(code_seen('U')) grn = code_value();
if(code_seen('B')) blu = code_value(); if(code_seen('B')) blu = code_value();
SendColors(red,grn,blu);
}
break;
#endif //BLINKM
case 190: //M190 - Wait for bed heater to reach target.
{
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
if(debugDryrun()) break;
LCD_MESSAGEPGM(MSG_BED_HEATING);
if (code_seen('S'))
{
setTargetBed(code_value());
CooldownNoWait = true;
}
else if (code_seen('R'))
{
setTargetBed(code_value());
CooldownNoWait = false;
}
codenum = millis();
cancel_heatup = false;
target_direction = isHeatingBed(); // true if heating, false if cooling
SendColors(red,grn,blu); while ((target_direction)&&(!cancel_heatup) ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)))
{
if ((millis() - codenum) > 1000) //Print Temp Reading every 1 second while heating up.
{
float tt=degHotend(active_extruder);
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOL(tt);
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOL((int)active_extruder);
SERIAL_PROTOCOLPGM(" B:");
SERIAL_PROTOCOL_F(degBed(),1);
SERIAL_PROTOCOLLN("");
codenum = millis();
}
manage_heater();
manage_inactivity();
lcd_update();
}
LCD_MESSAGEPGM(MSG_BED_DONE);
refresh_cmd_timeout();
#endif
} }
break; break;
#endif //BLINKM
case 200: //M200 D<millimetres> set filament diameter and set E axis units to cubic millimetres (use S0 to set back to millimetres). case 200: //M200 D<millimetres> set filament diameter and set E axis units to cubic millimetres (use S0 to set back to millimetres).
{ {
tmp_extruder = active_extruder; tmp_extruder = active_extruder;
...@@ -4483,7 +4686,7 @@ void process_commands() ...@@ -4483,7 +4686,7 @@ void process_commands()
calculate_volumetric_multipliers(); calculate_volumetric_multipliers();
} }
break; break;
case 201: //M201 case 201: //M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
{ {
for(int8_t i=0; i < NUM_AXIS; i++) for(int8_t i=0; i < NUM_AXIS; i++)
{ {
...@@ -5135,6 +5338,7 @@ void process_commands() ...@@ -5135,6 +5338,7 @@ void process_commands()
Config_PrintSettings(); Config_PrintSettings();
} }
break; break;
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
case 540: case 540:
{ {
...@@ -5182,163 +5386,7 @@ void process_commands() ...@@ -5182,163 +5386,7 @@ void process_commands()
#ifdef FILAMENTCHANGEENABLE #ifdef FILAMENTCHANGEENABLE
case 600: //M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] case 600: //M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
{ {
float target[4]; gcode_M600();
target[X_AXIS]=current_position[X_AXIS];
target[Y_AXIS]=current_position[Y_AXIS];
target[Z_AXIS]=current_position[Z_AXIS];
target[E_AXIS]=current_position[E_AXIS];
lastpos[X_AXIS]=current_position[X_AXIS];
lastpos[Y_AXIS]=current_position[Y_AXIS];
lastpos[Z_AXIS]=current_position[Z_AXIS];
lastpos[E_AXIS]=current_position[E_AXIS];
//retract by E
if(code_seen('E'))
{
target[E_AXIS]+= code_value();
}
else
{
#ifdef FILAMENTCHANGE_FIRSTRETRACT
target[E_AXIS]+= FILAMENTCHANGE_FIRSTRETRACT;
#endif
}
#ifdef DELTA
calculate_delta(target);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#else
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#endif
//lift Z
if(code_seen('Z'))
{
target[Z_AXIS]+= code_value();
}
else
{
#ifdef FILAMENTCHANGE_ZADD
target[Z_AXIS]+= FILAMENTCHANGE_ZADD;
#endif
}
#ifdef DELTA
calculate_delta(target);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#else
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#endif
//move xy
if(code_seen('X'))
{
target[X_AXIS]= code_value();
}
else
{
#ifdef FILAMENTCHANGE_XPOS
target[X_AXIS]= FILAMENTCHANGE_XPOS;
#endif
}
if(code_seen('Y'))
{
target[Y_AXIS]= code_value();
}
else
{
#ifdef FILAMENTCHANGE_YPOS
target[Y_AXIS]= FILAMENTCHANGE_YPOS;
#endif
}
#ifdef DELTA
calculate_delta(target);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#else
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#endif
if(code_seen('L'))
{
target[E_AXIS]+= code_value();
}
else
{
#ifdef FILAMENTCHANGE_FINALRETRACT
target[E_AXIS]+= FILAMENTCHANGE_FINALRETRACT ;
#endif
}
#ifdef DELTA
calculate_delta(target);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#else
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
#endif
//finish moves
st_synchronize();
//disable extruder steppers so filament can be removed
disable_e0();
disable_e1();
disable_e2();
disable_e3();
delay(100);
LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
uint8_t cnt=0;
while(!lcd_clicked())
{
cnt++;
manage_heater();
manage_inactivity(true);
lcd_update();
if(cnt==0)
{
#if BEEPER > 0
SET_OUTPUT(BEEPER);
WRITE(BEEPER,HIGH);
delay(3);
WRITE(BEEPER,LOW);
delay(3);
#else
#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
lcd_buzz(1000/6,100);
#else
lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS,LCD_FEEDBACK_FREQUENCY_HZ);
#endif
#endif
}
}
//return to normal
if(code_seen('L'))
{
target[E_AXIS]+= -code_value();
}
else
{
#ifdef FILAMENTCHANGE_FINALRETRACT
target[E_AXIS]+=(-1)*FILAMENTCHANGE_FINALRETRACT ;
#endif
}
#if defined(PAUSE_PIN) && PAUSE_PIN > -1
paused = false;
#endif
current_position[E_AXIS]=target[E_AXIS]; //the long retract of L is compensated by manual filament feeding
plan_set_e_position(current_position[E_AXIS]);
#ifdef DELTA
calculate_delta(target);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver); //should do nothing
calculate_delta(lastpos);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver); //move xyz back
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], lastpos[E_AXIS], feedrate/60, active_extruder, active_driver); //final unretract
#else
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver); //should do nothing
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver); //move xy back
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver); //move z back
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], feedrate/60, active_extruder, active_driver); //final unretract
#endif
} }
break; break;
#endif //FILAMENTCHANGEENABLE #endif //FILAMENTCHANGEENABLE
...@@ -5552,70 +5600,80 @@ void process_commands() ...@@ -5552,70 +5600,80 @@ void process_commands()
#if defined(MKR4) && (EXTRUDERS > 1) #if defined(MKR4) && (EXTRUDERS > 1)
#if (EXTRUDERS == 4) && (E0E2_CHOICE_PIN >1) && (E1E3_CHOICE_PIN > 1) #if (EXTRUDERS == 4) && (E0E2_CHOICE_PIN >1) && (E1E3_CHOICE_PIN > 1)
st_synchronize(); // Finish all movement st_synchronize(); // Finish all movement
disable_e0(); disable_e();
disable_e1();
switch(tmp_extruder) switch(tmp_extruder)
{ {
case 0: case 0:
WRITE(E0E2_CHOICE_PIN,LOW); WRITE(E0E2_CHOICE_PIN,LOW);
WRITE(E1E3_CHOICE_PIN,LOW); WRITE(E1E3_CHOICE_PIN,LOW);
active_driver=0; active_driver=0;
delay(500); // 500 microseconds delay for relay
enable_e0();
break; break;
case 1: case 1:
WRITE(E0E2_CHOICE_PIN,LOW); WRITE(E0E2_CHOICE_PIN,LOW);
WRITE(E1E3_CHOICE_PIN,LOW); WRITE(E1E3_CHOICE_PIN,LOW);
active_driver=1; active_driver=1;
delay(500); // 500 microseconds delay for relay
enable_e1();
break; break;
case 2: case 2:
WRITE(E0E2_CHOICE_PIN,HIGH); WRITE(E0E2_CHOICE_PIN,HIGH);
WRITE(E1E3_CHOICE_PIN,LOW); WRITE(E1E3_CHOICE_PIN,LOW);
active_driver=0; active_driver=0;
delay(500); // 500 microseconds delay for relay
enable_e2();
break; break;
case 3: case 3:
WRITE(E0E2_CHOICE_PIN,LOW); WRITE(E0E2_CHOICE_PIN,LOW);
WRITE(E1E3_CHOICE_PIN,HIGH); WRITE(E1E3_CHOICE_PIN,HIGH);
active_driver=1; active_driver=1;
delay(500); // 500 microseconds delay for relay
enable_e3();
break; break;
} }
delay(DELAY_R); // ritardo per commutazione rele
enable_e0();
enable_e1();
#elif (EXTRUDERS == 3) && (E0E2_CHOICE_PIN >1) #elif (EXTRUDERS == 3) && (E0E2_CHOICE_PIN >1)
st_synchronize(); // Finish all movement st_synchronize(); // Finish all movement
disable_e0(); disable_e();
switch(tmp_extruder) switch(tmp_extruder)
{ {
case 0: case 0:
WRITE(E0E2_CHOICE_PIN,LOW); WRITE(E0E2_CHOICE_PIN,LOW);
active_driver=0; active_driver=0;
delay(500); // 500 microseconds delay for relay
enable_e0();
break; break;
case 1: case 1:
WRITE(E0E2_CHOICE_PIN,LOW); WRITE(E0E2_CHOICE_PIN,LOW);
active_driver=1; active_driver=1;
delay(500); // 500 microseconds delay for relay
enable_e1();
break; break;
case 2: case 2:
WRITE(E0E2_CHOICE_PIN,HIGH); WRITE(E0E2_CHOICE_PIN,HIGH);
active_driver=0; active_driver=0;
delay(500); // 500 microseconds delay for relay
enable_e2();
break; break;
} }
delay(DELAY_R); // ritardo per commutazione rele
enable_e0();
#elif (EXTRUDERS == 2) && (E0E1_CHOICE_PIN >1) #elif (EXTRUDERS == 2) && (E0E1_CHOICE_PIN >1)
st_synchronize(); // Finish all movement st_synchronize(); // Finish all movement
disable_e0(); disable_e();
switch(tmp_extruder) switch(tmp_extruder)
{ {
case 0: case 0:
WRITE(E0E1_CHOICE_PIN,LOW); WRITE(E0E1_CHOICE_PIN,LOW);
active_driver=0; active_driver=0;
delay(500); // 500 microseconds delay for relay
enable_e0();
break; break;
case 1: case 1:
WRITE(E0E1_CHOICE_PIN,HIGH); WRITE(E0E1_CHOICE_PIN,HIGH);
active_driver=0; active_driver=0;
delay(500); // 500 microseconds delay for relay
enable_e1();
break; break;
} }
delay(DELAY_R); // ritardo per commutazione rele
enable_e0();
#endif // E0E1_CHOICE_PIN E0E2_CHOICE_PIN E1E3_CHOICE_PIN #endif // E0E1_CHOICE_PIN E0E2_CHOICE_PIN E1E3_CHOICE_PIN
active_extruder = tmp_extruder; active_extruder = tmp_extruder;
SERIAL_ECHO_START; SERIAL_ECHO_START;
...@@ -5765,81 +5823,6 @@ void clamp_to_software_endstops(float target[3]) ...@@ -5765,81 +5823,6 @@ void clamp_to_software_endstops(float target[3])
} }
} }
#ifdef DELTA
void calculate_delta(float cartesian[3])
{
delta[X_AXIS] = sqrt(DELTA_DIAGONAL_ROD_2
- sq(delta_tower1_x-cartesian[X_AXIS])
- sq(delta_tower1_y-cartesian[Y_AXIS])
) + cartesian[Z_AXIS];
delta[Y_AXIS] = sqrt(DELTA_DIAGONAL_ROD_2
- sq(delta_tower2_x-cartesian[X_AXIS])
- sq(delta_tower2_y-cartesian[Y_AXIS])
) + cartesian[Z_AXIS];
delta[Z_AXIS] = sqrt(DELTA_DIAGONAL_ROD_2
- sq(delta_tower3_x-cartesian[X_AXIS])
- sq(delta_tower3_y-cartesian[Y_AXIS])
) + cartesian[Z_AXIS];
/*
SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]);
SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]);
SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]);
SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]);
SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]);
SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]);
*/
/*
if ((delta_tmp[X_AXIS] > 0) and (delta_tmp[Y_AXIS] > 0) and (delta_tmp[Z_AXIS] > 0))
{
delta[X_AXIS] = delta_tmp[X_AXIS];
delta[Y_AXIS] = delta_tmp[Y_AXIS];
delta[Z_AXIS] = delta_tmp[Z_AXIS];
} else SERIAL_ECHOLN("ERROR: Invalid delta coordinates!");
*/
}
// Adjust print surface height by linear interpolation over the bed_level array.
void adjust_delta(float cartesian[3])
{
float grid_x = max(-2.999, min(2.999, cartesian[X_AXIS] / AUTOLEVEL_GRID));
float grid_y = max(-2.999, min(2.999, cartesian[Y_AXIS] / AUTOLEVEL_GRID));
int floor_x = floor(grid_x);
int floor_y = floor(grid_y);
float ratio_x = grid_x - floor_x;
float ratio_y = grid_y - floor_y;
float z1 = bed_level[floor_x+3][floor_y+3];
float z2 = bed_level[floor_x+3][floor_y+4];
float z3 = bed_level[floor_x+4][floor_y+3];
float z4 = bed_level[floor_x+4][floor_y+4];
float left = (1-ratio_y)*z1 + ratio_y*z2;
float right = (1-ratio_y)*z3 + ratio_y*z4;
float offset = (1-ratio_x)*left + ratio_x*right;
delta[X_AXIS] += offset;
delta[Y_AXIS] += offset;
delta[Z_AXIS] += offset;
/*
SERIAL_ECHOPGM("grid_x="); SERIAL_ECHO(grid_x);
SERIAL_ECHOPGM(" grid_y="); SERIAL_ECHO(grid_y);
SERIAL_ECHOPGM(" floor_x="); SERIAL_ECHO(floor_x);
SERIAL_ECHOPGM(" floor_y="); SERIAL_ECHO(floor_y);
SERIAL_ECHOPGM(" ratio_x="); SERIAL_ECHO(ratio_x);
SERIAL_ECHOPGM(" ratio_y="); SERIAL_ECHO(ratio_y);
SERIAL_ECHOPGM(" z1="); SERIAL_ECHO(z1);
SERIAL_ECHOPGM(" z2="); SERIAL_ECHO(z2);
SERIAL_ECHOPGM(" z3="); SERIAL_ECHO(z3);
SERIAL_ECHOPGM(" z4="); SERIAL_ECHO(z4);
SERIAL_ECHOPGM(" left="); SERIAL_ECHO(left);
SERIAL_ECHOPGM(" right="); SERIAL_ECHO(right);
SERIAL_ECHOPGM(" offset="); SERIAL_ECHOLN(offset);
*/
}
#endif // DELTA
void prepare_move() void prepare_move()
{ {
clamp_to_software_endstops(destination); clamp_to_software_endstops(destination);
...@@ -6184,10 +6167,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s ...@@ -6184,10 +6167,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
disable_x(); disable_x();
disable_y(); disable_y();
disable_z(); disable_z();
disable_e0(); disable_e();
disable_e1();
disable_e2();
disable_e3();
} }
} }
} }
...@@ -6289,10 +6269,7 @@ void kill() ...@@ -6289,10 +6269,7 @@ void kill()
disable_x(); disable_x();
disable_y(); disable_y();
disable_z(); disable_z();
disable_e0(); disable_e();
disable_e1();
disable_e2();
disable_e3();
#if defined(PS_ON_PIN) && PS_ON_PIN > -1 #if defined(PS_ON_PIN) && PS_ON_PIN > -1
pinMode(PS_ON_PIN,INPUT); pinMode(PS_ON_PIN,INPUT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment