Remove saved_feedmultiply global variable.

This commit is contained in:
Marek Bel 2018-09-06 11:30:06 +02:00
parent b43c8dad74
commit 40990c4deb

View file

@ -306,7 +306,6 @@ float homing_feedrate[] = HOMING_FEEDRATE;
// Other axes are always absolute or relative based on the common relative_mode flag.
bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
int feedmultiply=100; //100->1 200->2
int saved_feedmultiply;
int extrudemultiply=100; //100->1 200->2
int extruder_multiply[EXTRUDERS] = {100
#if EXTRUDERS > 1
@ -2009,23 +2008,24 @@ static void axis_is_at_home(int axis) {
inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); }
inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); }
static void setup_for_endstop_move(bool enable_endstops_now = true) {
//! @return original feedmultiply
static int setup_for_endstop_move(bool enable_endstops_now = true) {
saved_feedrate = feedrate;
saved_feedmultiply = feedmultiply;
int l_feedmultiply = feedmultiply;
feedmultiply = 100;
previous_millis_cmd = millis();
enable_endstops(enable_endstops_now);
return l_feedmultiply;
}
static void clean_up_after_endstop_move() {
static void clean_up_after_endstop_move(int original_feedmultiply) {
#ifdef ENDSTOPS_ONLY_FOR_HOMING
enable_endstops(false);
#endif
feedrate = saved_feedrate;
feedmultiply = saved_feedmultiply;
feedmultiply = original_feedmultiply;
previous_millis_cmd = millis();
}
@ -2610,7 +2610,7 @@ void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_
babystep_undo();
saved_feedrate = feedrate;
saved_feedmultiply = feedmultiply;
int l_feedmultiply = feedmultiply;
feedmultiply = 100;
previous_millis_cmd = millis();
@ -2796,7 +2796,7 @@ void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_
#endif
feedrate = saved_feedrate;
feedmultiply = saved_feedmultiply;
feedmultiply = l_feedmultiply;
previous_millis_cmd = millis();
endstops_hit_on_purpose();
#ifndef MESH_BED_LEVELING
@ -2876,7 +2876,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
// Home in the XY plane.
//set_destination_to_current();
setup_for_endstop_move();
int l_feedmultiply = setup_for_endstop_move();
lcd_display_message_fullscreen_P(_T(MSG_AUTO_HOME));
home_xy();
@ -2936,7 +2936,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
{
if (onlyZ)
{
clean_up_after_endstop_move();
clean_up_after_endstop_move(l_feedmultiply);
// Z only calibration.
// Load the machine correction matrix
world2machine_initialize();
@ -2961,7 +2961,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
// Complete XYZ calibration.
uint8_t point_too_far_mask = 0;
BedSkewOffsetDetectionResultType result = find_bed_offset_and_skew(verbosity_level, point_too_far_mask);
clean_up_after_endstop_move();
clean_up_after_endstop_move(l_feedmultiply);
// Print head up.
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder);
@ -2978,10 +2978,10 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
mbl.reset();
world2machine_reset();
// Home in the XY plane.
setup_for_endstop_move();
int l_feedmultiply = setup_for_endstop_move();
home_xy();
result = improve_bed_offset_and_skew(1, verbosity_level, point_too_far_mask);
clean_up_after_endstop_move();
clean_up_after_endstop_move(l_feedmultiply);
// Print head up.
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder);
@ -3824,7 +3824,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
current_position[Y_AXIS] = uncorrected_position.y;
current_position[Z_AXIS] = uncorrected_position.z;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
setup_for_endstop_move();
int l_feedmultiply = setup_for_endstop_move();
feedrate = homing_feedrate[Z_AXIS];
#ifdef AUTO_BED_LEVELING_GRID
@ -3890,7 +3890,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
xProbe += xInc;
}
}
clean_up_after_endstop_move();
clean_up_after_endstop_move(l_feedmultiply);
// solve lsq problem
double *plane_equation_coefficients = qr_solve(AUTO_BED_LEVELING_GRID_POINTS*AUTO_BED_LEVELING_GRID_POINTS, 3, eqnAMatrix, eqnBVector);
@ -3919,7 +3919,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
// probe 3
float z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
clean_up_after_endstop_move();
clean_up_after_endstop_move(l_feedmultiply);
set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
@ -3945,7 +3945,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
{
st_synchronize();
// TODO: make sure the bed_level_rotation_matrix is identity or the planner will get set incorectly
setup_for_endstop_move();
int l_feedmultiply = setup_for_endstop_move();
feedrate = homing_feedrate[Z_AXIS];
@ -3959,7 +3959,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
SERIAL_PROTOCOL(current_position[Z_AXIS]);
SERIAL_PROTOCOLPGM("\n");
clean_up_after_endstop_move();
clean_up_after_endstop_move(l_feedmultiply);
}
break;
#else
@ -3977,7 +3977,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
{
st_synchronize();
// TODO: make sure the bed_level_rotation_matrix is identity or the planner will get set incorectly
setup_for_endstop_move();
int l_feedmultiply = setup_for_endstop_move();
feedrate = homing_feedrate[Z_AXIS];
@ -3985,7 +3985,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
printf_P(_N("%S X: %.5f Y: %.5f Z: %.5f\n"), _T(MSG_BED), _x, _y, _z);
clean_up_after_endstop_move();
clean_up_after_endstop_move(l_feedmultiply);
}
break;
@ -4410,7 +4410,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
has_z ? SERIAL_PROTOCOLPGM("Z jitter data from Z cal. valid.\n") : SERIAL_PROTOCOLPGM("Z jitter data from Z cal. not valid.\n");
}
#endif // SUPPORT_VERBOSITY
setup_for_endstop_move(false); //save feedrate and feedmultiply, sets feedmultiply to 100
int l_feedmultiply = setup_for_endstop_move(false); //save feedrate and feedmultiply, sets feedmultiply to 100
const char *kill_message = NULL;
while (mesh_point != MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) {
// Get coords of a measuring point.
@ -4517,7 +4517,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
kill(kill_message);
SERIAL_ECHOLNPGM("killed");
}
clean_up_after_endstop_move();
clean_up_after_endstop_move(l_feedmultiply);
// SERIAL_ECHOLNPGM("clean up finished ");
bool apply_temp_comp = true;
@ -4641,9 +4641,9 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
*/
case 82:
SERIAL_PROTOCOLLNPGM("Finding bed ");
setup_for_endstop_move();
int l_feedmultiply = setup_for_endstop_move();
find_bed_induction_sensor_point_z();
clean_up_after_endstop_move();
clean_up_after_endstop_move(l_feedmultiply);
SERIAL_PROTOCOLPGM("Bed found at: ");
SERIAL_PROTOCOL_F(current_position[Z_AXIS], 5);
SERIAL_PROTOCOLPGM("\n");
@ -5070,7 +5070,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
st_synchronize();
// Home in the XY plane.
set_destination_to_current();
setup_for_endstop_move();
int l_feedmultiply = setup_for_endstop_move();
home_xy();
int8_t verbosity_level = 0;
if (code_seen('V')) {
@ -5079,7 +5079,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
verbosity_level = (c == ' ' || c == '\t' || c == 0) ? 1 : code_value_short();
}
bool success = scan_bed_induction_points(verbosity_level);
clean_up_after_endstop_move();
clean_up_after_endstop_move(l_feedmultiply);
// Print head up.
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS],current_position[Z_AXIS] , current_position[E_AXIS], homing_feedrate[Z_AXIS]/40, active_extruder);
@ -5209,7 +5209,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
// Then retrace the right amount and use that in subsequent probes
//
setup_for_endstop_move();
int l_feedmultiply = setup_for_endstop_move();
run_z_probe();
current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
@ -5273,7 +5273,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
do_blocking_move_to( X_probe_location, Y_probe_location, Z_start_location); // Go back to the probe location
}
setup_for_endstop_move();
int l_feedmultiply = setup_for_endstop_move();
run_z_probe();
sample_set[n] = current_position[Z_AXIS];
@ -5324,9 +5324,9 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
delay(1000);
clean_up_after_endstop_move();
clean_up_after_endstop_move(l_feedmultiply);
// enable_endstops(true);
// enable_endstops(true);
if (verbose_level > 0) {
SERIAL_PROTOCOLPGM("Mean: ");
@ -7850,7 +7850,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_
int XY_AXIS_FEEDRATE = homing_feedrate[X_AXIS] / 20;
int Z_LIFT_FEEDRATE = homing_feedrate[Z_AXIS] / 40;
setup_for_endstop_move(false);
int l_feedmultiply = setup_for_endstop_move(false);
SERIAL_PROTOCOLPGM("Num X,Y: ");
SERIAL_PROTOCOL(x_points_num);
@ -7979,7 +7979,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_
}
card.closefile();
clean_up_after_endstop_move(l_feedmultiply);
}
#endif
@ -8114,7 +8114,6 @@ void long_pause() //long pause print
st_synchronize();
//save currently set parameters to global variables
saved_feedmultiply = feedmultiply;
fanSpeedBckp = fanSpeed;
start_pause_print = millis();