♻️Code optimization
This commit is contained in:
parent
792bab9bbb
commit
fd1d05ab48
|
|
@ -310,9 +310,9 @@ extern int8_t lcd_change_fil_state;
|
||||||
extern float default_retraction;
|
extern float default_retraction;
|
||||||
|
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
bool homeaxis(int axis, bool doError = true, uint8_t cnt = 1, uint8_t* pstep = 0);
|
void homeaxis(int axis, uint8_t cnt = 1, uint8_t* pstep = 0);
|
||||||
#else
|
#else
|
||||||
bool homeaxis(int axis, bool doError = true, uint8_t cnt = 1);
|
void homeaxis(int axis, uint8_t cnt = 1);
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2197,9 +2197,24 @@ bool calibrate_z_auto()
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
|
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
bool homeaxis(int axis, bool doError, uint8_t cnt, uint8_t* pstep)
|
static void check_Z_crash(void)
|
||||||
|
{
|
||||||
|
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash
|
||||||
|
FORCE_HIGH_POWER_END;
|
||||||
|
current_position[Z_AXIS] = 0;
|
||||||
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||||
|
current_position[Z_AXIS] += MESH_HOME_Z_SEARCH;
|
||||||
|
plan_buffer_line_curposXYZE(max_feedrate[Z_AXIS], active_extruder);
|
||||||
|
st_synchronize();
|
||||||
|
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif //TMC2130
|
||||||
|
|
||||||
|
#ifdef TMC2130
|
||||||
|
void homeaxis(int axis, uint8_t cnt, uint8_t* pstep)
|
||||||
#else
|
#else
|
||||||
bool homeaxis(int axis, bool doError, uint8_t cnt)
|
void homeaxis(int axis, uint8_t cnt)
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
{
|
{
|
||||||
bool endstops_enabled = enable_endstops(true); //RP: endstops should be allways enabled durring homing
|
bool endstops_enabled = enable_endstops(true); //RP: endstops should be allways enabled durring homing
|
||||||
|
|
@ -2312,21 +2327,7 @@ bool homeaxis(int axis, bool doError, uint8_t cnt)
|
||||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash
|
check_Z_crash();
|
||||||
FORCE_HIGH_POWER_END;
|
|
||||||
if (doError)
|
|
||||||
{
|
|
||||||
current_position[Z_AXIS] = 0;
|
|
||||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
||||||
current_position[Z_AXIS] += MESH_HOME_Z_SEARCH;
|
|
||||||
plan_buffer_line_curposXYZE(max_feedrate[Z_AXIS], active_extruder);
|
|
||||||
st_synchronize();
|
|
||||||
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
|
|
||||||
}
|
|
||||||
current_position[Z_AXIS] = -MESH_HOME_Z_SEARCH; //assume that nozzle crashed into bed
|
|
||||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
current_position[axis] = 0;
|
current_position[axis] = 0;
|
||||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||||
|
|
@ -2338,21 +2339,7 @@ bool homeaxis(int axis, bool doError, uint8_t cnt)
|
||||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash
|
check_Z_crash();
|
||||||
FORCE_HIGH_POWER_END;
|
|
||||||
if (doError)
|
|
||||||
{
|
|
||||||
current_position[Z_AXIS] = 0;
|
|
||||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
||||||
current_position[Z_AXIS] += MESH_HOME_Z_SEARCH;
|
|
||||||
plan_buffer_line_curposXYZE(max_feedrate[Z_AXIS], active_extruder);
|
|
||||||
st_synchronize();
|
|
||||||
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
|
|
||||||
}
|
|
||||||
current_position[Z_AXIS] = -MESH_HOME_Z_SEARCH; //assume that nozzle crashed into bed
|
|
||||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
axis_is_at_home(axis);
|
axis_is_at_home(axis);
|
||||||
destination[axis] = current_position[axis];
|
destination[axis] = current_position[axis];
|
||||||
|
|
@ -2364,7 +2351,6 @@ bool homeaxis(int axis, bool doError, uint8_t cnt)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
enable_endstops(endstops_enabled);
|
enable_endstops(endstops_enabled);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
|
||||||
|
|
@ -994,7 +994,7 @@ bool tmc2130_home_calibrate(uint8_t axis)
|
||||||
uint8_t step[16];
|
uint8_t step[16];
|
||||||
uint8_t cnt[16];
|
uint8_t cnt[16];
|
||||||
uint8_t val[16];
|
uint8_t val[16];
|
||||||
homeaxis(axis, true, 16, step);
|
homeaxis(axis, 16, step);
|
||||||
bubblesort_uint8(step, 16, 0);
|
bubblesort_uint8(step, 16, 0);
|
||||||
printf_P(PSTR("sorted samples:\n"));
|
printf_P(PSTR("sorted samples:\n"));
|
||||||
for (uint8_t i = 0; i < 16; i++)
|
for (uint8_t i = 0; i < 16; i++)
|
||||||
|
|
|
||||||
|
|
@ -7734,7 +7734,7 @@ bool lcd_selftest()
|
||||||
set_destination_to_current();
|
set_destination_to_current();
|
||||||
_progress = lcd_selftest_screen(TestScreen::AxisZ, _progress, 3, true, 1500);
|
_progress = lcd_selftest_screen(TestScreen::AxisZ, _progress, 3, true, 1500);
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
_result = homeaxis(Z_AXIS, false);
|
homeaxis(Z_AXIS); //In case of failure, the code gets stuck in this function.
|
||||||
#else
|
#else
|
||||||
_result = lcd_selfcheck_axis(Z_AXIS, Z_MAX_POS);
|
_result = lcd_selfcheck_axis(Z_AXIS, Z_MAX_POS);
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue