|
@@ -49,16 +49,16 @@
|
49
|
49
|
#include "math.h"
|
50
|
50
|
|
51
|
51
|
#ifdef BLINKM
|
52
|
|
-#include "BlinkM.h"
|
53
|
|
-#include "Wire.h"
|
|
52
|
+ #include "BlinkM.h"
|
|
53
|
+ #include "Wire.h"
|
54
|
54
|
#endif
|
55
|
55
|
|
56
|
56
|
#if NUM_SERVOS > 0
|
57
|
|
-#include "Servo.h"
|
|
57
|
+ #include "Servo.h"
|
58
|
58
|
#endif
|
59
|
59
|
|
60
|
60
|
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
|
61
|
|
-#include <SPI.h>
|
|
61
|
+ #include <SPI.h>
|
62
|
62
|
#endif
|
63
|
63
|
|
64
|
64
|
// look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html
|
|
@@ -138,17 +138,17 @@
|
138
|
138
|
// M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
|
139
|
139
|
// 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
|
140
|
140
|
// 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
|
141
|
|
-// M206 - set additional homing offset
|
142
|
|
-// M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting
|
143
|
|
-// M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec]
|
|
141
|
+// M206 - Set additional homing offset
|
|
142
|
+// M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting
|
|
143
|
+// M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec]
|
144
|
144
|
// 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.
|
145
|
|
-// M218 - set hotend offset (in mm): T<extruder_number> X<offset_on_X> Y<offset_on_Y>
|
|
145
|
+// M218 - Set hotend offset (in mm): T<extruder_number> X<offset_on_X> Y<offset_on_Y>
|
146
|
146
|
// M220 S<factor in percent>- set speed factor override percentage
|
147
|
147
|
// M221 S<factor in percent>- set extrude factor override percentage
|
148
|
148
|
// M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
|
149
|
149
|
// M240 - Trigger a camera to take a photograph
|
150
|
150
|
// M250 - Set LCD contrast C<contrast value> (value 0..63)
|
151
|
|
-// M280 - set servo position absolute. P: servo index, S: angle or microseconds
|
|
151
|
+// M280 - Set servo position absolute. P: servo index, S: angle or microseconds
|
152
|
152
|
// M300 - Play beep sound S<frequency Hz> P<duration ms>
|
153
|
153
|
// M301 - Set PID parameters P I and D
|
154
|
154
|
// M302 - Allow cold extrudes, or set the minimum extrude S<temperature>.
|
|
@@ -161,14 +161,14 @@
|
161
|
161
|
// M405 - Turn on Filament Sensor extrusion control. Optional D<delay in cm> to set delay in centimeters between sensor and extruder
|
162
|
162
|
// M406 - Turn off Filament Sensor extrusion control
|
163
|
163
|
// M407 - Displays measured filament diameter
|
164
|
|
-// M500 - stores parameters in EEPROM
|
165
|
|
-// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
|
166
|
|
-// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
167
|
|
-// M503 - print the current settings (from memory not from EEPROM). Use S0 to leave off headings.
|
|
164
|
+// M500 - Store parameters in EEPROM
|
|
165
|
+// M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily).
|
|
166
|
+// M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
|
167
|
+// M503 - Print the current settings (from memory not from EEPROM). Use S0 to leave off headings.
|
168
|
168
|
// M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
169
|
169
|
// M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
|
170
|
|
-// M665 - set delta configurations
|
171
|
|
-// M666 - set delta endstop adjustment
|
|
170
|
+// M665 - Set delta configurations
|
|
171
|
+// M666 - Set delta endstop adjustment
|
172
|
172
|
// M605 - Set dual x-carriage movement mode: S<mode> [ X<duplication x-offset> R<duplication temp offset> ]
|
173
|
173
|
// M907 - Set digital trimpot motor current using axis codes.
|
174
|
174
|
// M908 - Control digital trimpot directly.
|
|
@@ -187,25 +187,16 @@
|
187
|
187
|
// M928 - Start SD logging (M928 filename.g) - ended by M29
|
188
|
188
|
// M999 - Restart after being stopped by error
|
189
|
189
|
|
190
|
|
-//Stepper Movement Variables
|
191
|
|
-
|
192
|
|
-//===========================================================================
|
193
|
|
-//=============================imported variables============================
|
194
|
|
-//===========================================================================
|
195
|
|
-
|
196
|
|
-
|
197
|
|
-//===========================================================================
|
198
|
|
-//=============================public variables=============================
|
199
|
|
-//===========================================================================
|
200
|
190
|
#ifdef SDSUPPORT
|
201
|
|
-CardReader card;
|
|
191
|
+ CardReader card;
|
202
|
192
|
#endif
|
|
193
|
+
|
203
|
194
|
float homing_feedrate[] = HOMING_FEEDRATE;
|
204
|
195
|
bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
|
205
|
|
-int feedmultiply=100; //100->1 200->2
|
|
196
|
+int feedmultiply = 100; //100->1 200->2
|
206
|
197
|
int saved_feedmultiply;
|
207
|
|
-int extrudemultiply=100; //100->1 200->2
|
208
|
|
-int extruder_multiply[EXTRUDERS] = {100
|
|
198
|
+int extrudemultiply = 100; //100->1 200->2
|
|
199
|
+int extruder_multiply[EXTRUDERS] = { 100
|
209
|
200
|
#if EXTRUDERS > 1
|
210
|
201
|
, 100
|
211
|
202
|
#if EXTRUDERS > 2
|
|
@@ -240,14 +231,14 @@ float volumetric_multiplier[EXTRUDERS] = {1.0
|
240
|
231
|
#endif
|
241
|
232
|
};
|
242
|
233
|
float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
|
243
|
|
-float add_homing[3]={0,0,0};
|
|
234
|
+float add_homing[3] = { 0, 0, 0 };
|
244
|
235
|
#ifdef DELTA
|
245
|
|
-float endstop_adj[3]={0,0,0};
|
|
236
|
+ float endstop_adj[3] = { 0, 0, 0 };
|
246
|
237
|
#endif
|
247
|
238
|
|
248
|
239
|
float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
|
249
|
240
|
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
|
250
|
|
-bool axis_known_position[3] = {false, false, false};
|
|
241
|
+bool axis_known_position[3] = { false, false, false };
|
251
|
242
|
float zprobe_zoffset;
|
252
|
243
|
|
253
|
244
|
// Extruder offset
|
|
@@ -258,25 +249,36 @@ float zprobe_zoffset;
|
258
|
249
|
#define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane
|
259
|
250
|
#endif
|
260
|
251
|
float extruder_offset[NUM_EXTRUDER_OFFSETS][EXTRUDERS] = {
|
261
|
|
-#if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y)
|
262
|
|
- EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y
|
263
|
|
-#endif
|
|
252
|
+ #if defined(EXTRUDER_OFFSET_X)
|
|
253
|
+ EXTRUDER_OFFSET_X
|
|
254
|
+ #else
|
|
255
|
+ 0
|
|
256
|
+ #endif
|
|
257
|
+ #if defined(EXTRUDER_OFFSET_Y)
|
|
258
|
+ EXTRUDER_OFFSET_Y
|
|
259
|
+ #else
|
|
260
|
+ 0
|
|
261
|
+ #endif
|
264
|
262
|
};
|
265
|
263
|
#endif
|
|
264
|
+
|
266
|
265
|
uint8_t active_extruder = 0;
|
267
|
|
-int fanSpeed=0;
|
|
266
|
+int fanSpeed = 0;
|
|
267
|
+
|
268
|
268
|
#ifdef SERVO_ENDSTOPS
|
269
|
269
|
int servo_endstops[] = SERVO_ENDSTOPS;
|
270
|
270
|
int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES;
|
271
|
271
|
#endif
|
|
272
|
+
|
272
|
273
|
#ifdef BARICUDA
|
273
|
|
-int ValvePressure=0;
|
274
|
|
-int EtoPPressure=0;
|
|
274
|
+ int ValvePressure = 0;
|
|
275
|
+ int EtoPPressure = 0;
|
275
|
276
|
#endif
|
276
|
277
|
|
277
|
278
|
#ifdef FWRETRACT
|
278
|
|
- bool autoretract_enabled=false;
|
279
|
|
- bool retracted[EXTRUDERS]={false
|
|
279
|
+
|
|
280
|
+ bool autoretract_enabled = false;
|
|
281
|
+ bool retracted[EXTRUDERS] = { false
|
280
|
282
|
#if EXTRUDERS > 1
|
281
|
283
|
, false
|
282
|
284
|
#if EXTRUDERS > 2
|
|
@@ -287,7 +289,7 @@ int EtoPPressure=0;
|
287
|
289
|
#endif
|
288
|
290
|
#endif
|
289
|
291
|
};
|
290
|
|
- bool retracted_swap[EXTRUDERS]={false
|
|
292
|
+ bool retracted_swap[EXTRUDERS] = { false
|
291
|
293
|
#if EXTRUDERS > 1
|
292
|
294
|
, false
|
293
|
295
|
#if EXTRUDERS > 2
|
|
@@ -306,38 +308,41 @@ int EtoPPressure=0;
|
306
|
308
|
float retract_recover_length = RETRACT_RECOVER_LENGTH;
|
307
|
309
|
float retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
|
308
|
310
|
float retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
|
|
311
|
+
|
309
|
312
|
#endif // FWRETRACT
|
310
|
313
|
|
311
|
314
|
#ifdef ULTIPANEL
|
312
|
|
- #ifdef PS_DEFAULT_OFF
|
313
|
|
- bool powersupply = false;
|
314
|
|
- #else
|
315
|
|
- bool powersupply = true;
|
316
|
|
- #endif
|
|
315
|
+ bool powersupply =
|
|
316
|
+ #ifdef PS_DEFAULT_OFF
|
|
317
|
+ false
|
|
318
|
+ #else
|
|
319
|
+ true
|
|
320
|
+ #endif
|
|
321
|
+ ;
|
317
|
322
|
#endif
|
318
|
323
|
|
319
|
324
|
#ifdef DELTA
|
320
|
|
- float delta[3] = {0.0, 0.0, 0.0};
|
|
325
|
+ float delta[3] = { 0, 0, 0 };
|
321
|
326
|
#define SIN_60 0.8660254037844386
|
322
|
327
|
#define COS_60 0.5
|
323
|
328
|
// these are the default values, can be overriden with M665
|
324
|
|
- float delta_radius= DELTA_RADIUS;
|
325
|
|
- float delta_tower1_x= -SIN_60*delta_radius; // front left tower
|
326
|
|
- float delta_tower1_y= -COS_60*delta_radius;
|
327
|
|
- float delta_tower2_x= SIN_60*delta_radius; // front right tower
|
328
|
|
- float delta_tower2_y= -COS_60*delta_radius;
|
329
|
|
- float delta_tower3_x= 0.0; // back middle tower
|
330
|
|
- float delta_tower3_y= delta_radius;
|
331
|
|
- float delta_diagonal_rod= DELTA_DIAGONAL_ROD;
|
332
|
|
- float delta_diagonal_rod_2= sq(delta_diagonal_rod);
|
333
|
|
- float delta_segments_per_second= DELTA_SEGMENTS_PER_SECOND;
|
|
329
|
+ float delta_radius = DELTA_RADIUS;
|
|
330
|
+ float delta_tower1_x = -SIN_60 * delta_radius; // front left tower
|
|
331
|
+ float delta_tower1_y = -COS_60 * delta_radius;
|
|
332
|
+ float delta_tower2_x = SIN_60 * delta_radius; // front right tower
|
|
333
|
+ float delta_tower2_y = -COS_60 * delta_radius;
|
|
334
|
+ float delta_tower3_x = 0; // back middle tower
|
|
335
|
+ float delta_tower3_y = delta_radius;
|
|
336
|
+ float delta_diagonal_rod = DELTA_DIAGONAL_ROD;
|
|
337
|
+ float delta_diagonal_rod_2 = sq(delta_diagonal_rod);
|
|
338
|
+ float delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
|
334
|
339
|
#endif
|
335
|
340
|
|
336
|
|
-#ifdef SCARA // Build size scaling
|
337
|
|
-float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1
|
|
341
|
+#ifdef SCARA
|
|
342
|
+ float axis_scaling[3] = { 1, 1, 1 }; // Build size scaling, default to 1
|
338
|
343
|
#endif
|
339
|
344
|
|
340
|
|
-bool cancel_heatup = false ;
|
|
345
|
+bool cancel_heatup = false;
|
341
|
346
|
|
342
|
347
|
#ifdef FILAMENT_SENSOR
|
343
|
348
|
//Variables for Filament Sensor input
|
|
@@ -354,17 +359,14 @@ bool cancel_heatup = false ;
|
354
|
359
|
const char errormagic[] PROGMEM = "Error:";
|
355
|
360
|
const char echomagic[] PROGMEM = "echo:";
|
356
|
361
|
|
357
|
|
-//===========================================================================
|
358
|
|
-//=============================Private Variables=============================
|
359
|
|
-//===========================================================================
|
360
|
362
|
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
361
|
|
-static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
|
363
|
+static float destination[NUM_AXIS] = { 0, 0, 0, 0 };
|
362
|
364
|
|
363
|
365
|
#ifndef DELTA
|
364
|
|
-static float delta[3] = {0.0, 0.0, 0.0};
|
|
366
|
+ static float delta[3] = { 0, 0, 0 };
|
365
|
367
|
#endif
|
366
|
368
|
|
367
|
|
-static float offset[3] = {0.0, 0.0, 0.0};
|
|
369
|
+static float offset[3] = { 0, 0, 0 };
|
368
|
370
|
static bool home_all_axis = true;
|
369
|
371
|
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
|
370
|
372
|
static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
|
|
@@ -376,29 +378,26 @@ static bool fromsd[BUFSIZE];
|
376
|
378
|
static int bufindr = 0;
|
377
|
379
|
static int bufindw = 0;
|
378
|
380
|
static int buflen = 0;
|
379
|
|
-//static int i = 0;
|
|
381
|
+
|
380
|
382
|
static char serial_char;
|
381
|
383
|
static int serial_count = 0;
|
382
|
384
|
static boolean comment_mode = false;
|
383
|
|
-static char *strchr_pointer; // just a pointer to find chars in the command string like X, Y, Z, E, etc
|
384
|
|
-
|
385
|
|
-const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
|
|
385
|
+static char *strchr_pointer; ///< A pointer to find chars in the command string (X, Y, Z, E, etc.)
|
386
|
386
|
|
387
|
|
-//static float tt = 0;
|
388
|
|
-//static float bt = 0;
|
|
387
|
+const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
|
389
|
388
|
|
390
|
|
-//Inactivity shutdown variables
|
|
389
|
+// Inactivity shutdown
|
391
|
390
|
static unsigned long previous_millis_cmd = 0;
|
392
|
391
|
static unsigned long max_inactive_time = 0;
|
393
|
392
|
static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
|
394
|
393
|
|
395
|
|
-unsigned long starttime=0;
|
396
|
|
-unsigned long stoptime=0;
|
|
394
|
+unsigned long starttime = 0; ///< Print job start time
|
|
395
|
+unsigned long stoptime = 0; ///< Print job stop time
|
397
|
396
|
|
398
|
397
|
static uint8_t tmp_extruder;
|
399
|
398
|
|
400
|
399
|
|
401
|
|
-bool Stopped=false;
|
|
400
|
+bool Stopped = false;
|
402
|
401
|
|
403
|
402
|
#if NUM_SERVOS > 0
|
404
|
403
|
Servo servos[NUM_SERVOS];
|
|
@@ -407,10 +406,9 @@ bool Stopped=false;
|
407
|
406
|
bool CooldownNoWait = true;
|
408
|
407
|
bool target_direction;
|
409
|
408
|
|
410
|
|
-//Insert variables if CHDK is defined
|
411
|
409
|
#ifdef CHDK
|
412
|
|
-unsigned long chdkHigh = 0;
|
413
|
|
-boolean chdkActive = false;
|
|
410
|
+ unsigned long chdkHigh = 0;
|
|
411
|
+ boolean chdkActive = false;
|
414
|
412
|
#endif
|
415
|
413
|
|
416
|
414
|
//===========================================================================
|