Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce _lcd_move() code size #4756

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Firmware/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ extern int extrudemultiply; // Sets extrude multiply factor (in percent) for all
extern float extruder_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
extern float current_position[NUM_AXIS] ;
extern float destination[NUM_AXIS] ;
extern float min_pos[3];
extern float max_pos[3];
extern bool axis_known_position[3];
extern uint8_t fanSpeed; //!< Print fan speed, ranges from 0 to 255
extern uint8_t newFanSpeed;
Expand Down
4 changes: 2 additions & 2 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
#define _z current_position[Z_AXIS]
#define _e current_position[E_AXIS]

float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
static float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
static float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
bool axis_known_position[3] = {false, false, false};

static float pause_position[3] = { X_PAUSE_POS, Y_PAUSE_POS, Z_PAUSE_LIFT };
Expand Down
14 changes: 5 additions & 9 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ void lcd_menu_statistics()
}


static void _lcd_move(const char *name, uint8_t axis, int min, int max)
static void _lcd_move(const char *name, const uint8_t axis)
{
if (homing_flag || mesh_bed_leveling_flag)
{
Expand All @@ -2417,12 +2417,9 @@ static void _lcd_move(const char *name, uint8_t axis, int min, int max)
if (! planner_queue_full())
{
current_position[axis] += lcd_encoder;
if (min_software_endstops && current_position[axis] < min) current_position[axis] = min;
if (max_software_endstops && current_position[axis] > max) current_position[axis] = max;
lcd_encoder = 0;
world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]);
clamp_to_software_endstops(current_position);
plan_buffer_line_curposXYZE(get_feedrate_mm_s(manual_feedrate[axis]));
lcd_draw_update = 1;
}
}
if (lcd_draw_update)
Expand All @@ -2447,7 +2444,6 @@ void lcd_move_e()
current_position[E_AXIS] += lcd_encoder;
lcd_encoder = 0;
plan_buffer_line_curposXYZE(manual_feedrate[E_AXIS] / 60);
lcd_draw_update = 1;
}
}
if (lcd_draw_update)
Expand Down Expand Up @@ -2573,13 +2569,13 @@ static void lcd_menu_xyz_offset()
// Note: the colon behind the text (X, Y, Z) is necessary to greatly shorten
// the implementation of menu_draw_float31
static void lcd_move_x() {
_lcd_move(PSTR("X:"), X_AXIS, X_MIN_POS, X_MAX_POS);
_lcd_move(PSTR("X:"), X_AXIS);
}
static void lcd_move_y() {
_lcd_move(PSTR("Y:"), Y_AXIS, Y_MIN_POS, Y_MAX_POS);
_lcd_move(PSTR("Y:"), Y_AXIS);
}
static void lcd_move_z() {
_lcd_move(PSTR("Z:"), Z_AXIS, Z_MIN_POS, Z_MAX_POS);
_lcd_move(PSTR("Z:"), Z_AXIS);
}


Expand Down
Loading