From c92b80d3d3df0aa4b94b4ab13eb2eaf669a7d12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 17 Aug 2024 18:23:27 +0000 Subject: [PATCH] Reduce _lcd_move() code size re-use clamp_to_software_endstops() to avoid code duplication Change in memory: Flash: -192 bytes SRAM: 0 bytes --- Firmware/ultralcd.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 82157097f..7605e3d47 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -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) { @@ -2417,10 +2417,8 @@ 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; } @@ -2573,13 +2571,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); }