5050// "Motion" > "Move Axis" submenu
5151//
5252
53- void lcd_move_axis (const AxisEnum axis) {
53+ // TODO: Use substitution here with MSG_MOVE_N
54+ static void _lcd_move_xyz (FSTR_P const name, const AxisEnum axis) {
5455 if (ui.use_click ()) return ui.goto_previous_screen_no_defer ();
5556 if (ui.encoderPosition && !ui.manual_move .processing ) {
5657 // Get motion limit from software endstops, if any
@@ -77,19 +78,19 @@ void lcd_move_axis(const AxisEnum axis) {
7778 const float pos = ui.manual_move .axis_value (axis);
7879 if (parser.using_inch_units ()) {
7980 const float imp_pos = LINEAR_UNIT (pos);
80- MenuEditItemBase::draw_edit_screen (GET_TEXT_F (MSG_MOVE_N) , ftostr63 (imp_pos));
81+ MenuEditItemBase::draw_edit_screen (name , ftostr63 (imp_pos));
8182 }
8283 else
83- MenuEditItemBase::draw_edit_screen (GET_TEXT_F (MSG_MOVE_N) , ui.manual_move .menu_scale >= 0 .1f ? (LARGE_AREA_TEST ? ftostr51sign (pos) : ftostr41sign (pos)) : ftostr63 (pos));
84+ MenuEditItemBase::draw_edit_screen (name , ui.manual_move .menu_scale >= 0 .1f ? (LARGE_AREA_TEST ? ftostr51sign (pos) : ftostr41sign (pos)) : ftostr63 (pos));
8485 }
8586}
8687
87- // Move Z easy accessor
88- void lcd_move_z () { lcd_move_axis (Z_AXIS); }
88+ # define _LCD_MOVE_FN ( N ) void lcd_move_##N() { _lcd_move_xyz ( GET_TEXT_F (MSG_MOVE_##N), _AXIS (N)); }
89+ MAIN_AXIS_MAP (_LCD_MOVE_FN);
8990
9091#if E_MANUAL
9192
92- static void lcd_move_e (TERN_(MULTI_E_MANUAL, const int8_t eindex=active_extruder)) {
93+ static void lcd_move_E (TERN_(MULTI_E_MANUAL, const int8_t eindex=active_extruder)) {
9394 if (ui.use_click ()) return ui.goto_previous_screen_no_defer ();
9495 if (ui.encoderPosition ) {
9596 if (!ui.manual_move .processing ) {
@@ -118,7 +119,7 @@ void lcd_move_z() { lcd_move_axis(Z_AXIS); }
118119
119120 void _goto_manual_move_z (const_float_t scale) {
120121 ui.manual_move .menu_scale = scale;
121- ui.goto_screen (lcd_move_z );
122+ ui.goto_screen (lcd_move_Z );
122123 }
123124
124125#endif
@@ -171,7 +172,7 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
171172#if E_MANUAL
172173
173174 inline void _goto_menu_move_distance_e () {
174- ui.goto_screen ([]{ _menu_move_distance (E_AXIS, []{ lcd_move_e (); }); });
175+ ui.goto_screen ([]{ _menu_move_distance (E_AXIS, []{ lcd_move_E (); }); });
175176 }
176177
177178 inline void _menu_move_distance_e_maybe () {
@@ -201,20 +202,18 @@ void menu_move() {
201202 // Move submenu for each axis
202203 if (NONE (IS_KINEMATIC, NO_MOTION_BEFORE_HOMING) || all_axes_homed ()) {
203204 if (TERN1 (DELTA, current_position.z <= delta_clip_start_height)) {
204- SUBMENU_N (X_AXIS, MSG_MOVE_N, []{ _menu_move_distance (X_AXIS, []{ lcd_move_axis (X_AXIS); } ); });
205+ SUBMENU_N (X_AXIS, MSG_MOVE_N, []{ _menu_move_distance (X_AXIS, lcd_move_X ); });
205206 #if HAS_Y_AXIS
206- SUBMENU_N (Y_AXIS, MSG_MOVE_N, []{ _menu_move_distance (Y_AXIS, []{ lcd_move_axis (Y_AXIS); } ); });
207+ SUBMENU_N (Y_AXIS, MSG_MOVE_N, []{ _menu_move_distance (Y_AXIS, lcd_move_Y ); });
207208 #endif
208209 }
209210 else {
210211 #if ENABLED(DELTA)
211212 ACTION_ITEM (MSG_FREE_XY, []{ line_to_z (delta_clip_start_height); ui.synchronize (); });
212213 #endif
213214 }
214- #if HAS_Z_AXIS
215- #define _AXIS_MOVE (N ) SUBMENU_N(N, MSG_MOVE_N, []{ _menu_move_distance (AxisEnum (N), []{ lcd_move_axis (AxisEnum (N)); }); });
216- REPEAT_S (2 , NUM_AXES, _AXIS_MOVE);
217- #endif
215+ #define _SUBMENU_MOVE (N ) SUBMENU_N(_AXIS(N), MSG_MOVE_N, []{ _menu_move_distance (_AXIS (N), lcd_move_##N); });
216+ MAIN_AXIS_MAP (_SUBMENU_MOVE);
218217 }
219218 else
220219 GCODES_ITEM (MSG_AUTO_HOME, FPSTR (G28_STR));
@@ -260,7 +259,7 @@ void menu_move() {
260259 // The current extruder
261260 SUBMENU (MSG_MOVE_E, _menu_move_distance_e_maybe);
262261
263- #define SUBMENU_MOVE_E (N ) SUBMENU_N(N, MSG_MOVE_EN, []{ _menu_move_distance (E_AXIS, []{ lcd_move_e (N); }, N); });
262+ #define SUBMENU_MOVE_E (N ) SUBMENU_N(N, MSG_MOVE_EN, []{ _menu_move_distance (E_AXIS, []{ lcd_move_E (N); }, N); });
264263
265264 #if EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE)
266265
0 commit comments