|
@@ -1524,8 +1524,7 @@ static void set_axis_is_at_home(AxisEnum axis) {
|
1524
|
1524
|
if (axis == X_AXIS || axis == Y_AXIS) {
|
1525
|
1525
|
|
1526
|
1526
|
float homeposition[3];
|
1527
|
|
- for (uint8_t i = X_AXIS; i <= Z_AXIS; i++)
|
1528
|
|
- homeposition[i] = LOGICAL_POSITION(base_home_pos(i), i);
|
|
1527
|
+ LOOP_XYZ(i) homeposition[i] = LOGICAL_POSITION(base_home_pos(i), i);
|
1529
|
1528
|
|
1530
|
1529
|
// SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]);
|
1531
|
1530
|
// SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]);
|
|
@@ -2597,7 +2596,7 @@ static void homeaxis(AxisEnum axis) {
|
2597
|
2596
|
* - Set the feedrate, if included
|
2598
|
2597
|
*/
|
2599
|
2598
|
void gcode_get_destination() {
|
2600
|
|
- for (int i = 0; i < NUM_AXIS; i++) {
|
|
2599
|
+ LOOP_XYZE(i) {
|
2601
|
2600
|
if (code_seen(axis_codes[i]))
|
2602
|
2601
|
destination[i] = code_value_axis_units(i) + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0);
|
2603
|
2602
|
else
|
|
@@ -3900,7 +3899,7 @@ inline void gcode_G92() {
|
3900
|
3899
|
if (!didE) stepper.synchronize();
|
3901
|
3900
|
|
3902
|
3901
|
bool didXYZ = false;
|
3903
|
|
- for (int i = 0; i < NUM_AXIS; i++) {
|
|
3902
|
+ LOOP_XYZE(i) {
|
3904
|
3903
|
if (code_seen(axis_codes[i])) {
|
3905
|
3904
|
float p = current_position[i],
|
3906
|
3905
|
v = code_value_axis_units(i);
|
|
@@ -5147,7 +5146,7 @@ inline void gcode_M85() {
|
5147
|
5146
|
* (Follows the same syntax as G92)
|
5148
|
5147
|
*/
|
5149
|
5148
|
inline void gcode_M92() {
|
5150
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++) {
|
|
5149
|
+ LOOP_XYZE(i) {
|
5151
|
5150
|
if (code_seen(axis_codes[i])) {
|
5152
|
5151
|
if (i == E_AXIS) {
|
5153
|
5152
|
float value = code_value_per_axis_unit(i);
|
|
@@ -5339,7 +5338,7 @@ inline void gcode_M200() {
|
5339
|
5338
|
* M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
|
5340
|
5339
|
*/
|
5341
|
5340
|
inline void gcode_M201() {
|
5342
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++) {
|
|
5341
|
+ LOOP_XYZE(i) {
|
5343
|
5342
|
if (code_seen(axis_codes[i])) {
|
5344
|
5343
|
planner.max_acceleration_mm_per_s2[i] = code_value_axis_units(i);
|
5345
|
5344
|
}
|
|
@@ -5350,7 +5349,7 @@ inline void gcode_M201() {
|
5350
|
5349
|
|
5351
|
5350
|
#if 0 // Not used for Sprinter/grbl gen6
|
5352
|
5351
|
inline void gcode_M202() {
|
5353
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++) {
|
|
5352
|
+ LOOP_XYZE(i) {
|
5354
|
5353
|
if (code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value_axis_units(i) * planner.axis_steps_per_mm[i];
|
5355
|
5354
|
}
|
5356
|
5355
|
}
|
|
@@ -5361,7 +5360,7 @@ inline void gcode_M201() {
|
5361
|
5360
|
* M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
|
5362
|
5361
|
*/
|
5363
|
5362
|
inline void gcode_M203() {
|
5364
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++)
|
|
5363
|
+ LOOP_XYZE(i)
|
5365
|
5364
|
if (code_seen(axis_codes[i]))
|
5366
|
5365
|
planner.max_feedrate_mm_s[i] = code_value_axis_units(i);
|
5367
|
5366
|
}
|
|
@@ -5421,7 +5420,7 @@ inline void gcode_M205() {
|
5421
|
5420
|
* M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
|
5422
|
5421
|
*/
|
5423
|
5422
|
inline void gcode_M206() {
|
5424
|
|
- for (int8_t i = X_AXIS; i <= Z_AXIS; i++)
|
|
5423
|
+ LOOP_XYZ(i)
|
5425
|
5424
|
if (code_seen(axis_codes[i]))
|
5426
|
5425
|
set_home_offset((AxisEnum)i, code_value_axis_units(i));
|
5427
|
5426
|
|
|
@@ -5463,7 +5462,7 @@ inline void gcode_M206() {
|
5463
|
5462
|
SERIAL_ECHOLNPGM(">>> gcode_M666");
|
5464
|
5463
|
}
|
5465
|
5464
|
#endif
|
5466
|
|
- for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
|
|
5465
|
+ LOOP_XYZ(i) {
|
5467
|
5466
|
if (code_seen(axis_codes[i])) {
|
5468
|
5467
|
endstop_adj[i] = code_value_axis_units(i);
|
5469
|
5468
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
@@ -5955,7 +5954,7 @@ inline void gcode_M303() {
|
5955
|
5954
|
* M365: SCARA calibration: Scaling factor, X, Y, Z axis
|
5956
|
5955
|
*/
|
5957
|
5956
|
inline void gcode_M365() {
|
5958
|
|
- for (int8_t i = X_AXIS; i <= Z_AXIS; i++)
|
|
5957
|
+ LOOP_XYZ(i)
|
5959
|
5958
|
if (code_seen(axis_codes[i]))
|
5960
|
5959
|
axis_scaling[i] = code_value_float();
|
5961
|
5960
|
}
|
|
@@ -6155,7 +6154,7 @@ void quickstop_stepper() {
|
6155
|
6154
|
*/
|
6156
|
6155
|
inline void gcode_M428() {
|
6157
|
6156
|
bool err = false;
|
6158
|
|
- for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
|
|
6157
|
+ LOOP_XYZ(i) {
|
6159
|
6158
|
if (axis_homed[i]) {
|
6160
|
6159
|
float base = (current_position[i] > (sw_endstop_min[i] + sw_endstop_max[i]) / 2) ? base_home_pos(i) : 0,
|
6161
|
6160
|
diff = current_position[i] - LOGICAL_POSITION(base, i);
|
|
@@ -6285,7 +6284,7 @@ inline void gcode_M503() {
|
6285
|
6284
|
float lastpos[NUM_AXIS];
|
6286
|
6285
|
|
6287
|
6286
|
// Save current position of all axes
|
6288
|
|
- for (uint8_t i = 0; i < NUM_AXIS; i++)
|
|
6287
|
+ LOOP_XYZE(i)
|
6289
|
6288
|
lastpos[i] = destination[i] = current_position[i];
|
6290
|
6289
|
|
6291
|
6290
|
// Define runplan for move axes
|
|
@@ -6506,7 +6505,7 @@ inline void gcode_M503() {
|
6506
|
6505
|
*/
|
6507
|
6506
|
inline void gcode_M907() {
|
6508
|
6507
|
#if HAS_DIGIPOTSS
|
6509
|
|
- for (int i = 0; i < NUM_AXIS; i++)
|
|
6508
|
+ LOOP_XYZE(i)
|
6510
|
6509
|
if (code_seen(axis_codes[i])) stepper.digipot_current(i, code_value_int());
|
6511
|
6510
|
if (code_seen('B')) stepper.digipot_current(4, code_value_int());
|
6512
|
6511
|
if (code_seen('S')) for (int i = 0; i <= 4; i++) stepper.digipot_current(i, code_value_int());
|
|
@@ -6522,7 +6521,7 @@ inline void gcode_M907() {
|
6522
|
6521
|
#endif
|
6523
|
6522
|
#if ENABLED(DIGIPOT_I2C)
|
6524
|
6523
|
// this one uses actual amps in floating point
|
6525
|
|
- for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) digipot_i2c_set_current(i, code_value_float());
|
|
6524
|
+ LOOP_XYZE(i) if (code_seen(axis_codes[i])) digipot_i2c_set_current(i, code_value_float());
|
6526
|
6525
|
// for each additional extruder (named B,C,D,E..., channels 4,5,6,7...)
|
6527
|
6526
|
for (int i = NUM_AXIS; i < DIGIPOT_I2C_NUM_CHANNELS; i++) if (code_seen('B' + i - (NUM_AXIS))) digipot_i2c_set_current(i, code_value_float());
|
6528
|
6527
|
#endif
|
|
@@ -6531,7 +6530,7 @@ inline void gcode_M907() {
|
6531
|
6530
|
float dac_percent = code_value_float();
|
6532
|
6531
|
for (uint8_t i = 0; i <= 4; i++) dac_current_percent(i, dac_percent);
|
6533
|
6532
|
}
|
6534
|
|
- for (uint8_t i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) dac_current_percent(i, code_value_float());
|
|
6533
|
+ LOOP_XYZE(i) if (code_seen(axis_codes[i])) dac_current_percent(i, code_value_float());
|
6535
|
6534
|
#endif
|
6536
|
6535
|
}
|
6537
|
6536
|
|
|
@@ -6570,7 +6569,7 @@ inline void gcode_M907() {
|
6570
|
6569
|
// M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
|
6571
|
6570
|
inline void gcode_M350() {
|
6572
|
6571
|
if (code_seen('S')) for (int i = 0; i <= 4; i++) stepper.microstep_mode(i, code_value_byte());
|
6573
|
|
- for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_mode(i, code_value_byte());
|
|
6572
|
+ LOOP_XYZE(i) if (code_seen(axis_codes[i])) stepper.microstep_mode(i, code_value_byte());
|
6574
|
6573
|
if (code_seen('B')) stepper.microstep_mode(4, code_value_byte());
|
6575
|
6574
|
stepper.microstep_readings();
|
6576
|
6575
|
}
|
|
@@ -6582,11 +6581,11 @@ inline void gcode_M907() {
|
6582
|
6581
|
inline void gcode_M351() {
|
6583
|
6582
|
if (code_seen('S')) switch (code_value_byte()) {
|
6584
|
6583
|
case 1:
|
6585
|
|
- for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, code_value_byte(), -1);
|
|
6584
|
+ LOOP_XYZE(i) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, code_value_byte(), -1);
|
6586
|
6585
|
if (code_seen('B')) stepper.microstep_ms(4, code_value_byte(), -1);
|
6587
|
6586
|
break;
|
6588
|
6587
|
case 2:
|
6589
|
|
- for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, -1, code_value_byte());
|
|
6588
|
+ LOOP_XYZE(i) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, -1, code_value_byte());
|
6590
|
6589
|
if (code_seen('B')) stepper.microstep_ms(4, -1, code_value_byte());
|
6591
|
6590
|
break;
|
6592
|
6591
|
}
|
|
@@ -8013,7 +8012,7 @@ void mesh_line_to_destination(float fr_mm_m, uint8_t x_splits = 0xff, uint8_t y_
|
8013
|
8012
|
|
8014
|
8013
|
inline bool prepare_kinematic_move_to(float target[NUM_AXIS]) {
|
8015
|
8014
|
float difference[NUM_AXIS];
|
8016
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++) difference[i] = target[i] - current_position[i];
|
|
8015
|
+ LOOP_XYZE(i) difference[i] = target[i] - current_position[i];
|
8017
|
8016
|
|
8018
|
8017
|
float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
|
8019
|
8018
|
if (cartesian_mm < 0.000001) cartesian_mm = abs(difference[E_AXIS]);
|
|
@@ -8031,7 +8030,7 @@ void mesh_line_to_destination(float fr_mm_m, uint8_t x_splits = 0xff, uint8_t y_
|
8031
|
8030
|
|
8032
|
8031
|
float fraction = float(s) * inv_steps;
|
8033
|
8032
|
|
8034
|
|
- for (int8_t i = 0; i < NUM_AXIS; i++)
|
|
8033
|
+ LOOP_XYZE(i)
|
8035
|
8034
|
target[i] = current_position[i] + difference[i] * fraction;
|
8036
|
8035
|
|
8037
|
8036
|
inverse_kinematics(target);
|