|
@@ -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,17 +127,17 @@
|
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
|
140
|
|
-// M207 - set retract length S[positive mm] F[feedrate mm/sec] Z[additional zlift/hop]
|
|
139
|
+// M206 - set additional homing offset
|
|
140
|
+// M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting
|
141
|
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>
|
|
@@ -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,13 +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
|
|
-// M666 - set delta endstop adjustemnt
|
|
164
|
+// M665 - set delta configurations
|
|
165
|
+// M666 - set delta endstop adjustment
|
165
|
166
|
// M605 - Set dual x-carriage movement mode: S<mode> [ X<duplication x-offset> R<duplication temp offset> ]
|
166
|
167
|
// M907 - Set digital trimpot motor current using axis codes.
|
167
|
168
|
// M908 - Control digital trimpot directly.
|
|
@@ -231,10 +232,13 @@ int EtoPPressure=0;
|
231
|
232
|
#endif
|
232
|
233
|
|
233
|
234
|
#ifdef FWRETRACT
|
234
|
|
- bool autoretract_enabled=true;
|
|
235
|
+ bool autoretract_enabled=false;
|
235
|
236
|
bool retracted=false;
|
236
|
|
- float retract_length=3, retract_feedrate=17*60, retract_zlift=0.8;
|
237
|
|
- 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;
|
238
|
242
|
#endif
|
239
|
243
|
|
240
|
244
|
#ifdef ULTIPANEL
|
|
@@ -246,12 +250,24 @@ int EtoPPressure=0;
|
246
|
250
|
#endif
|
247
|
251
|
|
248
|
252
|
#ifdef DELTA
|
249
|
|
-float delta[3] = {0.0, 0.0, 0.0};
|
250
|
|
-#endif
|
251
|
|
-
|
|
253
|
+ float delta[3] = {0.0, 0.0, 0.0};
|
|
254
|
+ #define SIN_60 0.8660254037844386
|
|
255
|
+ #define COS_60 0.5
|
|
256
|
+ // these are the default values, can be overriden with M665
|
|
257
|
+ float delta_radius= DELTA_RADIUS;
|
|
258
|
+ float delta_tower1_x= -SIN_60*delta_radius; // front left tower
|
|
259
|
+ float delta_tower1_y= -COS_60*delta_radius;
|
|
260
|
+ float delta_tower2_x= SIN_60*delta_radius; // front right tower
|
|
261
|
+ float delta_tower2_y= -COS_60*delta_radius;
|
|
262
|
+ float delta_tower3_x= 0.0; // back middle tower
|
|
263
|
+ float delta_tower3_y= delta_radius;
|
|
264
|
+ float delta_diagonal_rod= DELTA_DIAGONAL_ROD;
|
|
265
|
+ float delta_diagonal_rod_2= sq(delta_diagonal_rod);
|
|
266
|
+ float delta_segments_per_second= DELTA_SEGMENTS_PER_SECOND;
|
|
267
|
+#endif
|
252
|
268
|
|
253
|
269
|
//===========================================================================
|
254
|
|
-//=============================private variables=============================
|
|
270
|
+//=============================Private Variables=============================
|
255
|
271
|
//===========================================================================
|
256
|
272
|
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
257
|
273
|
static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
|
@@ -271,7 +287,7 @@ static int buflen = 0;
|
271
|
287
|
static char serial_char;
|
272
|
288
|
static int serial_count = 0;
|
273
|
289
|
static boolean comment_mode = false;
|
274
|
|
-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
|
275
|
291
|
|
276
|
292
|
const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
|
277
|
293
|
|
|
@@ -298,8 +314,14 @@ bool Stopped=false;
|
298
|
314
|
bool CooldownNoWait = true;
|
299
|
315
|
bool target_direction;
|
300
|
316
|
|
|
317
|
+//Insert variables if CHDK is defined
|
|
318
|
+#ifdef CHDK
|
|
319
|
+unsigned long chdkHigh = 0;
|
|
320
|
+boolean chdkActive = false;
|
|
321
|
+#endif
|
|
322
|
+
|
301
|
323
|
//===========================================================================
|
302
|
|
-//=============================ROUTINES=============================
|
|
324
|
+//=============================Routines======================================
|
303
|
325
|
//===========================================================================
|
304
|
326
|
|
305
|
327
|
void get_arc_coordinates();
|
|
@@ -336,7 +358,7 @@ void enquecommand(const char *cmd)
|
336
|
358
|
{
|
337
|
359
|
if(buflen < BUFSIZE)
|
338
|
360
|
{
|
339
|
|
- //this is dangerous if a mixing of serial and this happsens
|
|
361
|
+ //this is dangerous if a mixing of serial and this happens
|
340
|
362
|
strcpy(&(cmdbuffer[bufindw][0]),cmd);
|
341
|
363
|
SERIAL_ECHO_START;
|
342
|
364
|
SERIAL_ECHOPGM("enqueing \"");
|
|
@@ -351,7 +373,7 @@ void enquecommand_P(const char *cmd)
|
351
|
373
|
{
|
352
|
374
|
if(buflen < BUFSIZE)
|
353
|
375
|
{
|
354
|
|
- //this is dangerous if a mixing of serial and this happsens
|
|
376
|
+ //this is dangerous if a mixing of serial and this happens
|
355
|
377
|
strcpy_P(&(cmdbuffer[bufindw][0]),cmd);
|
356
|
378
|
SERIAL_ECHO_START;
|
357
|
379
|
SERIAL_ECHOPGM("enqueing \"");
|
|
@@ -658,9 +680,9 @@ void get_command()
|
658
|
680
|
return;
|
659
|
681
|
}
|
660
|
682
|
|
661
|
|
- //'#' stops reading from sd to the buffer prematurely, so procedural macro calls are possible
|
662
|
|
- // if it occures, stop_buffering is triggered and the buffer is ran dry.
|
663
|
|
- // this character _can_ occure in serial com, due to checksums. however, no checksums are used in sd printing
|
|
683
|
+ //'#' stops reading from SD to the buffer prematurely, so procedural macro calls are possible
|
|
684
|
+ // if it occurs, stop_buffering is triggered and the buffer is ran dry.
|
|
685
|
+ // this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing
|
664
|
686
|
|
665
|
687
|
static bool stop_buffering=false;
|
666
|
688
|
if(buflen==0) stop_buffering=false;
|
|
@@ -819,7 +841,7 @@ static void axis_is_at_home(int axis) {
|
819
|
841
|
}
|
820
|
842
|
|
821
|
843
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
822
|
|
-#ifdef ACCURATE_BED_LEVELING
|
|
844
|
+#ifdef AUTO_BED_LEVELING_GRID
|
823
|
845
|
static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
|
824
|
846
|
{
|
825
|
847
|
vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
|
|
@@ -843,42 +865,36 @@ static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
|
843
|
865
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
844
|
866
|
}
|
845
|
867
|
|
846
|
|
-#else
|
847
|
|
-static void set_bed_level_equation(float z_at_xLeft_yFront, float z_at_xRight_yFront, float z_at_xLeft_yBack) {
|
848
|
|
- plan_bed_level_matrix.set_to_identity();
|
|
868
|
+#else // not AUTO_BED_LEVELING_GRID
|
849
|
869
|
|
850
|
|
- vector_3 xLeftyFront = vector_3(LEFT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, z_at_xLeft_yFront);
|
851
|
|
- vector_3 xLeftyBack = vector_3(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, z_at_xLeft_yBack);
|
852
|
|
- vector_3 xRightyFront = vector_3(RIGHT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, z_at_xRight_yFront);
|
|
870
|
+static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float z_at_pt_3) {
|
853
|
871
|
|
854
|
|
- vector_3 xPositive = (xRightyFront - xLeftyFront).get_normal();
|
855
|
|
- vector_3 yPositive = (xLeftyBack - xLeftyFront).get_normal();
|
856
|
|
- vector_3 planeNormal = vector_3::cross(xPositive, yPositive).get_normal();
|
|
872
|
+ plan_bed_level_matrix.set_to_identity();
|
857
|
873
|
|
858
|
|
- //planeNormal.debug("planeNormal");
|
859
|
|
- //yPositive.debug("yPositive");
|
860
|
|
- plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
861
|
|
- //bedLevel.debug("bedLevel");
|
|
874
|
+ vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1);
|
|
875
|
+ vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
|
|
876
|
+ vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
|
862
|
877
|
|
863
|
|
- //plan_bed_level_matrix.debug("bed level before");
|
864
|
|
- //vector_3 uncorrected_position = plan_get_position_mm();
|
865
|
|
- //uncorrected_position.debug("position before");
|
|
878
|
+ vector_3 from_2_to_1 = (pt1 - pt2).get_normal();
|
|
879
|
+ vector_3 from_2_to_3 = (pt3 - pt2).get_normal();
|
|
880
|
+ vector_3 planeNormal = vector_3::cross(from_2_to_1, from_2_to_3).get_normal();
|
|
881
|
+ planeNormal = vector_3(planeNormal.x, planeNormal.y, abs(planeNormal.z));
|
866
|
882
|
|
867
|
|
- // and set our bed level equation to do the right thing
|
868
|
|
- //plan_bed_level_matrix.debug("bed level after");
|
|
883
|
+ plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
869
|
884
|
|
870
|
885
|
vector_3 corrected_position = plan_get_position();
|
871
|
|
- //corrected_position.debug("position after");
|
872
|
886
|
current_position[X_AXIS] = corrected_position.x;
|
873
|
887
|
current_position[Y_AXIS] = corrected_position.y;
|
874
|
888
|
current_position[Z_AXIS] = corrected_position.z;
|
875
|
889
|
|
876
|
|
- // but the bed at 0 so we don't go below it.
|
|
890
|
+ // put the bed at 0 so we don't go below it.
|
877
|
891
|
current_position[Z_AXIS] = zprobe_zoffset;
|
878
|
892
|
|
879
|
893
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
894
|
+
|
880
|
895
|
}
|
881
|
|
-#endif // ACCURATE_BED_LEVELING
|
|
896
|
+
|
|
897
|
+#endif // AUTO_BED_LEVELING_GRID
|
882
|
898
|
|
883
|
899
|
static void run_z_probe() {
|
884
|
900
|
plan_bed_level_matrix.set_to_identity();
|
|
@@ -978,6 +994,28 @@ static void retract_z_probe() {
|
978
|
994
|
#endif
|
979
|
995
|
}
|
980
|
996
|
|
|
997
|
+/// Probe bed height at position (x,y), returns the measured z value
|
|
998
|
+static float probe_pt(float x, float y, float z_before) {
|
|
999
|
+ // move to right place
|
|
1000
|
+ do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
|
|
1001
|
+ do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
|
|
1002
|
+
|
|
1003
|
+ engage_z_probe(); // Engage Z Servo endstop if available
|
|
1004
|
+ run_z_probe();
|
|
1005
|
+ float measured_z = current_position[Z_AXIS];
|
|
1006
|
+ retract_z_probe();
|
|
1007
|
+
|
|
1008
|
+ SERIAL_PROTOCOLPGM(MSG_BED);
|
|
1009
|
+ SERIAL_PROTOCOLPGM(" x: ");
|
|
1010
|
+ SERIAL_PROTOCOL(x);
|
|
1011
|
+ SERIAL_PROTOCOLPGM(" y: ");
|
|
1012
|
+ SERIAL_PROTOCOL(y);
|
|
1013
|
+ SERIAL_PROTOCOLPGM(" z: ");
|
|
1014
|
+ SERIAL_PROTOCOL(measured_z);
|
|
1015
|
+ SERIAL_PROTOCOLPGM("\n");
|
|
1016
|
+ return measured_z;
|
|
1017
|
+}
|
|
1018
|
+
|
981
|
1019
|
#endif // #ifdef ENABLE_AUTO_BED_LEVELING
|
982
|
1020
|
|
983
|
1021
|
static void homeaxis(int axis) {
|
|
@@ -1058,6 +1096,46 @@ static void homeaxis(int axis) {
|
1058
|
1096
|
}
|
1059
|
1097
|
}
|
1060
|
1098
|
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
|
|
1099
|
+void refresh_cmd_timeout(void)
|
|
1100
|
+{
|
|
1101
|
+ previous_millis_cmd = millis();
|
|
1102
|
+}
|
|
1103
|
+
|
|
1104
|
+#ifdef FWRETRACT
|
|
1105
|
+ void retract(bool retracting) {
|
|
1106
|
+ if(retracting && !retracted) {
|
|
1107
|
+ destination[X_AXIS]=current_position[X_AXIS];
|
|
1108
|
+ destination[Y_AXIS]=current_position[Y_AXIS];
|
|
1109
|
+ destination[Z_AXIS]=current_position[Z_AXIS];
|
|
1110
|
+ destination[E_AXIS]=current_position[E_AXIS];
|
|
1111
|
+ current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
|
|
1112
|
+ plan_set_e_position(current_position[E_AXIS]);
|
|
1113
|
+ float oldFeedrate = feedrate;
|
|
1114
|
+ feedrate=retract_feedrate;
|
|
1115
|
+ retracted=true;
|
|
1116
|
+ prepare_move();
|
|
1117
|
+ current_position[Z_AXIS]-=retract_zlift;
|
|
1118
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1119
|
+ prepare_move();
|
|
1120
|
+ feedrate = oldFeedrate;
|
|
1121
|
+ } else if(!retracting && retracted) {
|
|
1122
|
+ destination[X_AXIS]=current_position[X_AXIS];
|
|
1123
|
+ destination[Y_AXIS]=current_position[Y_AXIS];
|
|
1124
|
+ destination[Z_AXIS]=current_position[Z_AXIS];
|
|
1125
|
+ destination[E_AXIS]=current_position[E_AXIS];
|
|
1126
|
+ current_position[Z_AXIS]+=retract_zlift;
|
|
1127
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1128
|
+ //prepare_move();
|
|
1129
|
+ current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder];
|
|
1130
|
+ plan_set_e_position(current_position[E_AXIS]);
|
|
1131
|
+ float oldFeedrate = feedrate;
|
|
1132
|
+ feedrate=retract_recover_feedrate;
|
|
1133
|
+ retracted=false;
|
|
1134
|
+ prepare_move();
|
|
1135
|
+ feedrate = oldFeedrate;
|
|
1136
|
+ }
|
|
1137
|
+ } //retract
|
|
1138
|
+#endif //FWRETRACT
|
1061
|
1139
|
|
1062
|
1140
|
void process_commands()
|
1063
|
1141
|
{
|
|
@@ -1074,6 +1152,18 @@ void process_commands()
|
1074
|
1152
|
case 1: // G1
|
1075
|
1153
|
if(Stopped == false) {
|
1076
|
1154
|
get_coordinates(); // For X Y Z E F
|
|
1155
|
+ #ifdef FWRETRACT
|
|
1156
|
+ if(autoretract_enabled)
|
|
1157
|
+ if( !(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) {
|
|
1158
|
+ float echange=destination[E_AXIS]-current_position[E_AXIS];
|
|
1159
|
+ if((echange<-MIN_RETRACT && !retracted) || (echange>MIN_RETRACT && retracted)) { //move appears to be an attempt to retract or recover
|
|
1160
|
+ current_position[E_AXIS] = destination[E_AXIS]; //hide the slicer-generated retract/recover from calculations
|
|
1161
|
+ plan_set_e_position(current_position[E_AXIS]); //AND from the planner
|
|
1162
|
+ retract(!retracted);
|
|
1163
|
+ return;
|
|
1164
|
+ }
|
|
1165
|
+ }
|
|
1166
|
+ #endif //FWRETRACT
|
1077
|
1167
|
prepare_move();
|
1078
|
1168
|
//ClearToSend();
|
1079
|
1169
|
return;
|
|
@@ -1108,31 +1198,10 @@ void process_commands()
|
1108
|
1198
|
break;
|
1109
|
1199
|
#ifdef FWRETRACT
|
1110
|
1200
|
case 10: // G10 retract
|
1111
|
|
- if(!retracted)
|
1112
|
|
- {
|
1113
|
|
- destination[X_AXIS]=current_position[X_AXIS];
|
1114
|
|
- destination[Y_AXIS]=current_position[Y_AXIS];
|
1115
|
|
- destination[Z_AXIS]=current_position[Z_AXIS];
|
1116
|
|
- current_position[Z_AXIS]+=-retract_zlift;
|
1117
|
|
- destination[E_AXIS]=current_position[E_AXIS]-retract_length;
|
1118
|
|
- feedrate=retract_feedrate;
|
1119
|
|
- retracted=true;
|
1120
|
|
- prepare_move();
|
1121
|
|
- }
|
1122
|
|
-
|
|
1201
|
+ retract(true);
|
1123
|
1202
|
break;
|
1124
|
1203
|
case 11: // G11 retract_recover
|
1125
|
|
- if(retracted)
|
1126
|
|
- {
|
1127
|
|
- destination[X_AXIS]=current_position[X_AXIS];
|
1128
|
|
- destination[Y_AXIS]=current_position[Y_AXIS];
|
1129
|
|
- destination[Z_AXIS]=current_position[Z_AXIS];
|
1130
|
|
- current_position[Z_AXIS]+=retract_zlift;
|
1131
|
|
- destination[E_AXIS]=current_position[E_AXIS]+retract_length+retract_recover_length;
|
1132
|
|
- feedrate=retract_recover_feedrate;
|
1133
|
|
- retracted=false;
|
1134
|
|
- prepare_move();
|
1135
|
|
- }
|
|
1204
|
+ retract(false);
|
1136
|
1205
|
break;
|
1137
|
1206
|
#endif //FWRETRACT
|
1138
|
1207
|
case 28: //G28 Home all Axis one at a time
|
|
@@ -1185,7 +1254,7 @@ void process_commands()
|
1185
|
1254
|
|
1186
|
1255
|
#else // NOT DELTA
|
1187
|
1256
|
|
1188
|
|
- home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
|
|
1257
|
+ home_all_axis = !((code_seen(axis_codes[X_AXIS])) || (code_seen(axis_codes[Y_AXIS])) || (code_seen(axis_codes[Z_AXIS])));
|
1189
|
1258
|
|
1190
|
1259
|
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
|
1191
|
1260
|
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
|
@@ -1347,12 +1416,21 @@ void process_commands()
|
1347
|
1416
|
break;
|
1348
|
1417
|
|
1349
|
1418
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
1350
|
|
- case 29: // G29 Detailed Z-Probe, probes the bed at 3 points.
|
|
1419
|
+ case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points.
|
1351
|
1420
|
{
|
1352
|
1421
|
#if Z_MIN_PIN == -1
|
1353
|
1422
|
#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."
|
1354
|
1423
|
#endif
|
1355
|
1424
|
|
|
1425
|
+ // Prevent user from running a G29 without first homing in X and Y
|
|
1426
|
+ if (! (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) )
|
|
1427
|
+ {
|
|
1428
|
+ LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
|
|
1429
|
+ SERIAL_ECHO_START;
|
|
1430
|
+ SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
|
|
1431
|
+ break; // abort G29, since we don't know where we are
|
|
1432
|
+ }
|
|
1433
|
+
|
1356
|
1434
|
st_synchronize();
|
1357
|
1435
|
// make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
|
1358
|
1436
|
//vector_3 corrected_position = plan_get_position_mm();
|
|
@@ -1367,10 +1445,11 @@ void process_commands()
|
1367
|
1445
|
setup_for_endstop_move();
|
1368
|
1446
|
|
1369
|
1447
|
feedrate = homing_feedrate[Z_AXIS];
|
1370
|
|
-#ifdef ACCURATE_BED_LEVELING
|
|
1448
|
+#ifdef AUTO_BED_LEVELING_GRID
|
|
1449
|
+ // probe at the points of a lattice grid
|
1371
|
1450
|
|
1372
|
|
- int xGridSpacing = (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION) / (ACCURATE_BED_LEVELING_POINTS-1);
|
1373
|
|
- int yGridSpacing = (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION) / (ACCURATE_BED_LEVELING_POINTS-1);
|
|
1451
|
+ int xGridSpacing = (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION) / (AUTO_BED_LEVELING_GRID_POINTS-1);
|
|
1452
|
+ int yGridSpacing = (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION) / (AUTO_BED_LEVELING_GRID_POINTS-1);
|
1374
|
1453
|
|
1375
|
1454
|
|
1376
|
1455
|
// solve the plane equation ax + by + d = z
|
|
@@ -1380,9 +1459,9 @@ void process_commands()
|
1380
|
1459
|
// so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
1381
|
1460
|
|
1382
|
1461
|
// "A" matrix of the linear system of equations
|
1383
|
|
- double eqnAMatrix[ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS*3];
|
|
1462
|
+ double eqnAMatrix[AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS*3];
|
1384
|
1463
|
// "B" vector of Z points
|
1385
|
|
- double eqnBVector[ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS];
|
|
1464
|
+ double eqnBVector[AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS];
|
1386
|
1465
|
|
1387
|
1466
|
|
1388
|
1467
|
int probePointCounter = 0;
|
|
@@ -1405,37 +1484,26 @@ void process_commands()
|
1405
|
1484
|
zig = true;
|
1406
|
1485
|
}
|
1407
|
1486
|
|
1408
|
|
- for (int xCount=0; xCount < ACCURATE_BED_LEVELING_POINTS; xCount++)
|
|
1487
|
+ for (int xCount=0; xCount < AUTO_BED_LEVELING_GRID_POINTS; xCount++)
|
1409
|
1488
|
{
|
|
1489
|
+ float z_before;
|
1410
|
1490
|
if (probePointCounter == 0)
|
1411
|
1491
|
{
|
1412
|
1492
|
// raise before probing
|
1413
|
|
- do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_RAISE_BEFORE_PROBING);
|
|
1493
|
+ z_before = Z_RAISE_BEFORE_PROBING;
|
1414
|
1494
|
} else
|
1415
|
1495
|
{
|
1416
|
1496
|
// raise extruder
|
1417
|
|
- do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
|
1497
|
+ z_before = current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS;
|
1418
|
1498
|
}
|
1419
|
1499
|
|
|
1500
|
+ float measured_z = probe_pt(xProbe, yProbe, z_before);
|
1420
|
1501
|
|
1421
|
|
- do_blocking_move_to(xProbe - X_PROBE_OFFSET_FROM_EXTRUDER, yProbe - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
|
1422
|
|
-
|
1423
|
|
- engage_z_probe(); // Engage Z Servo endstop if available
|
1424
|
|
- run_z_probe();
|
1425
|
|
- eqnBVector[probePointCounter] = current_position[Z_AXIS];
|
1426
|
|
- retract_z_probe();
|
|
1502
|
+ eqnBVector[probePointCounter] = measured_z;
|
1427
|
1503
|
|
1428
|
|
- SERIAL_PROTOCOLPGM("Bed x: ");
|
1429
|
|
- SERIAL_PROTOCOL(xProbe);
|
1430
|
|
- SERIAL_PROTOCOLPGM(" y: ");
|
1431
|
|
- SERIAL_PROTOCOL(yProbe);
|
1432
|
|
- SERIAL_PROTOCOLPGM(" z: ");
|
1433
|
|
- SERIAL_PROTOCOL(current_position[Z_AXIS]);
|
1434
|
|
- SERIAL_PROTOCOLPGM("\n");
|
1435
|
|
-
|
1436
|
|
- eqnAMatrix[probePointCounter + 0*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = xProbe;
|
1437
|
|
- eqnAMatrix[probePointCounter + 1*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = yProbe;
|
1438
|
|
- eqnAMatrix[probePointCounter + 2*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = 1;
|
|
1504
|
+ eqnAMatrix[probePointCounter + 0*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = xProbe;
|
|
1505
|
+ eqnAMatrix[probePointCounter + 1*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = yProbe;
|
|
1506
|
+ eqnAMatrix[probePointCounter + 2*AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS] = 1;
|
1439
|
1507
|
probePointCounter++;
|
1440
|
1508
|
xProbe += xInc;
|
1441
|
1509
|
}
|
|
@@ -1443,7 +1511,7 @@ void process_commands()
|
1443
|
1511
|
clean_up_after_endstop_move();
|
1444
|
1512
|
|
1445
|
1513
|
// solve lsq problem
|
1446
|
|
- double *plane_equation_coefficients = qr_solve(ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS, 3, eqnAMatrix, eqnBVector);
|
|
1514
|
+ double *plane_equation_coefficients = qr_solve(AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS, 3, eqnAMatrix, eqnBVector);
|
1447
|
1515
|
|
1448
|
1516
|
SERIAL_PROTOCOLPGM("Eqn coefficients: a: ");
|
1449
|
1517
|
SERIAL_PROTOCOL(plane_equation_coefficients[0]);
|
|
@@ -1457,67 +1525,24 @@ void process_commands()
|
1457
|
1525
|
|
1458
|
1526
|
free(plane_equation_coefficients);
|
1459
|
1527
|
|
1460
|
|
-#else // ACCURATE_BED_LEVELING not defined
|
1461
|
|
-
|
1462
|
|
-
|
1463
|
|
- // prob 1
|
1464
|
|
- do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_RAISE_BEFORE_PROBING);
|
1465
|
|
- do_blocking_move_to(LEFT_PROBE_BED_POSITION - X_PROBE_OFFSET_FROM_EXTRUDER, BACK_PROBE_BED_POSITION - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
|
|
1528
|
+#else // AUTO_BED_LEVELING_GRID not defined
|
1466
|
1529
|
|
1467
|
|
- engage_z_probe(); // Engage Z Servo endstop if available
|
1468
|
|
- run_z_probe();
|
1469
|
|
- float z_at_xLeft_yBack = current_position[Z_AXIS];
|
1470
|
|
- retract_z_probe();
|
1471
|
|
-
|
1472
|
|
- SERIAL_PROTOCOLPGM("Bed x: ");
|
1473
|
|
- SERIAL_PROTOCOL(LEFT_PROBE_BED_POSITION);
|
1474
|
|
- SERIAL_PROTOCOLPGM(" y: ");
|
1475
|
|
- SERIAL_PROTOCOL(BACK_PROBE_BED_POSITION);
|
1476
|
|
- SERIAL_PROTOCOLPGM(" z: ");
|
1477
|
|
- SERIAL_PROTOCOL(current_position[Z_AXIS]);
|
1478
|
|
- SERIAL_PROTOCOLPGM("\n");
|
|
1530
|
+ // Probe at 3 arbitrary points
|
|
1531
|
+ // probe 1
|
|
1532
|
+ float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING);
|
1479
|
1533
|
|
1480
|
|
- // prob 2
|
1481
|
|
- do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
1482
|
|
- do_blocking_move_to(LEFT_PROBE_BED_POSITION - X_PROBE_OFFSET_FROM_EXTRUDER, FRONT_PROBE_BED_POSITION - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
|
|
1534
|
+ // probe 2
|
|
1535
|
+ 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);
|
1483
|
1536
|
|
1484
|
|
- engage_z_probe(); // Engage Z Servo endstop if available
|
1485
|
|
- run_z_probe();
|
1486
|
|
- float z_at_xLeft_yFront = current_position[Z_AXIS];
|
1487
|
|
- retract_z_probe();
|
1488
|
|
-
|
1489
|
|
- SERIAL_PROTOCOLPGM("Bed x: ");
|
1490
|
|
- SERIAL_PROTOCOL(LEFT_PROBE_BED_POSITION);
|
1491
|
|
- SERIAL_PROTOCOLPGM(" y: ");
|
1492
|
|
- SERIAL_PROTOCOL(FRONT_PROBE_BED_POSITION);
|
1493
|
|
- SERIAL_PROTOCOLPGM(" z: ");
|
1494
|
|
- SERIAL_PROTOCOL(current_position[Z_AXIS]);
|
1495
|
|
- SERIAL_PROTOCOLPGM("\n");
|
1496
|
|
-
|
1497
|
|
- // prob 3
|
1498
|
|
- do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
|
1499
|
|
- // the current position will be updated by the blocking move so the head will not lower on this next call.
|
1500
|
|
- do_blocking_move_to(RIGHT_PROBE_BED_POSITION - X_PROBE_OFFSET_FROM_EXTRUDER, FRONT_PROBE_BED_POSITION - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
|
1501
|
|
-
|
1502
|
|
- engage_z_probe(); // Engage Z Servo endstop if available
|
1503
|
|
- run_z_probe();
|
1504
|
|
- float z_at_xRight_yFront = current_position[Z_AXIS];
|
1505
|
|
- retract_z_probe(); // Retract Z Servo endstop if available
|
1506
|
|
-
|
1507
|
|
- SERIAL_PROTOCOLPGM("Bed x: ");
|
1508
|
|
- SERIAL_PROTOCOL(RIGHT_PROBE_BED_POSITION);
|
1509
|
|
- SERIAL_PROTOCOLPGM(" y: ");
|
1510
|
|
- SERIAL_PROTOCOL(FRONT_PROBE_BED_POSITION);
|
1511
|
|
- SERIAL_PROTOCOLPGM(" z: ");
|
1512
|
|
- SERIAL_PROTOCOL(current_position[Z_AXIS]);
|
1513
|
|
- SERIAL_PROTOCOLPGM("\n");
|
|
1537
|
+ // probe 3
|
|
1538
|
+ 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);
|
1514
|
1539
|
|
1515
|
1540
|
clean_up_after_endstop_move();
|
1516
|
1541
|
|
1517
|
|
- set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
|
|
1542
|
+ set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
1518
|
1543
|
|
1519
|
1544
|
|
1520
|
|
-#endif // ACCURATE_BED_LEVELING
|
|
1545
|
+#endif // AUTO_BED_LEVELING_GRID
|
1521
|
1546
|
st_synchronize();
|
1522
|
1547
|
|
1523
|
1548
|
// The following code correct the Z height difference from z-probe position and hotend tip position.
|
|
@@ -1545,7 +1570,8 @@ void process_commands()
|
1545
|
1570
|
feedrate = homing_feedrate[Z_AXIS];
|
1546
|
1571
|
|
1547
|
1572
|
run_z_probe();
|
1548
|
|
- SERIAL_PROTOCOLPGM("Bed Position X: ");
|
|
1573
|
+ SERIAL_PROTOCOLPGM(MSG_BED);
|
|
1574
|
+ SERIAL_PROTOCOLPGM(" X: ");
|
1549
|
1575
|
SERIAL_PROTOCOL(current_position[X_AXIS]);
|
1550
|
1576
|
SERIAL_PROTOCOLPGM(" Y: ");
|
1551
|
1577
|
SERIAL_PROTOCOL(current_position[Y_AXIS]);
|
|
@@ -2085,7 +2111,7 @@ void process_commands()
|
2085
|
2111
|
}
|
2086
|
2112
|
else
|
2087
|
2113
|
{
|
2088
|
|
- bool all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2]))|| (code_seen(axis_codes[3])));
|
|
2114
|
+ 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])));
|
2089
|
2115
|
if(all_axis)
|
2090
|
2116
|
{
|
2091
|
2117
|
st_synchronize();
|
|
@@ -2147,18 +2173,18 @@ void process_commands()
|
2147
|
2173
|
case 114: // M114
|
2148
|
2174
|
SERIAL_PROTOCOLPGM("X:");
|
2149
|
2175
|
SERIAL_PROTOCOL(current_position[X_AXIS]);
|
2150
|
|
- SERIAL_PROTOCOLPGM("Y:");
|
|
2176
|
+ SERIAL_PROTOCOLPGM(" Y:");
|
2151
|
2177
|
SERIAL_PROTOCOL(current_position[Y_AXIS]);
|
2152
|
|
- SERIAL_PROTOCOLPGM("Z:");
|
|
2178
|
+ SERIAL_PROTOCOLPGM(" Z:");
|
2153
|
2179
|
SERIAL_PROTOCOL(current_position[Z_AXIS]);
|
2154
|
|
- SERIAL_PROTOCOLPGM("E:");
|
|
2180
|
+ SERIAL_PROTOCOLPGM(" E:");
|
2155
|
2181
|
SERIAL_PROTOCOL(current_position[E_AXIS]);
|
2156
|
2182
|
|
2157
|
2183
|
SERIAL_PROTOCOLPGM(MSG_COUNT_X);
|
2158
|
2184
|
SERIAL_PROTOCOL(float(st_get_position(X_AXIS))/axis_steps_per_unit[X_AXIS]);
|
2159
|
|
- SERIAL_PROTOCOLPGM("Y:");
|
|
2185
|
+ SERIAL_PROTOCOLPGM(" Y:");
|
2160
|
2186
|
SERIAL_PROTOCOL(float(st_get_position(Y_AXIS))/axis_steps_per_unit[Y_AXIS]);
|
2161
|
|
- SERIAL_PROTOCOLPGM("Z:");
|
|
2187
|
+ SERIAL_PROTOCOLPGM(" Z:");
|
2162
|
2188
|
SERIAL_PROTOCOL(float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]);
|
2163
|
2189
|
|
2164
|
2190
|
SERIAL_PROTOCOLLN("");
|
|
@@ -2286,6 +2312,19 @@ void process_commands()
|
2286
|
2312
|
}
|
2287
|
2313
|
break;
|
2288
|
2314
|
#ifdef DELTA
|
|
2315
|
+ case 665: // M665 set delta configurations L<diagonal_rod> R<delta_radius> S<segments_per_sec>
|
|
2316
|
+ if(code_seen('L')) {
|
|
2317
|
+ delta_diagonal_rod= code_value();
|
|
2318
|
+ }
|
|
2319
|
+ if(code_seen('R')) {
|
|
2320
|
+ delta_radius= code_value();
|
|
2321
|
+ }
|
|
2322
|
+ if(code_seen('S')) {
|
|
2323
|
+ delta_segments_per_second= code_value();
|
|
2324
|
+ }
|
|
2325
|
+
|
|
2326
|
+ recalc_delta_settings(delta_radius, delta_diagonal_rod);
|
|
2327
|
+ break;
|
2289
|
2328
|
case 666: // M666 set delta endstop adjustemnt
|
2290
|
2329
|
for(int8_t i=0; i < 3; i++)
|
2291
|
2330
|
{
|
|
@@ -2555,23 +2594,33 @@ void process_commands()
|
2555
|
2594
|
#endif //PIDTEMP
|
2556
|
2595
|
case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
|
2557
|
2596
|
{
|
2558
|
|
- #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
|
2559
|
|
- const uint8_t NUM_PULSES=16;
|
2560
|
|
- const float PULSE_LENGTH=0.01524;
|
2561
|
|
- for(int i=0; i < NUM_PULSES; i++) {
|
2562
|
|
- WRITE(PHOTOGRAPH_PIN, HIGH);
|
2563
|
|
- _delay_ms(PULSE_LENGTH);
|
2564
|
|
- WRITE(PHOTOGRAPH_PIN, LOW);
|
2565
|
|
- _delay_ms(PULSE_LENGTH);
|
|
2597
|
+ #ifdef CHDK
|
|
2598
|
+
|
|
2599
|
+ SET_OUTPUT(CHDK);
|
|
2600
|
+ WRITE(CHDK, HIGH);
|
|
2601
|
+ chdkHigh = millis();
|
|
2602
|
+ chdkActive = true;
|
|
2603
|
+
|
|
2604
|
+ #else
|
|
2605
|
+
|
|
2606
|
+ #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
|
|
2607
|
+ const uint8_t NUM_PULSES=16;
|
|
2608
|
+ const float PULSE_LENGTH=0.01524;
|
|
2609
|
+ for(int i=0; i < NUM_PULSES; i++) {
|
|
2610
|
+ WRITE(PHOTOGRAPH_PIN, HIGH);
|
|
2611
|
+ _delay_ms(PULSE_LENGTH);
|
|
2612
|
+ WRITE(PHOTOGRAPH_PIN, LOW);
|
|
2613
|
+ _delay_ms(PULSE_LENGTH);
|
2566
|
2614
|
}
|
2567
|
2615
|
delay(7.33);
|
2568
|
2616
|
for(int i=0; i < NUM_PULSES; i++) {
|
2569
|
|
- WRITE(PHOTOGRAPH_PIN, HIGH);
|
2570
|
|
- _delay_ms(PULSE_LENGTH);
|
2571
|
|
- WRITE(PHOTOGRAPH_PIN, LOW);
|
2572
|
|
- _delay_ms(PULSE_LENGTH);
|
|
2617
|
+ WRITE(PHOTOGRAPH_PIN, HIGH);
|
|
2618
|
+ _delay_ms(PULSE_LENGTH);
|
|
2619
|
+ WRITE(PHOTOGRAPH_PIN, LOW);
|
|
2620
|
+ _delay_ms(PULSE_LENGTH);
|
2573
|
2621
|
}
|
2574
|
|
- #endif
|
|
2622
|
+ #endif
|
|
2623
|
+ #endif //chdk end if
|
2575
|
2624
|
}
|
2576
|
2625
|
break;
|
2577
|
2626
|
#ifdef DOGLCD
|
|
@@ -3041,42 +3090,6 @@ void get_coordinates()
|
3041
|
3090
|
next_feedrate = code_value();
|
3042
|
3091
|
if(next_feedrate > 0.0) feedrate = next_feedrate;
|
3043
|
3092
|
}
|
3044
|
|
- #ifdef FWRETRACT
|
3045
|
|
- if(autoretract_enabled)
|
3046
|
|
- if( !(seen[X_AXIS] || seen[Y_AXIS] || seen[Z_AXIS]) && seen[E_AXIS])
|
3047
|
|
- {
|
3048
|
|
- float echange=destination[E_AXIS]-current_position[E_AXIS];
|
3049
|
|
- if(echange<-MIN_RETRACT) //retract
|
3050
|
|
- {
|
3051
|
|
- if(!retracted)
|
3052
|
|
- {
|
3053
|
|
-
|
3054
|
|
- destination[Z_AXIS]+=retract_zlift; //not sure why chaninging current_position negatively does not work.
|
3055
|
|
- //if slicer retracted by echange=-1mm and you want to retract 3mm, corrrectede=-2mm additionally
|
3056
|
|
- float correctede=-echange-retract_length;
|
3057
|
|
- //to generate the additional steps, not the destination is changed, but inversely the current position
|
3058
|
|
- current_position[E_AXIS]+=-correctede;
|
3059
|
|
- feedrate=retract_feedrate;
|
3060
|
|
- retracted=true;
|
3061
|
|
- }
|
3062
|
|
-
|
3063
|
|
- }
|
3064
|
|
- else
|
3065
|
|
- if(echange>MIN_RETRACT) //retract_recover
|
3066
|
|
- {
|
3067
|
|
- if(retracted)
|
3068
|
|
- {
|
3069
|
|
- //current_position[Z_AXIS]+=-retract_zlift;
|
3070
|
|
- //if slicer retracted_recovered by echange=+1mm and you want to retract_recover 3mm, corrrectede=2mm additionally
|
3071
|
|
- float correctede=-echange+1*retract_length+retract_recover_length; //total unretract=retract_length+retract_recover_length[surplus]
|
3072
|
|
- current_position[E_AXIS]+=correctede; //to generate the additional steps, not the destination is changed, but inversely the current position
|
3073
|
|
- feedrate=retract_recover_feedrate;
|
3074
|
|
- retracted=false;
|
3075
|
|
- }
|
3076
|
|
- }
|
3077
|
|
-
|
3078
|
|
- }
|
3079
|
|
- #endif //FWRETRACT
|
3080
|
3093
|
}
|
3081
|
3094
|
|
3082
|
3095
|
void get_arc_coordinates()
|
|
@@ -3120,19 +3133,30 @@ void clamp_to_software_endstops(float target[3])
|
3120
|
3133
|
}
|
3121
|
3134
|
|
3122
|
3135
|
#ifdef DELTA
|
|
3136
|
+void recalc_delta_settings(float radius, float diagonal_rod)
|
|
3137
|
+{
|
|
3138
|
+ delta_tower1_x= -SIN_60*radius; // front left tower
|
|
3139
|
+ delta_tower1_y= -COS_60*radius;
|
|
3140
|
+ delta_tower2_x= SIN_60*radius; // front right tower
|
|
3141
|
+ delta_tower2_y= -COS_60*radius;
|
|
3142
|
+ delta_tower3_x= 0.0; // back middle tower
|
|
3143
|
+ delta_tower3_y= radius;
|
|
3144
|
+ delta_diagonal_rod_2= sq(diagonal_rod);
|
|
3145
|
+}
|
|
3146
|
+
|
3123
|
3147
|
void calculate_delta(float cartesian[3])
|
3124
|
3148
|
{
|
3125
|
|
- delta[X_AXIS] = sqrt(DELTA_DIAGONAL_ROD_2
|
3126
|
|
- - sq(DELTA_TOWER1_X-cartesian[X_AXIS])
|
3127
|
|
- - sq(DELTA_TOWER1_Y-cartesian[Y_AXIS])
|
|
3149
|
+ delta[X_AXIS] = sqrt(delta_diagonal_rod_2
|
|
3150
|
+ - sq(delta_tower1_x-cartesian[X_AXIS])
|
|
3151
|
+ - sq(delta_tower1_y-cartesian[Y_AXIS])
|
3128
|
3152
|
) + cartesian[Z_AXIS];
|
3129
|
|
- delta[Y_AXIS] = sqrt(DELTA_DIAGONAL_ROD_2
|
3130
|
|
- - sq(DELTA_TOWER2_X-cartesian[X_AXIS])
|
3131
|
|
- - sq(DELTA_TOWER2_Y-cartesian[Y_AXIS])
|
|
3153
|
+ delta[Y_AXIS] = sqrt(delta_diagonal_rod_2
|
|
3154
|
+ - sq(delta_tower2_x-cartesian[X_AXIS])
|
|
3155
|
+ - sq(delta_tower2_y-cartesian[Y_AXIS])
|
3132
|
3156
|
) + cartesian[Z_AXIS];
|
3133
|
|
- delta[Z_AXIS] = sqrt(DELTA_DIAGONAL_ROD_2
|
3134
|
|
- - sq(DELTA_TOWER3_X-cartesian[X_AXIS])
|
3135
|
|
- - sq(DELTA_TOWER3_Y-cartesian[Y_AXIS])
|
|
3157
|
+ delta[Z_AXIS] = sqrt(delta_diagonal_rod_2
|
|
3158
|
+ - sq(delta_tower3_x-cartesian[X_AXIS])
|
|
3159
|
+ - sq(delta_tower3_y-cartesian[Y_AXIS])
|
3136
|
3160
|
) + cartesian[Z_AXIS];
|
3137
|
3161
|
/*
|
3138
|
3162
|
SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]);
|
|
@@ -3162,7 +3186,7 @@ void prepare_move()
|
3162
|
3186
|
if (cartesian_mm < 0.000001) { cartesian_mm = abs(difference[E_AXIS]); }
|
3163
|
3187
|
if (cartesian_mm < 0.000001) { return; }
|
3164
|
3188
|
float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
|
3165
|
|
- int steps = max(1, int(DELTA_SEGMENTS_PER_SECOND * seconds));
|
|
3189
|
+ int steps = max(1, int(delta_segments_per_second * seconds));
|
3166
|
3190
|
// SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm);
|
3167
|
3191
|
// SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds);
|
3168
|
3192
|
// SERIAL_ECHOPGM(" steps="); SERIAL_ECHOLN(steps);
|
|
@@ -3345,6 +3369,16 @@ void manage_inactivity()
|
3345
|
3369
|
}
|
3346
|
3370
|
}
|
3347
|
3371
|
}
|
|
3372
|
+
|
|
3373
|
+ #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH
|
|
3374
|
+ if (chdkActive)
|
|
3375
|
+ {
|
|
3376
|
+ chdkActive = false;
|
|
3377
|
+ if (millis()-chdkHigh < CHDK_DELAY) return;
|
|
3378
|
+ WRITE(CHDK, LOW);
|
|
3379
|
+ }
|
|
3380
|
+ #endif
|
|
3381
|
+
|
3348
|
3382
|
#if defined(KILL_PIN) && KILL_PIN > -1
|
3349
|
3383
|
if( 0 == READ(KILL_PIN) )
|
3350
|
3384
|
kill();
|