|
@@ -31,7 +31,7 @@
|
31
|
31
|
|
32
|
32
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
33
|
33
|
#include "vector_3.h"
|
34
|
|
- #ifdef ACCURATE_BED_LEVELING
|
|
34
|
+ #ifdef AUTO_BED_LEVELING_GRID
|
35
|
35
|
#include "qr_solve.h"
|
36
|
36
|
#endif
|
37
|
37
|
#endif // ENABLE_AUTO_BED_LEVELING
|
|
@@ -63,7 +63,7 @@
|
63
|
63
|
|
64
|
64
|
#define VERSION_STRING "1.0.0"
|
65
|
65
|
|
66
|
|
-// look here for descriptions of gcodes: http://linuxcnc.org/handbook/gcode/g-code.html
|
|
66
|
+// look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html
|
67
|
67
|
// http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
|
68
|
68
|
|
69
|
69
|
//Implemented Codes
|
|
@@ -76,11 +76,11 @@
|
76
|
76
|
// G10 - retract filament according to settings of M207
|
77
|
77
|
// G11 - retract recover filament according to settings of M208
|
78
|
78
|
// G28 - Home all Axis
|
79
|
|
-// G29 - Detailed Z-Probe, probes the bed at 3 points. You must de at the home position for this to work correctly.
|
|
79
|
+// G29 - Detailed Z-Probe, probes the bed at 3 or more points. Will fail if you haven't homed yet.
|
80
|
80
|
// G30 - Single Z Probe, probes bed at current XY location.
|
81
|
81
|
// G90 - Use Absolute Coordinates
|
82
|
82
|
// G91 - Use Relative Coordinates
|
83
|
|
-// G92 - Set current position to cordinates given
|
|
83
|
+// G92 - Set current position to coordinates given
|
84
|
84
|
|
85
|
85
|
// M Codes
|
86
|
86
|
// M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled)
|
|
@@ -101,7 +101,7 @@
|
101
|
101
|
// M31 - Output time since last M109 or SD card start to serial
|
102
|
102
|
// M32 - Select file and start SD print (Can be used _while_ printing from SD card files):
|
103
|
103
|
// syntax "M32 /path/filename#", or "M32 S<startpos bytes> !filename#"
|
104
|
|
-// Call gcode file : "M32 P !filename#" and return to caller file after finishing (simiarl to #include).
|
|
104
|
+// Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include).
|
105
|
105
|
// The '#' is necessary when calling from within sd files, as it stops buffer prereading
|
106
|
106
|
// 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.
|
107
|
107
|
// M80 - Turn on Power Supply
|
|
@@ -127,18 +127,18 @@
|
127
|
127
|
// M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
|
128
|
128
|
// M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil)
|
129
|
129
|
// M140 - Set bed target temp
|
130
|
|
-// 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.
|
|
130
|
+// 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.
|
131
|
131
|
// M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
|
132
|
132
|
// Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
|
133
|
133
|
// M200 D<millimeters>- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).
|
134
|
134
|
// M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
|
135
|
135
|
// M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
|
136
|
136
|
// M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
|
137
|
|
-// 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
|
|
137
|
+// 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
|
138
|
138
|
// 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
|
139
|
|
-// M206 - set additional homeing offset
|
|
139
|
+// M206 - set additional homing offset
|
140
|
140
|
// M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting
|
141
|
|
-// M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/min]
|
|
141
|
+// M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec]
|
142
|
142
|
// 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.
|
143
|
143
|
// M218 - set hotend offset (in mm): T<extruder_number> X<offset_on_X> Y<offset_on_Y>
|
144
|
144
|
// M220 S<factor in percent>- set speed factor override percentage
|
|
@@ -147,7 +147,7 @@
|
147
|
147
|
// M240 - Trigger a camera to take a photograph
|
148
|
148
|
// M250 - Set LCD contrast C<contrast value> (value 0..63)
|
149
|
149
|
// M280 - set servo position absolute. P: servo index, S: angle or microseconds
|
150
|
|
-// M300 - Play beepsound S<frequency Hz> P<duration ms>
|
|
150
|
+// M300 - Play beep sound S<frequency Hz> P<duration ms>
|
151
|
151
|
// M301 - Set PID parameters P I and D
|
152
|
152
|
// M302 - Allow cold extrudes, or set the minimum extrude S<temperature>.
|
153
|
153
|
// M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
|
|
@@ -155,14 +155,14 @@
|
155
|
155
|
// M400 - Finish all moves
|
156
|
156
|
// M401 - Lower z-probe if present
|
157
|
157
|
// M402 - Raise z-probe if present
|
158
|
|
-// M500 - stores paramters in EEPROM
|
|
158
|
+// M500 - stores parameters in EEPROM
|
159
|
159
|
// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
|
160
|
160
|
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
161
|
|
-// M503 - print the current settings (from memory not from eeprom)
|
|
161
|
+// M503 - print the current settings (from memory not from EEPROM)
|
162
|
162
|
// M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
163
|
163
|
// M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
|
164
|
164
|
// M665 - set delta configurations
|
165
|
|
-// M666 - set delta endstop adjustemnt
|
|
165
|
+// M666 - set delta endstop adjustment
|
166
|
166
|
// M605 - Set dual x-carriage movement mode: S<mode> [ X<duplication x-offset> R<duplication temp offset> ]
|
167
|
167
|
// M907 - Set digital trimpot motor current using axis codes.
|
168
|
168
|
// M908 - Control digital trimpot directly.
|
|
@@ -232,10 +232,13 @@ int EtoPPressure=0;
|
232
|
232
|
#endif
|
233
|
233
|
|
234
|
234
|
#ifdef FWRETRACT
|
235
|
|
- bool autoretract_enabled=true;
|
|
235
|
+ bool autoretract_enabled=false;
|
236
|
236
|
bool retracted=false;
|
237
|
|
- float retract_length=3, retract_feedrate=17*60, retract_zlift=0.8;
|
238
|
|
- float retract_recover_length=0, retract_recover_feedrate=8*60;
|
|
237
|
+ float retract_length = RETRACT_LENGTH;
|
|
238
|
+ float retract_feedrate = RETRACT_FEEDRATE;
|
|
239
|
+ float retract_zlift = RETRACT_ZLIFT;
|
|
240
|
+ float retract_recover_length = RETRACT_RECOVER_LENGTH;
|
|
241
|
+ float retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
|
239
|
242
|
#endif
|
240
|
243
|
|
241
|
244
|
#ifdef ULTIPANEL
|
|
@@ -264,7 +267,7 @@ int EtoPPressure=0;
|
264
|
267
|
#endif
|
265
|
268
|
|
266
|
269
|
//===========================================================================
|
267
|
|
-//=============================private variables=============================
|
|
270
|
+//=============================Private Variables=============================
|
268
|
271
|
//===========================================================================
|
269
|
272
|
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
270
|
273
|
static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
|
@@ -284,7 +287,7 @@ static int buflen = 0;
|
284
|
287
|
static char serial_char;
|
285
|
288
|
static int serial_count = 0;
|
286
|
289
|
static boolean comment_mode = false;
|
287
|
|
-static char *strchr_pointer; // just a pointer to find chars in the cmd string like X, Y, Z, E, etc
|
|
290
|
+static char *strchr_pointer; // just a pointer to find chars in the command string like X, Y, Z, E, etc
|
288
|
291
|
|
289
|
292
|
const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
|
290
|
293
|
|
|
@@ -312,7 +315,7 @@ bool CooldownNoWait = true;
|
312
|
315
|
bool target_direction;
|
313
|
316
|
|
314
|
317
|
//===========================================================================
|
315
|
|
-//=============================ROUTINES=============================
|
|
318
|
+//=============================Routines======================================
|
316
|
319
|
//===========================================================================
|
317
|
320
|
|
318
|
321
|
void get_arc_coordinates();
|
|
@@ -349,7 +352,7 @@ void enquecommand(const char *cmd)
|
349
|
352
|
{
|
350
|
353
|
if(buflen < BUFSIZE)
|
351
|
354
|
{
|
352
|
|
- //this is dangerous if a mixing of serial and this happsens
|
|
355
|
+ //this is dangerous if a mixing of serial and this happens
|
353
|
356
|
strcpy(&(cmdbuffer[bufindw][0]),cmd);
|
354
|
357
|
SERIAL_ECHO_START;
|
355
|
358
|
SERIAL_ECHOPGM("enqueing \"");
|
|
@@ -364,7 +367,7 @@ void enquecommand_P(const char *cmd)
|
364
|
367
|
{
|
365
|
368
|
if(buflen < BUFSIZE)
|
366
|
369
|
{
|
367
|
|
- //this is dangerous if a mixing of serial and this happsens
|
|
370
|
+ //this is dangerous if a mixing of serial and this happens
|
368
|
371
|
strcpy_P(&(cmdbuffer[bufindw][0]),cmd);
|
369
|
372
|
SERIAL_ECHO_START;
|
370
|
373
|
SERIAL_ECHOPGM("enqueing \"");
|
|
@@ -671,9 +674,9 @@ void get_command()
|
671
|
674
|
return;
|
672
|
675
|
}
|
673
|
676
|
|
674
|
|
- //'#' stops reading from sd to the buffer prematurely, so procedural macro calls are possible
|
675
|
|
- // if it occures, stop_buffering is triggered and the buffer is ran dry.
|
676
|
|
- // this character _can_ occure in serial com, due to checksums. however, no checksums are used in sd printing
|
|
677
|
+ //'#' stops reading from SD to the buffer prematurely, so procedural macro calls are possible
|
|
678
|
+ // if it occurs, stop_buffering is triggered and the buffer is ran dry.
|
|
679
|
+ // this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing
|
677
|
680
|
|
678
|
681
|
static bool stop_buffering=false;
|
679
|
682
|
if(buflen==0) stop_buffering=false;
|
|
@@ -832,7 +835,7 @@ static void axis_is_at_home(int axis) {
|
832
|
835
|
}
|
833
|
836
|
|
834
|
837
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
835
|
|
-#ifdef ACCURATE_BED_LEVELING
|
|
838
|
+#ifdef AUTO_BED_LEVELING_GRID
|
836
|
839
|
static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
|
837
|
840
|
{
|
838
|
841
|
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)
|
856
|
859
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
857
|
860
|
}
|
858
|
861
|
|
859
|
|
-#else
|
860
|
|
-static void set_bed_level_equation(float z_at_xLeft_yFront, float z_at_xRight_yFront, float z_at_xLeft_yBack) {
|
861
|
|
- plan_bed_level_matrix.set_to_identity();
|
|
862
|
+#else // not AUTO_BED_LEVELING_GRID
|
862
|
863
|
|
863
|
|
- vector_3 xLeftyFront = vector_3(LEFT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, z_at_xLeft_yFront);
|
864
|
|
- vector_3 xLeftyBack = vector_3(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, z_at_xLeft_yBack);
|
865
|
|
- vector_3 xRightyFront = vector_3(RIGHT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, z_at_xRight_yFront);
|
|
864
|
+static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float z_at_pt_3) {
|
866
|
865
|
|
867
|
|
- vector_3 xPositive = (xRightyFront - xLeftyFront).get_normal();
|
868
|
|
- vector_3 yPositive = (xLeftyBack - xLeftyFront).get_normal();
|
869
|
|
- vector_3 planeNormal = vector_3::cross(xPositive, yPositive).get_normal();
|
|
866
|
+ plan_bed_level_matrix.set_to_identity();
|
870
|
867
|
|
871
|
|
- //planeNormal.debug("planeNormal");
|
872
|
|
- //yPositive.debug("yPositive");
|
873
|
|
- plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
874
|
|
- //bedLevel.debug("bedLevel");
|
|
868
|
+ vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1);
|
|
869
|
+ vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
|
|
870
|
+ vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
|
875
|
871
|
|
876
|
|
- //plan_bed_level_matrix.debug("bed level before");
|
877
|
|
- //vector_3 uncorrected_position = plan_get_position_mm();
|
878
|
|
- //uncorrected_position.debug("position before");
|
|
872
|
+ vector_3 from_2_to_1 = (pt1 - pt2).get_normal();
|
|
873
|
+ vector_3 from_2_to_3 = (pt3 - pt2).get_normal();
|
|
874
|
+ vector_3 planeNormal = vector_3::cross(from_2_to_1, from_2_to_3).get_normal();
|
|
875
|
+ planeNormal = vector_3(planeNormal.x, planeNormal.y, abs(planeNormal.z));
|
879
|
876
|
|
880
|
|
- // and set our bed level equation to do the right thing
|
881
|
|
- //plan_bed_level_matrix.debug("bed level after");
|
|
877
|
+ plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
882
|
878
|
|
883
|
879
|
vector_3 corrected_position = plan_get_position();
|
884
|
|
- //corrected_position.debug("position after");
|
885
|
880
|
current_position[X_AXIS] = corrected_position.x;
|
886
|
881
|
current_position[Y_AXIS] = corrected_position.y;
|
887
|
882
|
current_position[Z_AXIS] = corrected_position.z;
|
888
|
883
|
|
889
|
|
- // but the bed at 0 so we don't go below it.
|
|
884
|
+ // put the bed at 0 so we don't go below it.
|
890
|
885
|
current_position[Z_AXIS] = zprobe_zoffset;
|
891
|
886
|
|
892
|
887
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
888
|
+
|
893
|
889
|
}
|
894
|
|
-#endif // ACCURATE_BED_LEVELING
|
|
890
|
+
|
|
891
|
+#endif // AUTO_BED_LEVELING_GRID
|
895
|
892
|
|
896
|
893
|
static void run_z_probe() {
|
897
|
894
|
plan_bed_level_matrix.set_to_identity();
|
|
@@ -1098,6 +1095,42 @@ void refresh_cmd_timeout(void)
|
1098
|
1095
|
previous_millis_cmd = millis();
|
1099
|
1096
|
}
|
1100
|
1097
|
|
|
1098
|
+#ifdef FWRETRACT
|
|
1099
|
+ void retract(bool retracting) {
|
|
1100
|
+ if(retracting && !retracted) {
|
|
1101
|
+ destination[X_AXIS]=current_position[X_AXIS];
|
|
1102
|
+ destination[Y_AXIS]=current_position[Y_AXIS];
|
|
1103
|
+ destination[Z_AXIS]=current_position[Z_AXIS];
|
|
1104
|
+ destination[E_AXIS]=current_position[E_AXIS];
|
|
1105
|
+ current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
|
|
1106
|
+ plan_set_e_position(current_position[E_AXIS]);
|
|
1107
|
+ float oldFeedrate = feedrate;
|
|
1108
|
+ feedrate=retract_feedrate;
|
|
1109
|
+ retracted=true;
|
|
1110
|
+ prepare_move();
|
|
1111
|
+ current_position[Z_AXIS]-=retract_zlift;
|
|
1112
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1113
|
+ prepare_move();
|
|
1114
|
+ feedrate = oldFeedrate;
|
|
1115
|
+ } else if(!retracting && retracted) {
|
|
1116
|
+ destination[X_AXIS]=current_position[X_AXIS];
|
|
1117
|
+ destination[Y_AXIS]=current_position[Y_AXIS];
|
|
1118
|
+ destination[Z_AXIS]=current_position[Z_AXIS];
|
|
1119
|
+ destination[E_AXIS]=current_position[E_AXIS];
|
|
1120
|
+ current_position[Z_AXIS]+=retract_zlift;
|
|
1121
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1122
|
+ //prepare_move();
|
|
1123
|
+ current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder];
|
|
1124
|
+ plan_set_e_position(current_position[E_AXIS]);
|
|
1125
|
+ float oldFeedrate = feedrate;
|
|
1126
|
+ feedrate=retract_recover_feedrate;
|
|
1127
|
+ retracted=false;
|
|
1128
|
+ prepare_move();
|
|
1129
|
+ feedrate = oldFeedrate;
|
|
1130
|
+ }
|
|
1131
|
+ } //retract
|
|
1132
|
+#endif //FWRETRACT
|
|
1133
|
+
|
1101
|
1134
|
void process_commands()
|
1102
|
1135
|
{
|
1103
|
1136
|
unsigned long codenum; //throw away variable
|
|
@@ -1113,6 +1146,18 @@ void process_commands()
|
1113
|
1146
|
case 1: // G1
|
1114
|
1147
|
if(Stopped == false) {
|
1115
|
1148
|
get_coordinates(); // For X Y Z E F
|
|
1149
|
+ #ifdef FWRETRACT
|
|
1150
|
+ if(autoretract_enabled)
|
|
1151
|
+ if( !(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) {
|
|
1152
|
+ float echange=destination[E_AXIS]-current_position[E_AXIS];
|
|
1153
|
+ if((echange<-MIN_RETRACT && !retracted) || (echange>MIN_RETRACT && retracted)) { //move appears to be an attempt to retract or recover
|
|
1154
|
+ current_position[E_AXIS] = destination[E_AXIS]; //hide the slicer-generated retract/recover from calculations
|
|
1155
|
+ plan_set_e_position(current_position[E_AXIS]); //AND from the planner
|
|
1156
|
+ retract(!retracted);
|
|
1157
|
+ return;
|
|
1158
|
+ }
|
|
1159
|
+ }
|
|
1160
|
+ #endif //FWRETRACT
|
1116
|
1161
|
prepare_move();
|
1117
|
1162
|
//ClearToSend();
|
1118
|
1163
|
return;
|
|
@@ -1147,39 +1192,10 @@ void process_commands()
|
1147
|
1192
|
break;
|
1148
|
1193
|
#ifdef FWRETRACT
|
1149
|
1194
|
case 10: // G10 retract
|
1150
|
|
- if(!retracted)
|
1151
|
|
- {
|
1152
|
|
- destination[X_AXIS]=current_position[X_AXIS];
|
1153
|
|
- destination[Y_AXIS]=current_position[Y_AXIS];
|
1154
|
|
- destination[Z_AXIS]=current_position[Z_AXIS];
|
1155
|
|
- current_position[Z_AXIS]-=retract_zlift;
|
1156
|
|
- destination[E_AXIS]=current_position[E_AXIS];
|
1157
|
|
- current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
|
1158
|
|
- plan_set_e_position(current_position[E_AXIS]);
|
1159
|
|
- float oldFeedrate = feedrate;
|
1160
|
|
- feedrate=retract_feedrate;
|
1161
|
|
- retracted=true;
|
1162
|
|
- prepare_move();
|
1163
|
|
- feedrate = oldFeedrate;
|
1164
|
|
- }
|
1165
|
|
-
|
|
1195
|
+ retract(true);
|
1166
|
1196
|
break;
|
1167
|
1197
|
case 11: // G11 retract_recover
|
1168
|
|
- if(retracted)
|
1169
|
|
- {
|
1170
|
|
- destination[X_AXIS]=current_position[X_AXIS];
|
1171
|
|
- destination[Y_AXIS]=current_position[Y_AXIS];
|
1172
|
|
- destination[Z_AXIS]=current_position[Z_AXIS];
|
1173
|
|
- current_position[Z_AXIS]+=retract_zlift;
|
1174
|
|
- destination[E_AXIS]=current_position[E_AXIS];
|
1175
|
|
- current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder];
|
1176
|
|
- plan_set_e_position(current_position[E_AXIS]);
|
1177
|
|
- float oldFeedrate = feedrate;
|
1178
|
|
- feedrate=retract_recover_feedrate;
|
1179
|
|
- retracted=false;
|
1180
|
|
- prepare_move();
|
1181
|
|
- feedrate = oldFeedrate;
|
1182
|
|
- }
|
|
1198
|
+ retract(false);
|
1183
|
1199
|
break;
|
1184
|
1200
|
#endif //FWRETRACT
|
1185
|
1201
|
case 28: //G28 Home all Axis one at a time
|
|
@@ -1232,7 +1248,7 @@ void process_commands()
|
1232
|
1248
|
|
1233
|
1249
|
#else // NOT DELTA
|
1234
|
1250
|
|
1235
|
|
- home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
|
|
1251
|
+ home_all_axis = !((code_seen(axis_codes[X_AXIS])) || (code_seen(axis_codes[Y_AXIS])) || (code_seen(axis_codes[Z_AXIS])));
|
1236
|
1252
|
|
1237
|
1253
|
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
|
1238
|
1254
|
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
|
@@ -1394,12 +1410,21 @@ void process_commands()
|
1394
|
1410
|
break;
|
1395
|
1411
|
|
1396
|
1412
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
1397
|
|
- case 29: // G29 Detailed Z-Probe, probes the bed at 3 points.
|
|
1413
|
+ case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points.
|
1398
|
1414
|
{
|
1399
|
1415
|
#if Z_MIN_PIN == -1
|
1400
|
1416
|
#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."
|
1401
|
1417
|
#endif
|
1402
|
1418
|
|
|
1419
|
+ // Prevent user from running a G29 without first homing in X and Y
|
|
1420
|
+ if (! (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) )
|
|
1421
|
+ {
|
|
1422
|
+ LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
|
|
1423
|
+ SERIAL_ECHO_START;
|
|
1424
|
+ SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
|
|
1425
|
+ break; // abort G29, since we don't know where we are
|
|
1426
|
+ }
|
|
1427
|
+
|
1403
|
1428
|
st_synchronize();
|
1404
|
1429
|
// make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
|
1405
|
1430
|
//vector_3 corrected_position = plan_get_position_mm();
|
|
@@ -1414,10 +1439,11 @@ void process_commands()
|
1414
|
1439
|
setup_for_endstop_move();
|
1415
|
1440
|
|
1416
|
1441
|
feedrate = homing_feedrate[Z_AXIS];
|
1417
|
|
-#ifdef ACCURATE_BED_LEVELING
|
|
1442
|
+#ifdef AUTO_BED_LEVELING_GRID
|
|
1443
|
+ // probe at the points of a lattice grid
|
1418
|
1444
|
|
1419
|
|
- int xGridSpacing = (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION) / (ACCURATE_BED_LEVELING_POINTS-1);
|
1420
|
|
- int yGridSpacing = (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION) / (ACCURATE_BED_LEVELING_POINTS-1);
|
|
1445
|
+ int xGridSpacing = (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION) / (AUTO_BED_LEVELING_GRID_POINTS-1);
|
|
1446
|
+ int yGridSpacing = (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION) / (AUTO_BED_LEVELING_GRID_POINTS-1);
|
1421
|
1447
|
|
1422
|
1448
|
|
1423
|
1449
|
// solve the plane equation ax + by + d = z
|
|
@@ -1427,9 +1453,9 @@ void process_commands()
|
1427
|
1453
|
// so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
1428
|
1454
|
|
1429
|
1455
|
// "A" matrix of the linear system of equations
|
1430
|
|
- double eqnAMatrix[ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS*3];
|
|
1456
|
+ double eqnAMatrix[AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS*3];
|
1431
|
1457
|
// "B" vector of Z points
|
1432
|
|
- double eqnBVector[ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS];
|
|
1458
|
+ double eqnBVector[AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS];
|
1433
|
1459
|
|
1434
|
1460
|
|
1435
|
1461
|
int probePointCounter = 0;
|
|
@@ -1452,7 +1478,7 @@ void process_commands()
|
1452
|
1478
|
zig = true;
|
1453
|
1479
|
}
|
1454
|
1480
|
|
1455
|
|
- for (int xCount=0; xCount < ACCURATE_BED_LEVELING_POINTS; xCount++)
|
|
1481
|
+ for (int xCount=0; xCount < AUTO_BED_LEVELING_GRID_POINTS; xCount++)
|
1456
|
1482
|
{
|
1457
|
1483
|
float z_before;
|
1458
|
1484
|
if (probePointCounter == 0)
|
|
@@ -1469,9 +1495,9 @@ void process_commands()
|
1469
|
1495
|
|
1470
|
1496
|
eqnBVector[probePointCounter] = measured_z;
|
1471
|
1497
|
|
1472
|
|
- eqnAMatrix[probePointCounter + 0*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = xProbe;
|
1473
|
|
- eqnAMatrix[probePointCounter + 1*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = yProbe;
|
1474
|
|
- eqnAMatrix[probePointCounter + 2*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = 1;
|
|
1498
|
+ eqnAMatrix[probePointCounter + 0*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = xProbe;
|
|
1499
|
+ eqnAMatrix[probePointCounter + 1*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = yProbe;
|
|
1500
|
+ eqnAMatrix[probePointCounter + 2*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = 1;
|
1475
|
1501
|
probePointCounter++;
|
1476
|
1502
|
xProbe += xInc;
|
1477
|
1503
|
}
|
|
@@ -1479,7 +1505,7 @@ void process_commands()
|
1479
|
1505
|
clean_up_after_endstop_move();
|
1480
|
1506
|
|
1481
|
1507
|
// solve lsq problem
|
1482
|
|
- double *plane_equation_coefficients = qr_solve(ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS, 3, eqnAMatrix, eqnBVector);
|
|
1508
|
+ double *plane_equation_coefficients = qr_solve(AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS, 3, eqnAMatrix, eqnBVector);
|
1483
|
1509
|
|
1484
|
1510
|
SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
|
1485
|
1511
|
SERIAL_PROTOCOL(plane_equation_coefficients[0]);
|
|
@@ -1493,24 +1519,24 @@ void process_commands()
|
1493
|
1519
|
|
1494
|
1520
|
free(plane_equation_coefficients);
|
1495
|
1521
|
|
1496
|
|
-#else // ACCURATE_BED_LEVELING not defined
|
1497
|
|
-
|
|
1522
|
+#else // AUTO_BED_LEVELING_GRID not defined
|
1498
|
1523
|
|
1499
|
|
- // prob 1
|
1500
|
|
- float z_at_xLeft_yBack = probe_pt(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, Z_RAISE_BEFORE_PROBING);
|
|
1524
|
+ // Probe at 3 arbitrary points
|
|
1525
|
+ // probe 1
|
|
1526
|
+ float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING);
|
1501
|
1527
|
|
1502
|
|
- // prob 2
|
1503
|
|
- float z_at_xLeft_yFront = probe_pt(LEFT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
|
1528
|
+ // probe 2
|
|
1529
|
+ 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);
|
1504
|
1530
|
|
1505
|
|
- // prob 3
|
1506
|
|
- float z_at_xRight_yFront = probe_pt(RIGHT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
|
1531
|
+ // probe 3
|
|
1532
|
+ 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);
|
1507
|
1533
|
|
1508
|
1534
|
clean_up_after_endstop_move();
|
1509
|
1535
|
|
1510
|
|
- set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
|
|
1536
|
+ set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
1511
|
1537
|
|
1512
|
1538
|
|
1513
|
|
-#endif // ACCURATE_BED_LEVELING
|
|
1539
|
+#endif // AUTO_BED_LEVELING_GRID
|
1514
|
1540
|
st_synchronize();
|
1515
|
1541
|
|
1516
|
1542
|
// The following code correct the Z height difference from z-probe position and hotend tip position.
|
|
@@ -2079,7 +2105,7 @@ void process_commands()
|
2079
|
2105
|
}
|
2080
|
2106
|
else
|
2081
|
2107
|
{
|
2082
|
|
- bool all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2]))|| (code_seen(axis_codes[3])));
|
|
2108
|
+ 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])));
|
2083
|
2109
|
if(all_axis)
|
2084
|
2110
|
{
|
2085
|
2111
|
st_synchronize();
|
|
@@ -3048,42 +3074,6 @@ void get_coordinates()
|
3048
|
3074
|
next_feedrate = code_value();
|
3049
|
3075
|
if(next_feedrate > 0.0) feedrate = next_feedrate;
|
3050
|
3076
|
}
|
3051
|
|
- #ifdef FWRETRACT
|
3052
|
|
- if(autoretract_enabled)
|
3053
|
|
- if( !(seen[X_AXIS] || seen[Y_AXIS] || seen[Z_AXIS]) && seen[E_AXIS])
|
3054
|
|
- {
|
3055
|
|
- float echange=destination[E_AXIS]-current_position[E_AXIS];
|
3056
|
|
- if(echange<-MIN_RETRACT) //retract
|
3057
|
|
- {
|
3058
|
|
- if(!retracted)
|
3059
|
|
- {
|
3060
|
|
-
|
3061
|
|
- destination[Z_AXIS]+=retract_zlift; //not sure why chaninging current_position negatively does not work.
|
3062
|
|
- //if slicer retracted by echange=-1mm and you want to retract 3mm, corrrectede=-2mm additionally
|
3063
|
|
- float correctede=-echange-retract_length;
|
3064
|
|
- //to generate the additional steps, not the destination is changed, but inversely the current position
|
3065
|
|
- current_position[E_AXIS]+=-correctede;
|
3066
|
|
- feedrate=retract_feedrate;
|
3067
|
|
- retracted=true;
|
3068
|
|
- }
|
3069
|
|
-
|
3070
|
|
- }
|
3071
|
|
- else
|
3072
|
|
- if(echange>MIN_RETRACT) //retract_recover
|
3073
|
|
- {
|
3074
|
|
- if(retracted)
|
3075
|
|
- {
|
3076
|
|
- //current_position[Z_AXIS]+=-retract_zlift;
|
3077
|
|
- //if slicer retracted_recovered by echange=+1mm and you want to retract_recover 3mm, corrrectede=2mm additionally
|
3078
|
|
- float correctede=-echange+1*retract_length+retract_recover_length; //total unretract=retract_length+retract_recover_length[surplus]
|
3079
|
|
- current_position[E_AXIS]+=correctede; //to generate the additional steps, not the destination is changed, but inversely the current position
|
3080
|
|
- feedrate=retract_recover_feedrate;
|
3081
|
|
- retracted=false;
|
3082
|
|
- }
|
3083
|
|
- }
|
3084
|
|
-
|
3085
|
|
- }
|
3086
|
|
- #endif //FWRETRACT
|
3087
|
3077
|
}
|
3088
|
3078
|
|
3089
|
3079
|
void get_arc_coordinates()
|