|
|
@ -284,7 +284,7 @@ |
|
|
|
|
|
|
|
#if ENABLED(M100_FREE_MEMORY_WATCHER) |
|
|
|
void gcode_M100(); |
|
|
|
void M100_dump_routine( char *title, char *start, char *end); |
|
|
|
void M100_dump_routine(const char * const title, const char *start, const char *end); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(SDSUPPORT) |
|
|
@ -1091,7 +1091,7 @@ inline void get_serial_commands() { |
|
|
|
if (IsStopped()) { |
|
|
|
char* gpos = strchr(command, 'G'); |
|
|
|
if (gpos) { |
|
|
|
int codenum = strtol(gpos + 1, NULL, 10); |
|
|
|
const int codenum = strtol(gpos + 1, NULL, 10); |
|
|
|
switch (codenum) { |
|
|
|
case 0: |
|
|
|
case 1: |
|
|
@ -4167,17 +4167,25 @@ inline void gcode_G28() { |
|
|
|
#define ABL_VAR |
|
|
|
#endif |
|
|
|
|
|
|
|
ABL_VAR int verbose_level, abl_probe_index; |
|
|
|
ABL_VAR int verbose_level; |
|
|
|
ABL_VAR float xProbe, yProbe, measured_z; |
|
|
|
ABL_VAR bool dryrun, abl_should_enable; |
|
|
|
|
|
|
|
#if ENABLED(PROBE_MANUALLY) || ENABLED(AUTO_BED_LEVELING_LINEAR) |
|
|
|
ABL_VAR int abl_probe_index; |
|
|
|
#endif |
|
|
|
|
|
|
|
#if HAS_SOFTWARE_ENDSTOPS |
|
|
|
ABL_VAR bool enable_soft_endstops = true; |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ABL_GRID |
|
|
|
|
|
|
|
#if ENABLED(PROBE_MANUALLY) |
|
|
|
ABL_VAR uint8_t PR_OUTER_VAR; |
|
|
|
ABL_VAR int8_t PR_INNER_VAR; |
|
|
|
#endif |
|
|
|
|
|
|
|
ABL_VAR int left_probe_bed_position, right_probe_bed_position, front_probe_bed_position, back_probe_bed_position; |
|
|
|
ABL_VAR float xGridSpacing, yGridSpacing; |
|
|
|
|
|
|
@ -4186,14 +4194,19 @@ inline void gcode_G28() { |
|
|
|
#if ABL_PLANAR |
|
|
|
ABL_VAR uint8_t abl_grid_points_x = GRID_MAX_POINTS_X, |
|
|
|
abl_grid_points_y = GRID_MAX_POINTS_Y; |
|
|
|
ABL_VAR int abl2; |
|
|
|
ABL_VAR bool do_topography_map; |
|
|
|
#else // 3-point
|
|
|
|
uint8_t constexpr abl_grid_points_x = GRID_MAX_POINTS_X, |
|
|
|
abl_grid_points_y = GRID_MAX_POINTS_Y; |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(PROBE_MANUALLY) |
|
|
|
#if ABL_PLANAR |
|
|
|
ABL_VAR int abl2; |
|
|
|
#else // 3-point
|
|
|
|
int constexpr abl2 = ABL_GRID_MAX; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) |
|
|
|
|
|
|
@ -4224,7 +4237,10 @@ inline void gcode_G28() { |
|
|
|
*/ |
|
|
|
if (!g29_in_progress) { |
|
|
|
|
|
|
|
#if ENABLED(PROBE_MANUALLY) || ENABLED(AUTO_BED_LEVELING_LINEAR) |
|
|
|
abl_probe_index = 0; |
|
|
|
#endif |
|
|
|
|
|
|
|
abl_should_enable = planner.abl_enabled; |
|
|
|
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) |
|
|
@ -4284,7 +4300,7 @@ inline void gcode_G28() { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
dryrun = code_seen('D') ? code_value_bool() : false; |
|
|
|
dryrun = code_seen('D') && code_value_bool(); |
|
|
|
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR) |
|
|
|
|
|
|
@ -4455,7 +4471,7 @@ inline void gcode_G28() { |
|
|
|
g29_in_progress = true; |
|
|
|
|
|
|
|
if (abl_probe_index == 0) { |
|
|
|
// For the initial G29 S2 save software endstop state
|
|
|
|
// For the initial G29 save software endstop state
|
|
|
|
#if HAS_SOFTWARE_ENDSTOPS |
|
|
|
enable_soft_endstops = soft_endstops_enabled; |
|
|
|
#endif |
|
|
@ -4586,7 +4602,6 @@ inline void gcode_G28() { |
|
|
|
|
|
|
|
#else // !PROBE_MANUALLY
|
|
|
|
|
|
|
|
|
|
|
|
bool stow_probe_after_each = code_seen('E'); |
|
|
|
|
|
|
|
#if ABL_GRID |
|
|
@ -4927,14 +4942,12 @@ inline void gcode_G28() { |
|
|
|
* S = Stows the probe if 1 (default=1) |
|
|
|
*/ |
|
|
|
inline void gcode_G30() { |
|
|
|
float X_probe_location = code_seen('X') ? code_value_linear_units() : current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER, |
|
|
|
Y_probe_location = code_seen('Y') ? code_value_linear_units() : current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER; |
|
|
|
const float xpos = code_seen('X') ? code_value_linear_units() : current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER, |
|
|
|
ypos = code_seen('Y') ? code_value_linear_units() : current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER, |
|
|
|
pos[XYZ] = { xpos, ypos, LOGICAL_Z_POSITION(0) }; |
|
|
|
|
|
|
|
float pos[XYZ] = { X_probe_location, Y_probe_location, LOGICAL_Z_POSITION(0) }; |
|
|
|
if (!position_is_reachable(pos, true)) return; |
|
|
|
|
|
|
|
bool stow = code_seen('S') ? code_value_bool() : true; |
|
|
|
|
|
|
|
// Disable leveling so the planner won't mess with us
|
|
|
|
#if PLANNER_LEVELING |
|
|
|
set_bed_leveling_enabled(false); |
|
|
@ -4942,14 +4955,11 @@ inline void gcode_G28() { |
|
|
|
|
|
|
|
setup_for_endstop_or_probe_move(); |
|
|
|
|
|
|
|
float measured_z = probe_pt(X_probe_location, Y_probe_location, stow, 1); |
|
|
|
const float measured_z = probe_pt(xpos, ypos, !code_seen('S') || code_value_bool(), 1); |
|
|
|
|
|
|
|
SERIAL_PROTOCOLPGM("Bed X: "); |
|
|
|
SERIAL_PROTOCOL(FIXFLOAT(X_probe_location)); |
|
|
|
SERIAL_PROTOCOLPGM(" Y: "); |
|
|
|
SERIAL_PROTOCOL(FIXFLOAT(Y_probe_location)); |
|
|
|
SERIAL_PROTOCOLPGM(" Z: "); |
|
|
|
SERIAL_PROTOCOLLN(FIXFLOAT(measured_z)); |
|
|
|
SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos)); |
|
|
|
SERIAL_PROTOCOLPAIR(" Y: ", FIXFLOAT(ypos)); |
|
|
|
SERIAL_PROTOCOLLNPAIR(" Z: ", FIXFLOAT(measured_z)); |
|
|
|
|
|
|
|
clean_up_after_endstop_or_probe_move(); |
|
|
|
|
|
|
@ -5466,7 +5476,7 @@ inline void gcode_G92() { |
|
|
|
* M1: Conditional stop - Wait for user button press on LCD |
|
|
|
*/ |
|
|
|
inline void gcode_M0_M1() { |
|
|
|
char* args = current_command_args; |
|
|
|
const char * const args = current_command_args; |
|
|
|
|
|
|
|
millis_t codenum = 0; |
|
|
|
bool hasP = false, hasS = false; |
|
|
@ -5524,7 +5534,7 @@ inline void gcode_G92() { |
|
|
|
KEEPALIVE_STATE(IN_HANDLER); |
|
|
|
} |
|
|
|
|
|
|
|
#endif // EMERGENCY_PARSER || ULTIPANEL
|
|
|
|
#endif // HAS_RESUME_CONTINUE
|
|
|
|
|
|
|
|
/**
|
|
|
|
* M17: Enable power on all stepper motors |
|
|
@ -5806,24 +5816,21 @@ inline void gcode_M42() { |
|
|
|
#include "pinsDebug.h" |
|
|
|
|
|
|
|
inline void toggle_pins() { |
|
|
|
int pin, j; |
|
|
|
|
|
|
|
bool I_flag = code_seen('I') ? code_value_bool() : false; |
|
|
|
|
|
|
|
int repeat = code_seen('R') ? code_value_int() : 1, |
|
|
|
const bool I_flag = code_seen('I') && code_value_bool(); |
|
|
|
const int repeat = code_seen('R') ? code_value_int() : 1, |
|
|
|
start = code_seen('S') ? code_value_int() : 0, |
|
|
|
end = code_seen('E') ? code_value_int() : NUM_DIGITAL_PINS - 1, |
|
|
|
wait = code_seen('W') ? code_value_int() : 500; |
|
|
|
|
|
|
|
for (pin = start; pin <= end; pin++) { |
|
|
|
for (uint8_t pin = start; pin <= end; pin++) { |
|
|
|
if (!I_flag && pin_is_protected(pin)) { |
|
|
|
SERIAL_ECHOPAIR("Sensitive Pin: ", pin); |
|
|
|
SERIAL_ECHOPGM(" untouched.\n"); |
|
|
|
SERIAL_ECHOLNPGM(" untouched."); |
|
|
|
} |
|
|
|
else { |
|
|
|
SERIAL_ECHOPAIR("Pulsing Pin: ", pin); |
|
|
|
pinMode(pin, OUTPUT); |
|
|
|
for(j = 0; j < repeat; j++) { |
|
|
|
for (int16_t j = 0; j < repeat; j++) { |
|
|
|
digitalWrite(pin, 0); |
|
|
|
safe_delay(wait); |
|
|
|
digitalWrite(pin, 1); |
|
|
@ -5832,44 +5839,71 @@ inline void gcode_M42() { |
|
|
|
safe_delay(wait); |
|
|
|
} |
|
|
|
} |
|
|
|
SERIAL_ECHOPGM("\n"); |
|
|
|
SERIAL_CHAR('\n'); |
|
|
|
} |
|
|
|
SERIAL_ECHOPGM("Done\n"); |
|
|
|
SERIAL_ECHOLNPGM("Done."); |
|
|
|
|
|
|
|
} // toggle_pins
|
|
|
|
|
|
|
|
inline void servo_probe_test() { |
|
|
|
#if !(NUM_SERVOS >= 1 && HAS_SERVO_0) |
|
|
|
#if !(NUM_SERVOS > 0 && HAS_SERVO_0) |
|
|
|
|
|
|
|
SERIAL_ERROR_START; |
|
|
|
SERIAL_ERRORLNPGM("SERVO not setup"); |
|
|
|
|
|
|
|
#elif !HAS_Z_SERVO_ENDSTOP |
|
|
|
|
|
|
|
SERIAL_ERROR_START; |
|
|
|
SERIAL_ERRORLNPGM("Z_ENDSTOP_SERVO_NR not setup"); |
|
|
|
|
|
|
|
#else |
|
|
|
uint8_t probe_index = code_seen('P') ? code_value_byte() : Z_ENDSTOP_SERVO_NR; |
|
|
|
|
|
|
|
#if !defined(z_servo_angle) |
|
|
|
const int z_servo_angle[2] = Z_SERVO_ANGLES; |
|
|
|
#endif |
|
|
|
|
|
|
|
const uint8_t probe_index = code_seen('P') ? code_value_byte() : Z_ENDSTOP_SERVO_NR; |
|
|
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Servo probe test"); |
|
|
|
SERIAL_PROTOCOLLNPAIR(". using index: ", probe_index); |
|
|
|
SERIAL_PROTOCOLLNPAIR(". deploy angle: ", z_servo_angle[0]); |
|
|
|
SERIAL_PROTOCOLLNPAIR(". stow angle: ", z_servo_angle[1]); |
|
|
|
|
|
|
|
bool probe_inverting; |
|
|
|
|
|
|
|
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) |
|
|
|
|
|
|
|
#define PROBE_TEST_PIN Z_MIN_PIN |
|
|
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR(". probe uses Z_MIN pin: ", PROBE_TEST_PIN); |
|
|
|
SERIAL_PROTOCOLLNPGM(". uses Z_MIN_ENDSTOP_INVERTING (ignores Z_MIN_PROBE_ENDSTOP_INVERTING)"); |
|
|
|
SERIAL_PROTOCOLPGM(". Z_MIN_ENDSTOP_INVERTING: "); |
|
|
|
if (Z_MIN_ENDSTOP_INVERTING) SERIAL_PROTOCOLLNPGM("true"); |
|
|
|
else SERIAL_PROTOCOLLNPGM("false"); |
|
|
|
|
|
|
|
#if Z_MIN_ENDSTOP_INVERTING |
|
|
|
SERIAL_PROTOCOLLNPGM("true"); |
|
|
|
#else |
|
|
|
SERIAL_PROTOCOLLNPGM("false"); |
|
|
|
#endif |
|
|
|
|
|
|
|
probe_inverting = Z_MIN_ENDSTOP_INVERTING; |
|
|
|
|
|
|
|
#elif ENABLED(Z_MIN_PROBE_ENDSTOP) |
|
|
|
|
|
|
|
#define PROBE_TEST_PIN Z_MIN_PROBE_PIN |
|
|
|
SERIAL_PROTOCOLLNPAIR(". probe uses Z_MIN_PROBE_PIN: ", PROBE_TEST_PIN); |
|
|
|
SERIAL_PROTOCOLLNPGM(". uses Z_MIN_PROBE_ENDSTOP_INVERTING (ignores Z_MIN_ENDSTOP_INVERTING)"); |
|
|
|
SERIAL_PROTOCOLPGM(". Z_MIN_PROBE_ENDSTOP_INVERTING: "); |
|
|
|
if (Z_MIN_PROBE_ENDSTOP_INVERTING) SERIAL_PROTOCOLLNPGM("true"); |
|
|
|
else SERIAL_PROTOCOLLNPGM("false"); |
|
|
|
probe_inverting = Z_MIN_PROBE_ENDSTOP_INVERTING; |
|
|
|
|
|
|
|
#if Z_MIN_PROBE_ENDSTOP_INVERTING |
|
|
|
SERIAL_PROTOCOLLNPGM("true"); |
|
|
|
#else |
|
|
|
#error "ERROR - probe pin not defined - strange, SANITY_CHECK should have caught this" |
|
|
|
SERIAL_PROTOCOLLNPGM("false"); |
|
|
|
#endif |
|
|
|
|
|
|
|
probe_inverting = Z_MIN_PROBE_ENDSTOP_INVERTING; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
SERIAL_PROTOCOLLNPGM(". deploy & stow 4 times"); |
|
|
|
pinMode(PROBE_TEST_PIN, INPUT_PULLUP); |
|
|
|
bool deploy_state; |
|
|
@ -5883,7 +5917,9 @@ inline void gcode_M42() { |
|
|
|
stow_state = digitalRead(PROBE_TEST_PIN); |
|
|
|
} |
|
|
|
if (probe_inverting != deploy_state) SERIAL_PROTOCOLLNPGM("WARNING - INVERTING setting probably backwards"); |
|
|
|
|
|
|
|
refresh_cmd_timeout(); |
|
|
|
|
|
|
|
if (deploy_state != stow_state) { |
|
|
|
SERIAL_PROTOCOLLNPGM("BLTouch clone detected"); |
|
|
|
if (deploy_state) { |
|
|
@ -5904,28 +5940,39 @@ inline void gcode_M42() { |
|
|
|
safe_delay(500); |
|
|
|
SERIAL_PROTOCOLLNPGM("please trigger probe"); |
|
|
|
uint16_t probe_counter = 0; |
|
|
|
for (uint16_t j = 0; j < 500*30 && probe_counter == 0 ; j++) { // allow 30 seconds max for operator to trigger probe
|
|
|
|
|
|
|
|
// Allow 30 seconds max for operator to trigger probe
|
|
|
|
for (uint16_t j = 0; j < 500 * 30 && probe_counter == 0 ; j++) { |
|
|
|
|
|
|
|
safe_delay(2); |
|
|
|
if ( 0 == j%(500*1)) {refresh_cmd_timeout(); watchdog_reset();} // beat the dog every 45 seconds
|
|
|
|
|
|
|
|
if (0 == j % (500 * 1)) // keep cmd_timeout happy
|
|
|
|
refresh_cmd_timeout(); |
|
|
|
|
|
|
|
if (deploy_state != digitalRead(PROBE_TEST_PIN)) { // probe triggered
|
|
|
|
for (probe_counter = 1; probe_counter < 50 && (deploy_state != digitalRead(PROBE_TEST_PIN)); probe_counter ++) { |
|
|
|
|
|
|
|
for (probe_counter = 1; probe_counter < 50 && deploy_state != digitalRead(PROBE_TEST_PIN); ++probe_counter) |
|
|
|
safe_delay(2); |
|
|
|
} |
|
|
|
if (probe_counter == 50) { |
|
|
|
|
|
|
|
if (probe_counter == 50) |
|
|
|
SERIAL_PROTOCOLLNPGM("Z Servo Probe detected"); // >= 100mS active time
|
|
|
|
} |
|
|
|
else if (probe_counter >= 2 ) { |
|
|
|
else if (probe_counter >= 2) |
|
|
|
SERIAL_PROTOCOLLNPAIR("BLTouch compatible probe detected - pulse width (+/- 4mS): ", probe_counter * 2); // allow 4 - 100mS pulse
|
|
|
|
} |
|
|
|
else { |
|
|
|
else |
|
|
|
SERIAL_PROTOCOLLNPGM("noise detected - please re-run test"); // less than 2mS pulse
|
|
|
|
} |
|
|
|
|
|
|
|
servo[probe_index].move(z_servo_angle[1]); //stow
|
|
|
|
|
|
|
|
} // pulse detected
|
|
|
|
|
|
|
|
} // for loop waiting for trigger
|
|
|
|
|
|
|
|
if (probe_counter == 0) SERIAL_PROTOCOLLNPGM("trigger not detected"); |
|
|
|
|
|
|
|
} // measure active signal length
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} // servo_probe_test
|
|
|
|
|
|
|
|
/**
|
|
|
@ -5977,39 +6024,43 @@ inline void gcode_M42() { |
|
|
|
} |
|
|
|
|
|
|
|
// Get the range of pins to test or watch
|
|
|
|
int first_pin = 0, last_pin = NUM_DIGITAL_PINS - 1; |
|
|
|
if (code_seen('P')) { |
|
|
|
first_pin = last_pin = code_value_byte(); |
|
|
|
if (first_pin > NUM_DIGITAL_PINS - 1) return; |
|
|
|
} |
|
|
|
const uint8_t first_pin = code_seen('P') ? code_value_byte() : 0, |
|
|
|
last_pin = code_seen('P') ? first_pin : NUM_DIGITAL_PINS - 1; |
|
|
|
|
|
|
|
bool ignore_protection = code_seen('I') ? code_value_bool() : false; |
|
|
|
if (first_pin > last_pin) return; |
|
|
|
|
|
|
|
const bool ignore_protection = code_seen('I') && code_value_bool(); |
|
|
|
|
|
|
|
// Watch until click, M108, or reset
|
|
|
|
if (code_seen('W') && code_value_bool()) { // watch digital pins
|
|
|
|
if (code_seen('W') && code_value_bool()) { |
|
|
|
SERIAL_PROTOCOLLNPGM("Watching pins"); |
|
|
|
byte pin_state[last_pin - first_pin + 1]; |
|
|
|
for (int8_t pin = first_pin; pin <= last_pin; pin++) { |
|
|
|
if (pin_is_protected(pin) && !ignore_protection) continue; |
|
|
|
pinMode(pin, INPUT_PULLUP); |
|
|
|
// if (IS_ANALOG(pin))
|
|
|
|
// pin_state[pin - first_pin] = analogRead(pin - analogInputToDigitalPin(0)); // int16_t pin_state[...]
|
|
|
|
// else
|
|
|
|
/*
|
|
|
|
if (IS_ANALOG(pin)) |
|
|
|
pin_state[pin - first_pin] = analogRead(pin - analogInputToDigitalPin(0)); // int16_t pin_state[...]
|
|
|
|
else |
|
|
|
//*/
|
|
|
|
pin_state[pin - first_pin] = digitalRead(pin); |
|
|
|
} |
|
|
|
|
|
|
|
#if HAS_RESUME_CONTINUE |
|
|
|
wait_for_user = true; |
|
|
|
KEEPALIVE_STATE(PAUSED_FOR_USER); |
|
|
|
#endif |
|
|
|
|
|
|
|
for (;;) { |
|
|
|
for (int8_t pin = first_pin; pin <= last_pin; pin++) { |
|
|
|
if (pin_is_protected(pin)) continue; |
|
|
|
byte val; |
|
|
|
// if (IS_ANALOG(pin))
|
|
|
|
// val = analogRead(pin - analogInputToDigitalPin(0)); // int16_t val
|
|
|
|
// else
|
|
|
|
val = digitalRead(pin); |
|
|
|
const byte val = |
|
|
|
/*
|
|
|
|
IS_ANALOG(pin) |
|
|
|
? analogRead(pin - analogInputToDigitalPin(0)) : // int16_t val
|
|
|
|
: |
|
|
|
//*/
|
|
|
|
digitalRead(pin); |
|
|
|
if (val != pin_state[pin - first_pin]) { |
|
|
|
report_pin_state(pin); |
|
|
|
pin_state[pin - first_pin] = val; |
|
|
@ -6017,7 +6068,10 @@ inline void gcode_M42() { |
|
|
|
} |
|
|
|
|
|
|
|
#if HAS_RESUME_CONTINUE |
|
|
|
if (!wait_for_user) break; |
|
|
|
if (!wait_for_user) { |
|
|
|
KEEPALIVE_STATE(IN_HANDLER); |
|
|
|
break; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
safe_delay(500); |
|
|
@ -11170,15 +11224,16 @@ void prepare_move_to_destination() { |
|
|
|
uint8_t clockwise // Clockwise?
|
|
|
|
) { |
|
|
|
|
|
|
|
float radius = HYPOT(offset[X_AXIS], offset[Y_AXIS]), |
|
|
|
center_X = current_position[X_AXIS] + offset[X_AXIS], |
|
|
|
center_Y = current_position[Y_AXIS] + offset[Y_AXIS], |
|
|
|
linear_travel = logical[Z_AXIS] - current_position[Z_AXIS], |
|
|
|
extruder_travel = logical[E_AXIS] - current_position[E_AXIS], |
|
|
|
r_X = -offset[X_AXIS], // Radius vector from center to current location
|
|
|
|
r_Y = -offset[Y_AXIS], |
|
|
|
float r_X = -offset[X_AXIS], // Radius vector from center to current location
|
|
|
|
r_Y = -offset[Y_AXIS]; |
|
|
|
|
|
|
|
const float radius = HYPOT(r_X, r_Y), |
|
|
|
center_X = current_position[X_AXIS] - r_X, |
|
|
|
center_Y = current_position[Y_AXIS] - r_Y, |
|
|
|
rt_X = logical[X_AXIS] - center_X, |
|
|
|
rt_Y = logical[Y_AXIS] - center_Y; |
|
|
|
rt_Y = logical[Y_AXIS] - center_Y, |
|
|
|
linear_travel = logical[Z_AXIS] - current_position[Z_AXIS], |
|
|
|
extruder_travel = logical[E_AXIS] - current_position[E_AXIS]; |
|
|
|
|
|
|
|
// CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required.
|
|
|
|
float angular_travel = atan2(r_X * rt_Y - r_Y * rt_X, r_X * rt_X + r_Y * rt_Y); |
|
|
@ -11222,8 +11277,8 @@ void prepare_move_to_destination() { |
|
|
|
* This is important when there are successive arc motions. |
|
|
|
*/ |
|
|
|
// Vector rotation matrix values
|
|
|
|
float arc_target[XYZE], |
|
|
|
theta_per_segment = angular_travel / segments, |
|
|
|
float arc_target[XYZE]; |
|
|
|
const float theta_per_segment = angular_travel / segments, |
|
|
|
linear_per_segment = linear_travel / segments, |
|
|
|
extruder_per_segment = extruder_travel / segments, |
|
|
|
sin_T = theta_per_segment, |
|
|
@ -11235,7 +11290,7 @@ void prepare_move_to_destination() { |
|
|
|
// Initialize the extruder axis
|
|
|
|
arc_target[E_AXIS] = current_position[E_AXIS]; |
|
|
|
|
|
|
|
float fr_mm_s = MMS_SCALED(feedrate_mm_s); |
|
|
|
const float fr_mm_s = MMS_SCALED(feedrate_mm_s); |
|
|
|
|
|
|
|
millis_t next_idle_ms = millis() + 200UL; |
|
|
|
|
|
|
@ -11250,7 +11305,7 @@ void prepare_move_to_destination() { |
|
|
|
|
|
|
|
if (++count < N_ARC_CORRECTION) { |
|
|
|
// Apply vector rotation matrix to previous r_X / 1
|
|
|
|
float r_new_Y = r_X * sin_T + r_Y * cos_T; |
|
|
|
const float r_new_Y = r_X * sin_T + r_Y * cos_T; |
|
|
|
r_X = r_X * cos_T - r_Y * sin_T; |
|
|
|
r_Y = r_new_Y; |
|
|
|
} |
|
|
@ -11259,7 +11314,7 @@ void prepare_move_to_destination() { |
|
|
|
// Compute exact location by applying transformation matrix from initial radius vector(=-offset).
|
|
|
|
// To reduce stuttering, the sin and cos could be computed at different times.
|
|
|
|
// For now, compute both at the same time.
|
|
|
|
float cos_Ti = cos(i * theta_per_segment), |
|
|
|
const float cos_Ti = cos(i * theta_per_segment), |
|
|
|
sin_Ti = sin(i * theta_per_segment); |
|
|
|
r_X = -offset[X_AXIS] * cos_Ti + offset[Y_AXIS] * sin_Ti; |
|
|
|
r_Y = -offset[X_AXIS] * sin_Ti - offset[Y_AXIS] * cos_Ti; |
|
|
@ -11774,30 +11829,15 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { |
|
|
|
enable_E0(); |
|
|
|
#else // !SWITCHING_EXTRUDER
|
|
|
|
switch (active_extruder) { |
|
|
|
case 0: |
|
|
|
oldstatus = E0_ENABLE_READ; |
|
|
|
enable_E0(); |
|
|
|
break; |
|
|
|
case 0: oldstatus = E0_ENABLE_READ; enable_E0(); break; |
|
|
|
#if E_STEPPERS > 1 |
|
|
|
case 1: |
|
|
|
oldstatus = E1_ENABLE_READ; |
|
|
|
enable_E1(); |
|
|
|
break; |
|
|
|
case 1: oldstatus = E1_ENABLE_READ; enable_E1(); break; |
|
|
|
#if E_STEPPERS > 2 |
|
|
|
case 2: |
|
|
|
oldstatus = E2_ENABLE_READ; |
|
|
|
enable_E2(); |
|
|
|
break; |
|
|
|
case 2: oldstatus = E2_ENABLE_READ; enable_E2(); break; |
|
|
|
#if E_STEPPERS > 3 |
|
|
|
case 3: |
|
|
|
oldstatus = E3_ENABLE_READ; |
|
|
|
enable_E3(); |
|
|
|
break; |
|
|
|
case 3: oldstatus = E3_ENABLE_READ; enable_E3(); break; |
|
|
|
#if E_STEPPERS > 4 |
|
|
|
case 4: |
|
|
|
oldstatus = E4_ENABLE_READ; |
|
|
|
enable_E4(); |
|
|
|
break; |
|
|
|
case 4: oldstatus = E4_ENABLE_READ; enable_E4(); break; |
|
|
|
#endif // E_STEPPERS > 4
|
|
|
|
#endif // E_STEPPERS > 3
|
|
|
|
#endif // E_STEPPERS > 2
|
|
|
@ -11817,25 +11857,15 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { |
|
|
|
E0_ENABLE_WRITE(oldstatus); |
|
|
|
#else |
|
|
|
switch (active_extruder) { |
|
|
|
case 0: |
|
|
|
E0_ENABLE_WRITE(oldstatus); |
|
|
|
break; |
|
|
|
case 0: E0_ENABLE_WRITE(oldstatus); break; |
|
|
|
#if E_STEPPERS > 1 |
|
|
|
case 1: |
|
|
|
E1_ENABLE_WRITE(oldstatus); |
|
|
|
break; |
|
|
|
case 1: E1_ENABLE_WRITE(oldstatus); break; |
|
|
|
#if E_STEPPERS > 2 |
|
|
|
case 2: |
|
|
|
E2_ENABLE_WRITE(oldstatus); |
|
|
|
break; |
|
|
|
case 2: E2_ENABLE_WRITE(oldstatus); break; |
|
|
|
#if E_STEPPERS > 3 |
|
|
|
case 3: |
|
|
|
E3_ENABLE_WRITE(oldstatus); |
|
|
|
break; |
|
|
|
case 3: E3_ENABLE_WRITE(oldstatus); break; |
|
|
|
#if E_STEPPERS > 4 |
|
|
|
case 4: |
|
|
|
E4_ENABLE_WRITE(oldstatus); |
|
|
|
break; |
|
|
|
case 4: E4_ENABLE_WRITE(oldstatus); break; |
|
|
|
#endif // E_STEPPERS > 4
|
|
|
|
#endif // E_STEPPERS > 3
|
|
|
|
#endif // E_STEPPERS > 2
|
|
|
|