Merge remote-tracking branch 'origin/Marlin_v1' into add/M665-set-delta-configuration
Conflicts: Marlin/Marlin_main.cpp
This commit is contained in:
@ -31,7 +31,7 @@
|
||||
|
||||
#ifdef ENABLE_AUTO_BED_LEVELING
|
||||
#include "vector_3.h"
|
||||
#ifdef ACCURATE_BED_LEVELING
|
||||
#ifdef AUTO_BED_LEVELING_GRID
|
||||
#include "qr_solve.h"
|
||||
#endif
|
||||
#endif // ENABLE_AUTO_BED_LEVELING
|
||||
@ -63,7 +63,7 @@
|
||||
|
||||
#define VERSION_STRING "1.0.0"
|
||||
|
||||
// look here for descriptions of gcodes: 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
|
||||
|
||||
//Implemented Codes
|
||||
@ -76,11 +76,11 @@
|
||||
// G10 - retract filament according to settings of M207
|
||||
// G11 - retract recover filament according to settings of M208
|
||||
// G28 - Home all Axis
|
||||
// G29 - Detailed Z-Probe, probes the bed at 3 points. You must de at the home position for this to work correctly.
|
||||
// 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.
|
||||
// G90 - Use Absolute Coordinates
|
||||
// G91 - Use Relative Coordinates
|
||||
// G92 - Set current position to cordinates given
|
||||
// G92 - Set current position to coordinates given
|
||||
|
||||
// M Codes
|
||||
// M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled)
|
||||
@ -101,7 +101,7 @@
|
||||
// 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):
|
||||
// syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#"
|
||||
// Call gcode file : "M32 P !filename#" and return to caller file after finishing (simiarl 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
|
||||
// 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.
|
||||
// M80 - Turn on Power Supply
|
||||
@ -127,18 +127,18 @@
|
||||
// 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
|
||||
// M150 - Set BlinkM Colour 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
|
||||
// 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).
|
||||
// M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
|
||||
// M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
|
||||
// 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) im mm/sec^2 also sets minimum segment time in ms (B20000) to prevent buffer underruns 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
|
||||
// M206 - set additional homeing 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
|
||||
// M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/min]
|
||||
// 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.
|
||||
// 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
|
||||
@ -147,7 +147,7 @@
|
||||
// M240 - Trigger a camera to take a photograph
|
||||
// M250 - Set LCD contrast C<contrast value> (value 0..63)
|
||||
// M280 - set servo position absolute. P: servo index, S: angle or microseconds
|
||||
// M300 - Play beepsound S<frequency Hz> P<duration ms>
|
||||
// M300 - Play beep sound S<frequency Hz> P<duration ms>
|
||||
// M301 - Set PID parameters P I and D
|
||||
// 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)
|
||||
@ -155,14 +155,14 @@
|
||||
// M400 - Finish all moves
|
||||
// M401 - Lower z-probe if present
|
||||
// M402 - Raise z-probe if present
|
||||
// M500 - stores paramters in EEPROM
|
||||
// M500 - stores parameters in EEPROM
|
||||
// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
|
||||
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
||||
// M503 - print the current settings (from memory not from eeprom)
|
||||
// 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)
|
||||
// M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
|
||||
// M665 - set delta configurations
|
||||
// M666 - set delta endstop adjustemnt
|
||||
// M666 - set delta endstop adjustment
|
||||
// M605 - Set dual x-carriage movement mode: S<mode> [ X<duplication x-offset> R<duplication temp offset> ]
|
||||
// M907 - Set digital trimpot motor current using axis codes.
|
||||
// M908 - Control digital trimpot directly.
|
||||
@ -232,10 +232,13 @@ int EtoPPressure=0;
|
||||
#endif
|
||||
|
||||
#ifdef FWRETRACT
|
||||
bool autoretract_enabled=true;
|
||||
bool autoretract_enabled=false;
|
||||
bool retracted=false;
|
||||
float retract_length=3, retract_feedrate=17*60, retract_zlift=0.8;
|
||||
float retract_recover_length=0, retract_recover_feedrate=8*60;
|
||||
float retract_length = RETRACT_LENGTH;
|
||||
float retract_feedrate = RETRACT_FEEDRATE;
|
||||
float retract_zlift = RETRACT_ZLIFT;
|
||||
float retract_recover_length = RETRACT_RECOVER_LENGTH;
|
||||
float retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
|
||||
#endif
|
||||
|
||||
#ifdef ULTIPANEL
|
||||
@ -264,7 +267,7 @@ int EtoPPressure=0;
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
//=============================private variables=============================
|
||||
//=============================Private Variables=============================
|
||||
//===========================================================================
|
||||
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
||||
static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
||||
@ -284,7 +287,7 @@ static int buflen = 0;
|
||||
static char serial_char;
|
||||
static int serial_count = 0;
|
||||
static boolean comment_mode = false;
|
||||
static char *strchr_pointer; // just a pointer to find chars in the cmd string like X, Y, Z, E, etc
|
||||
static char *strchr_pointer; // just a pointer to find chars in the command string like X, Y, Z, E, etc
|
||||
|
||||
const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
|
||||
|
||||
@ -312,7 +315,7 @@ bool CooldownNoWait = true;
|
||||
bool target_direction;
|
||||
|
||||
//===========================================================================
|
||||
//=============================ROUTINES=============================
|
||||
//=============================Routines======================================
|
||||
//===========================================================================
|
||||
|
||||
void get_arc_coordinates();
|
||||
@ -349,7 +352,7 @@ void enquecommand(const char *cmd)
|
||||
{
|
||||
if(buflen < BUFSIZE)
|
||||
{
|
||||
//this is dangerous if a mixing of serial and this happsens
|
||||
//this is dangerous if a mixing of serial and this happens
|
||||
strcpy(&(cmdbuffer[bufindw][0]),cmd);
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPGM("enqueing \"");
|
||||
@ -364,7 +367,7 @@ void enquecommand_P(const char *cmd)
|
||||
{
|
||||
if(buflen < BUFSIZE)
|
||||
{
|
||||
//this is dangerous if a mixing of serial and this happsens
|
||||
//this is dangerous if a mixing of serial and this happens
|
||||
strcpy_P(&(cmdbuffer[bufindw][0]),cmd);
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPGM("enqueing \"");
|
||||
@ -671,9 +674,9 @@ void get_command()
|
||||
return;
|
||||
}
|
||||
|
||||
//'#' stops reading from sd to the buffer prematurely, so procedural macro calls are possible
|
||||
// if it occures, stop_buffering is triggered and the buffer is ran dry.
|
||||
// this character _can_ occure in serial com, due to checksums. however, no checksums are used in sd printing
|
||||
//'#' stops reading from SD to the buffer prematurely, so procedural macro calls are possible
|
||||
// if it occurs, stop_buffering is triggered and the buffer is ran dry.
|
||||
// this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing
|
||||
|
||||
static bool stop_buffering=false;
|
||||
if(buflen==0) stop_buffering=false;
|
||||
@ -832,7 +835,7 @@ static void axis_is_at_home(int axis) {
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AUTO_BED_LEVELING
|
||||
#ifdef ACCURATE_BED_LEVELING
|
||||
#ifdef AUTO_BED_LEVELING_GRID
|
||||
static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
|
||||
{
|
||||
vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
|
||||
@ -856,42 +859,36 @@ static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
}
|
||||
|
||||
#else
|
||||
static void set_bed_level_equation(float z_at_xLeft_yFront, float z_at_xRight_yFront, float z_at_xLeft_yBack) {
|
||||
#else // not AUTO_BED_LEVELING_GRID
|
||||
|
||||
static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float z_at_pt_3) {
|
||||
|
||||
plan_bed_level_matrix.set_to_identity();
|
||||
|
||||
vector_3 xLeftyFront = vector_3(LEFT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, z_at_xLeft_yFront);
|
||||
vector_3 xLeftyBack = vector_3(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, z_at_xLeft_yBack);
|
||||
vector_3 xRightyFront = vector_3(RIGHT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, z_at_xRight_yFront);
|
||||
vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1);
|
||||
vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
|
||||
vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
|
||||
|
||||
vector_3 xPositive = (xRightyFront - xLeftyFront).get_normal();
|
||||
vector_3 yPositive = (xLeftyBack - xLeftyFront).get_normal();
|
||||
vector_3 planeNormal = vector_3::cross(xPositive, yPositive).get_normal();
|
||||
vector_3 from_2_to_1 = (pt1 - pt2).get_normal();
|
||||
vector_3 from_2_to_3 = (pt3 - pt2).get_normal();
|
||||
vector_3 planeNormal = vector_3::cross(from_2_to_1, from_2_to_3).get_normal();
|
||||
planeNormal = vector_3(planeNormal.x, planeNormal.y, abs(planeNormal.z));
|
||||
|
||||
//planeNormal.debug("planeNormal");
|
||||
//yPositive.debug("yPositive");
|
||||
plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
||||
//bedLevel.debug("bedLevel");
|
||||
|
||||
//plan_bed_level_matrix.debug("bed level before");
|
||||
//vector_3 uncorrected_position = plan_get_position_mm();
|
||||
//uncorrected_position.debug("position before");
|
||||
|
||||
// and set our bed level equation to do the right thing
|
||||
//plan_bed_level_matrix.debug("bed level after");
|
||||
|
||||
vector_3 corrected_position = plan_get_position();
|
||||
//corrected_position.debug("position after");
|
||||
current_position[X_AXIS] = corrected_position.x;
|
||||
current_position[Y_AXIS] = corrected_position.y;
|
||||
current_position[Z_AXIS] = corrected_position.z;
|
||||
|
||||
// but the bed at 0 so we don't go below it.
|
||||
// put the bed at 0 so we don't go below it.
|
||||
current_position[Z_AXIS] = zprobe_zoffset;
|
||||
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
|
||||
}
|
||||
#endif // ACCURATE_BED_LEVELING
|
||||
|
||||
#endif // AUTO_BED_LEVELING_GRID
|
||||
|
||||
static void run_z_probe() {
|
||||
plan_bed_level_matrix.set_to_identity();
|
||||
@ -1098,6 +1095,42 @@ void refresh_cmd_timeout(void)
|
||||
previous_millis_cmd = millis();
|
||||
}
|
||||
|
||||
#ifdef FWRETRACT
|
||||
void retract(bool retracting) {
|
||||
if(retracting && !retracted) {
|
||||
destination[X_AXIS]=current_position[X_AXIS];
|
||||
destination[Y_AXIS]=current_position[Y_AXIS];
|
||||
destination[Z_AXIS]=current_position[Z_AXIS];
|
||||
destination[E_AXIS]=current_position[E_AXIS];
|
||||
current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
|
||||
plan_set_e_position(current_position[E_AXIS]);
|
||||
float oldFeedrate = feedrate;
|
||||
feedrate=retract_feedrate;
|
||||
retracted=true;
|
||||
prepare_move();
|
||||
current_position[Z_AXIS]-=retract_zlift;
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
prepare_move();
|
||||
feedrate = oldFeedrate;
|
||||
} else if(!retracting && retracted) {
|
||||
destination[X_AXIS]=current_position[X_AXIS];
|
||||
destination[Y_AXIS]=current_position[Y_AXIS];
|
||||
destination[Z_AXIS]=current_position[Z_AXIS];
|
||||
destination[E_AXIS]=current_position[E_AXIS];
|
||||
current_position[Z_AXIS]+=retract_zlift;
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
//prepare_move();
|
||||
current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder];
|
||||
plan_set_e_position(current_position[E_AXIS]);
|
||||
float oldFeedrate = feedrate;
|
||||
feedrate=retract_recover_feedrate;
|
||||
retracted=false;
|
||||
prepare_move();
|
||||
feedrate = oldFeedrate;
|
||||
}
|
||||
} //retract
|
||||
#endif //FWRETRACT
|
||||
|
||||
void process_commands()
|
||||
{
|
||||
unsigned long codenum; //throw away variable
|
||||
@ -1113,6 +1146,18 @@ void process_commands()
|
||||
case 1: // G1
|
||||
if(Stopped == false) {
|
||||
get_coordinates(); // For X Y Z E F
|
||||
#ifdef FWRETRACT
|
||||
if(autoretract_enabled)
|
||||
if( !(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) {
|
||||
float echange=destination[E_AXIS]-current_position[E_AXIS];
|
||||
if((echange<-MIN_RETRACT && !retracted) || (echange>MIN_RETRACT && retracted)) { //move appears to be an attempt to retract or recover
|
||||
current_position[E_AXIS] = destination[E_AXIS]; //hide the slicer-generated retract/recover from calculations
|
||||
plan_set_e_position(current_position[E_AXIS]); //AND from the planner
|
||||
retract(!retracted);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif //FWRETRACT
|
||||
prepare_move();
|
||||
//ClearToSend();
|
||||
return;
|
||||
@ -1147,39 +1192,10 @@ void process_commands()
|
||||
break;
|
||||
#ifdef FWRETRACT
|
||||
case 10: // G10 retract
|
||||
if(!retracted)
|
||||
{
|
||||
destination[X_AXIS]=current_position[X_AXIS];
|
||||
destination[Y_AXIS]=current_position[Y_AXIS];
|
||||
destination[Z_AXIS]=current_position[Z_AXIS];
|
||||
current_position[Z_AXIS]-=retract_zlift;
|
||||
destination[E_AXIS]=current_position[E_AXIS];
|
||||
current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
|
||||
plan_set_e_position(current_position[E_AXIS]);
|
||||
float oldFeedrate = feedrate;
|
||||
feedrate=retract_feedrate;
|
||||
retracted=true;
|
||||
prepare_move();
|
||||
feedrate = oldFeedrate;
|
||||
}
|
||||
|
||||
retract(true);
|
||||
break;
|
||||
case 11: // G11 retract_recover
|
||||
if(retracted)
|
||||
{
|
||||
destination[X_AXIS]=current_position[X_AXIS];
|
||||
destination[Y_AXIS]=current_position[Y_AXIS];
|
||||
destination[Z_AXIS]=current_position[Z_AXIS];
|
||||
current_position[Z_AXIS]+=retract_zlift;
|
||||
destination[E_AXIS]=current_position[E_AXIS];
|
||||
current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder];
|
||||
plan_set_e_position(current_position[E_AXIS]);
|
||||
float oldFeedrate = feedrate;
|
||||
feedrate=retract_recover_feedrate;
|
||||
retracted=false;
|
||||
prepare_move();
|
||||
feedrate = oldFeedrate;
|
||||
}
|
||||
retract(false);
|
||||
break;
|
||||
#endif //FWRETRACT
|
||||
case 28: //G28 Home all Axis one at a time
|
||||
@ -1232,7 +1248,7 @@ void process_commands()
|
||||
|
||||
#else // NOT DELTA
|
||||
|
||||
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[X_AXIS])) || (code_seen(axis_codes[Y_AXIS])) || (code_seen(axis_codes[Z_AXIS])));
|
||||
|
||||
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
|
||||
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
||||
@ -1394,12 +1410,21 @@ void process_commands()
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_AUTO_BED_LEVELING
|
||||
case 29: // G29 Detailed Z-Probe, probes the bed at 3 points.
|
||||
case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points.
|
||||
{
|
||||
#if Z_MIN_PIN == -1
|
||||
#error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling feature!!! Z_MIN_PIN must point to a valid hardware pin."
|
||||
#endif
|
||||
|
||||
// Prevent user from running a G29 without first homing in X and Y
|
||||
if (! (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) )
|
||||
{
|
||||
LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
|
||||
break; // abort G29, since we don't know where we are
|
||||
}
|
||||
|
||||
st_synchronize();
|
||||
// make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
|
||||
//vector_3 corrected_position = plan_get_position_mm();
|
||||
@ -1414,10 +1439,11 @@ void process_commands()
|
||||
setup_for_endstop_move();
|
||||
|
||||
feedrate = homing_feedrate[Z_AXIS];
|
||||
#ifdef ACCURATE_BED_LEVELING
|
||||
#ifdef AUTO_BED_LEVELING_GRID
|
||||
// probe at the points of a lattice grid
|
||||
|
||||
int xGridSpacing = (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION) / (ACCURATE_BED_LEVELING_POINTS-1);
|
||||
int yGridSpacing = (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION) / (ACCURATE_BED_LEVELING_POINTS-1);
|
||||
int xGridSpacing = (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION) / (AUTO_BED_LEVELING_GRID_POINTS-1);
|
||||
int yGridSpacing = (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION) / (AUTO_BED_LEVELING_GRID_POINTS-1);
|
||||
|
||||
|
||||
// solve the plane equation ax + by + d = z
|
||||
@ -1427,9 +1453,9 @@ void process_commands()
|
||||
// so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
||||
|
||||
// "A" matrix of the linear system of equations
|
||||
double eqnAMatrix[ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS*3];
|
||||
double eqnAMatrix[AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS*3];
|
||||
// "B" vector of Z points
|
||||
double eqnBVector[ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS];
|
||||
double eqnBVector[AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS];
|
||||
|
||||
|
||||
int probePointCounter = 0;
|
||||
@ -1452,7 +1478,7 @@ void process_commands()
|
||||
zig = true;
|
||||
}
|
||||
|
||||
for (int xCount=0; xCount < ACCURATE_BED_LEVELING_POINTS; xCount++)
|
||||
for (int xCount=0; xCount < AUTO_BED_LEVELING_GRID_POINTS; xCount++)
|
||||
{
|
||||
float z_before;
|
||||
if (probePointCounter == 0)
|
||||
@ -1469,9 +1495,9 @@ void process_commands()
|
||||
|
||||
eqnBVector[probePointCounter] = measured_z;
|
||||
|
||||
eqnAMatrix[probePointCounter + 0*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = xProbe;
|
||||
eqnAMatrix[probePointCounter + 1*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = yProbe;
|
||||
eqnAMatrix[probePointCounter + 2*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = 1;
|
||||
eqnAMatrix[probePointCounter + 0*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = xProbe;
|
||||
eqnAMatrix[probePointCounter + 1*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = yProbe;
|
||||
eqnAMatrix[probePointCounter + 2*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = 1;
|
||||
probePointCounter++;
|
||||
xProbe += xInc;
|
||||
}
|
||||
@ -1479,7 +1505,7 @@ void process_commands()
|
||||
clean_up_after_endstop_move();
|
||||
|
||||
// solve lsq problem
|
||||
double *plane_equation_coefficients = qr_solve(ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS, 3, eqnAMatrix, eqnBVector);
|
||||
double *plane_equation_coefficients = qr_solve(AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS, 3, eqnAMatrix, eqnBVector);
|
||||
|
||||
SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
|
||||
SERIAL_PROTOCOL(plane_equation_coefficients[0]);
|
||||
@ -1493,24 +1519,24 @@ void process_commands()
|
||||
|
||||
free(plane_equation_coefficients);
|
||||
|
||||
#else // ACCURATE_BED_LEVELING not defined
|
||||
#else // AUTO_BED_LEVELING_GRID not defined
|
||||
|
||||
// Probe at 3 arbitrary points
|
||||
// probe 1
|
||||
float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING);
|
||||
|
||||
// prob 1
|
||||
float z_at_xLeft_yBack = probe_pt(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, Z_RAISE_BEFORE_PROBING);
|
||||
// probe 2
|
||||
float z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
||||
|
||||
// prob 2
|
||||
float z_at_xLeft_yFront = probe_pt(LEFT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
||||
|
||||
// prob 3
|
||||
float z_at_xRight_yFront = probe_pt(RIGHT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
||||
// probe 3
|
||||
float z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
||||
|
||||
clean_up_after_endstop_move();
|
||||
|
||||
set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
|
||||
set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
||||
|
||||
|
||||
#endif // ACCURATE_BED_LEVELING
|
||||
#endif // AUTO_BED_LEVELING_GRID
|
||||
st_synchronize();
|
||||
|
||||
// The following code correct the Z height difference from z-probe position and hotend tip position.
|
||||
@ -2079,7 +2105,7 @@ void process_commands()
|
||||
}
|
||||
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[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();
|
||||
@ -3048,42 +3074,6 @@ void get_coordinates()
|
||||
next_feedrate = code_value();
|
||||
if(next_feedrate > 0.0) feedrate = next_feedrate;
|
||||
}
|
||||
#ifdef FWRETRACT
|
||||
if(autoretract_enabled)
|
||||
if( !(seen[X_AXIS] || seen[Y_AXIS] || seen[Z_AXIS]) && seen[E_AXIS])
|
||||
{
|
||||
float echange=destination[E_AXIS]-current_position[E_AXIS];
|
||||
if(echange<-MIN_RETRACT) //retract
|
||||
{
|
||||
if(!retracted)
|
||||
{
|
||||
|
||||
destination[Z_AXIS]+=retract_zlift; //not sure why chaninging current_position negatively does not work.
|
||||
//if slicer retracted by echange=-1mm and you want to retract 3mm, corrrectede=-2mm additionally
|
||||
float correctede=-echange-retract_length;
|
||||
//to generate the additional steps, not the destination is changed, but inversely the current position
|
||||
current_position[E_AXIS]+=-correctede;
|
||||
feedrate=retract_feedrate;
|
||||
retracted=true;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
if(echange>MIN_RETRACT) //retract_recover
|
||||
{
|
||||
if(retracted)
|
||||
{
|
||||
//current_position[Z_AXIS]+=-retract_zlift;
|
||||
//if slicer retracted_recovered by echange=+1mm and you want to retract_recover 3mm, corrrectede=2mm additionally
|
||||
float correctede=-echange+1*retract_length+retract_recover_length; //total unretract=retract_length+retract_recover_length[surplus]
|
||||
current_position[E_AXIS]+=correctede; //to generate the additional steps, not the destination is changed, but inversely the current position
|
||||
feedrate=retract_recover_feedrate;
|
||||
retracted=false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif //FWRETRACT
|
||||
}
|
||||
|
||||
void get_arc_coordinates()
|
||||
|
Reference in New Issue
Block a user