|
|
@ -1524,8 +1524,7 @@ static void set_axis_is_at_home(AxisEnum axis) {
|
|
|
|
if (axis == X_AXIS || axis == Y_AXIS) {
|
|
|
|
if (axis == X_AXIS || axis == Y_AXIS) {
|
|
|
|
|
|
|
|
|
|
|
|
float homeposition[3];
|
|
|
|
float homeposition[3];
|
|
|
|
for (uint8_t i = X_AXIS; i <= Z_AXIS; i++)
|
|
|
|
LOOP_XYZ(i) homeposition[i] = LOGICAL_POSITION(base_home_pos(i), i);
|
|
|
|
homeposition[i] = LOGICAL_POSITION(base_home_pos(i), i);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]);
|
|
|
|
// SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]);
|
|
|
|
// SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]);
|
|
|
|
// SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]);
|
|
|
@ -2597,7 +2596,7 @@ static void homeaxis(AxisEnum axis) {
|
|
|
|
* - Set the feedrate, if included
|
|
|
|
* - Set the feedrate, if included
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void gcode_get_destination() {
|
|
|
|
void gcode_get_destination() {
|
|
|
|
for (int i = 0; i < NUM_AXIS; i++) {
|
|
|
|
LOOP_XYZE(i) {
|
|
|
|
if (code_seen(axis_codes[i]))
|
|
|
|
if (code_seen(axis_codes[i]))
|
|
|
|
destination[i] = code_value_axis_units(i) + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0);
|
|
|
|
destination[i] = code_value_axis_units(i) + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0);
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -3900,7 +3899,7 @@ inline void gcode_G92() {
|
|
|
|
if (!didE) stepper.synchronize();
|
|
|
|
if (!didE) stepper.synchronize();
|
|
|
|
|
|
|
|
|
|
|
|
bool didXYZ = false;
|
|
|
|
bool didXYZ = false;
|
|
|
|
for (int i = 0; i < NUM_AXIS; i++) {
|
|
|
|
LOOP_XYZE(i) {
|
|
|
|
if (code_seen(axis_codes[i])) {
|
|
|
|
if (code_seen(axis_codes[i])) {
|
|
|
|
float p = current_position[i],
|
|
|
|
float p = current_position[i],
|
|
|
|
v = code_value_axis_units(i);
|
|
|
|
v = code_value_axis_units(i);
|
|
|
@ -5147,7 +5146,7 @@ inline void gcode_M85() {
|
|
|
|
* (Follows the same syntax as G92)
|
|
|
|
* (Follows the same syntax as G92)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
inline void gcode_M92() {
|
|
|
|
inline void gcode_M92() {
|
|
|
|
for (int8_t i = 0; i < NUM_AXIS; i++) {
|
|
|
|
LOOP_XYZE(i) {
|
|
|
|
if (code_seen(axis_codes[i])) {
|
|
|
|
if (code_seen(axis_codes[i])) {
|
|
|
|
if (i == E_AXIS) {
|
|
|
|
if (i == E_AXIS) {
|
|
|
|
float value = code_value_per_axis_unit(i);
|
|
|
|
float value = code_value_per_axis_unit(i);
|
|
|
@ -5339,7 +5338,7 @@ inline void gcode_M200() {
|
|
|
|
* M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
|
|
|
|
* M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
inline void gcode_M201() {
|
|
|
|
inline void gcode_M201() {
|
|
|
|
for (int8_t i = 0; i < NUM_AXIS; i++) {
|
|
|
|
LOOP_XYZE(i) {
|
|
|
|
if (code_seen(axis_codes[i])) {
|
|
|
|
if (code_seen(axis_codes[i])) {
|
|
|
|
planner.max_acceleration_mm_per_s2[i] = code_value_axis_units(i);
|
|
|
|
planner.max_acceleration_mm_per_s2[i] = code_value_axis_units(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -5350,7 +5349,7 @@ inline void gcode_M201() {
|
|
|
|
|
|
|
|
|
|
|
|
#if 0 // Not used for Sprinter/grbl gen6
|
|
|
|
#if 0 // Not used for Sprinter/grbl gen6
|
|
|
|
inline void gcode_M202() {
|
|
|
|
inline void gcode_M202() {
|
|
|
|
for (int8_t i = 0; i < NUM_AXIS; i++) {
|
|
|
|
LOOP_XYZE(i) {
|
|
|
|
if (code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value_axis_units(i) * planner.axis_steps_per_mm[i];
|
|
|
|
if (code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value_axis_units(i) * planner.axis_steps_per_mm[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -5361,7 +5360,7 @@ inline void gcode_M201() {
|
|
|
|
* M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
|
|
|
|
* M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
inline void gcode_M203() {
|
|
|
|
inline void gcode_M203() {
|
|
|
|
for (int8_t i = 0; i < NUM_AXIS; i++)
|
|
|
|
LOOP_XYZE(i)
|
|
|
|
if (code_seen(axis_codes[i]))
|
|
|
|
if (code_seen(axis_codes[i]))
|
|
|
|
planner.max_feedrate_mm_s[i] = code_value_axis_units(i);
|
|
|
|
planner.max_feedrate_mm_s[i] = code_value_axis_units(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -5421,7 +5420,7 @@ inline void gcode_M205() {
|
|
|
|
* M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
|
|
|
|
* M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
inline void gcode_M206() {
|
|
|
|
inline void gcode_M206() {
|
|
|
|
for (int8_t i = X_AXIS; i <= Z_AXIS; i++)
|
|
|
|
LOOP_XYZ(i)
|
|
|
|
if (code_seen(axis_codes[i]))
|
|
|
|
if (code_seen(axis_codes[i]))
|
|
|
|
set_home_offset((AxisEnum)i, code_value_axis_units(i));
|
|
|
|
set_home_offset((AxisEnum)i, code_value_axis_units(i));
|
|
|
|
|
|
|
|
|
|
|
@ -5463,7 +5462,7 @@ inline void gcode_M206() {
|
|
|
|
SERIAL_ECHOLNPGM(">>> gcode_M666");
|
|
|
|
SERIAL_ECHOLNPGM(">>> gcode_M666");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
|
|
|
|
LOOP_XYZ(i) {
|
|
|
|
if (code_seen(axis_codes[i])) {
|
|
|
|
if (code_seen(axis_codes[i])) {
|
|
|
|
endstop_adj[i] = code_value_axis_units(i);
|
|
|
|
endstop_adj[i] = code_value_axis_units(i);
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
@ -5955,7 +5954,7 @@ inline void gcode_M303() {
|
|
|
|
* M365: SCARA calibration: Scaling factor, X, Y, Z axis
|
|
|
|
* M365: SCARA calibration: Scaling factor, X, Y, Z axis
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
inline void gcode_M365() {
|
|
|
|
inline void gcode_M365() {
|
|
|
|
for (int8_t i = X_AXIS; i <= Z_AXIS; i++)
|
|
|
|
LOOP_XYZ(i)
|
|
|
|
if (code_seen(axis_codes[i]))
|
|
|
|
if (code_seen(axis_codes[i]))
|
|
|
|
axis_scaling[i] = code_value_float();
|
|
|
|
axis_scaling[i] = code_value_float();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -6155,7 +6154,7 @@ void quickstop_stepper() {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
inline void gcode_M428() {
|
|
|
|
inline void gcode_M428() {
|
|
|
|
bool err = false;
|
|
|
|
bool err = false;
|
|
|
|
for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
|
|
|
|
LOOP_XYZ(i) {
|
|
|
|
if (axis_homed[i]) {
|
|
|
|
if (axis_homed[i]) {
|
|
|
|
float base = (current_position[i] > (sw_endstop_min[i] + sw_endstop_max[i]) / 2) ? base_home_pos(i) : 0,
|
|
|
|
float base = (current_position[i] > (sw_endstop_min[i] + sw_endstop_max[i]) / 2) ? base_home_pos(i) : 0,
|
|
|
|
diff = current_position[i] - LOGICAL_POSITION(base, i);
|
|
|
|
diff = current_position[i] - LOGICAL_POSITION(base, i);
|
|
|
@ -6285,7 +6284,7 @@ inline void gcode_M503() {
|
|
|
|
float lastpos[NUM_AXIS];
|
|
|
|
float lastpos[NUM_AXIS];
|
|
|
|
|
|
|
|
|
|
|
|
// Save current position of all axes
|
|
|
|
// Save current position of all axes
|
|
|
|
for (uint8_t i = 0; i < NUM_AXIS; i++)
|
|
|
|
LOOP_XYZE(i)
|
|
|
|
lastpos[i] = destination[i] = current_position[i];
|
|
|
|
lastpos[i] = destination[i] = current_position[i];
|
|
|
|
|
|
|
|
|
|
|
|
// Define runplan for move axes
|
|
|
|
// Define runplan for move axes
|
|
|
@ -6506,7 +6505,7 @@ inline void gcode_M503() {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
inline void gcode_M907() {
|
|
|
|
inline void gcode_M907() {
|
|
|
|
#if HAS_DIGIPOTSS
|
|
|
|
#if HAS_DIGIPOTSS
|
|
|
|
for (int i = 0; i < NUM_AXIS; i++)
|
|
|
|
LOOP_XYZE(i)
|
|
|
|
if (code_seen(axis_codes[i])) stepper.digipot_current(i, code_value_int());
|
|
|
|
if (code_seen(axis_codes[i])) stepper.digipot_current(i, code_value_int());
|
|
|
|
if (code_seen('B')) stepper.digipot_current(4, code_value_int());
|
|
|
|
if (code_seen('B')) stepper.digipot_current(4, code_value_int());
|
|
|
|
if (code_seen('S')) for (int i = 0; i <= 4; i++) stepper.digipot_current(i, code_value_int());
|
|
|
|
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() {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if ENABLED(DIGIPOT_I2C)
|
|
|
|
#if ENABLED(DIGIPOT_I2C)
|
|
|
|
// this one uses actual amps in floating point
|
|
|
|
// this one uses actual amps in floating point
|
|
|
|
for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) digipot_i2c_set_current(i, code_value_float());
|
|
|
|
LOOP_XYZE(i) if (code_seen(axis_codes[i])) digipot_i2c_set_current(i, code_value_float());
|
|
|
|
// for each additional extruder (named B,C,D,E..., channels 4,5,6,7...)
|
|
|
|
// for each additional extruder (named B,C,D,E..., channels 4,5,6,7...)
|
|
|
|
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());
|
|
|
|
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());
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -6531,7 +6530,7 @@ inline void gcode_M907() {
|
|
|
|
float dac_percent = code_value_float();
|
|
|
|
float dac_percent = code_value_float();
|
|
|
|
for (uint8_t i = 0; i <= 4; i++) dac_current_percent(i, dac_percent);
|
|
|
|
for (uint8_t i = 0; i <= 4; i++) dac_current_percent(i, dac_percent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (uint8_t i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) dac_current_percent(i, code_value_float());
|
|
|
|
LOOP_XYZE(i) if (code_seen(axis_codes[i])) dac_current_percent(i, code_value_float());
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -6570,7 +6569,7 @@ inline void gcode_M907() {
|
|
|
|
// M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
|
|
|
|
// M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
|
|
|
|
inline void gcode_M350() {
|
|
|
|
inline void gcode_M350() {
|
|
|
|
if (code_seen('S')) for (int i = 0; i <= 4; i++) stepper.microstep_mode(i, code_value_byte());
|
|
|
|
if (code_seen('S')) for (int i = 0; i <= 4; i++) stepper.microstep_mode(i, code_value_byte());
|
|
|
|
for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_mode(i, code_value_byte());
|
|
|
|
LOOP_XYZE(i) if (code_seen(axis_codes[i])) stepper.microstep_mode(i, code_value_byte());
|
|
|
|
if (code_seen('B')) stepper.microstep_mode(4, code_value_byte());
|
|
|
|
if (code_seen('B')) stepper.microstep_mode(4, code_value_byte());
|
|
|
|
stepper.microstep_readings();
|
|
|
|
stepper.microstep_readings();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -6582,11 +6581,11 @@ inline void gcode_M907() {
|
|
|
|
inline void gcode_M351() {
|
|
|
|
inline void gcode_M351() {
|
|
|
|
if (code_seen('S')) switch (code_value_byte()) {
|
|
|
|
if (code_seen('S')) switch (code_value_byte()) {
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, code_value_byte(), -1);
|
|
|
|
LOOP_XYZE(i) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, code_value_byte(), -1);
|
|
|
|
if (code_seen('B')) stepper.microstep_ms(4, code_value_byte(), -1);
|
|
|
|
if (code_seen('B')) stepper.microstep_ms(4, code_value_byte(), -1);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, -1, code_value_byte());
|
|
|
|
LOOP_XYZE(i) if (code_seen(axis_codes[i])) stepper.microstep_ms(i, -1, code_value_byte());
|
|
|
|
if (code_seen('B')) stepper.microstep_ms(4, -1, code_value_byte());
|
|
|
|
if (code_seen('B')) stepper.microstep_ms(4, -1, code_value_byte());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -8013,7 +8012,7 @@ void mesh_line_to_destination(float fr_mm_m, uint8_t x_splits = 0xff, uint8_t y_
|
|
|
|
|
|
|
|
|
|
|
|
inline bool prepare_kinematic_move_to(float target[NUM_AXIS]) {
|
|
|
|
inline bool prepare_kinematic_move_to(float target[NUM_AXIS]) {
|
|
|
|
float difference[NUM_AXIS];
|
|
|
|
float difference[NUM_AXIS];
|
|
|
|
for (int8_t i = 0; i < NUM_AXIS; i++) difference[i] = target[i] - current_position[i];
|
|
|
|
LOOP_XYZE(i) difference[i] = target[i] - current_position[i];
|
|
|
|
|
|
|
|
|
|
|
|
float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
|
|
|
|
float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
|
|
|
|
if (cartesian_mm < 0.000001) cartesian_mm = abs(difference[E_AXIS]);
|
|
|
|
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_
|
|
|
|
|
|
|
|
|
|
|
|
float fraction = float(s) * inv_steps;
|
|
|
|
float fraction = float(s) * inv_steps;
|
|
|
|
|
|
|
|
|
|
|
|
for (int8_t i = 0; i < NUM_AXIS; i++)
|
|
|
|
LOOP_XYZE(i)
|
|
|
|
target[i] = current_position[i] + difference[i] * fraction;
|
|
|
|
target[i] = current_position[i] + difference[i] * fraction;
|
|
|
|
|
|
|
|
|
|
|
|
inverse_kinematics(target);
|
|
|
|
inverse_kinematics(target);
|
|
|
|