57
57
// "Motion" > "Move Axis" submenu
58
58
//
59
59
60
- // TODO: Use substitution here with MSG_MOVE_N
61
-
62
- static void _lcd_move_xyz (FSTR_P const name, const AxisEnum axis) {
60
+ static void _lcd_move_xyz (const AxisEnum axis) {
63
61
if (ui.use_click ()) return ui.goto_previous_screen_no_defer ();
64
62
if (ui.encoderPosition && !ui.manual_move .processing ) {
65
63
// Get motion limit from software endstops, if any
@@ -86,28 +84,20 @@ static void _lcd_move_xyz(FSTR_P const name, const AxisEnum axis) {
86
84
const float pos = ui.manual_move .axis_value (axis);
87
85
if (parser.using_inch_units ()) {
88
86
const float imp_pos = LINEAR_UNIT (pos);
89
- MenuEditItemBase::draw_edit_screen (name , ftostr63 (imp_pos));
87
+ MenuEditItemBase::draw_edit_screen (GET_TEXT_F (MSG_MOVE_N) , ftostr63 (imp_pos));
90
88
}
91
89
else
92
- MenuEditItemBase::draw_edit_screen (name , ui.manual_move .menu_scale >= 0 .1f ? (LARGE_AREA_TEST ? ftostr51sign (pos) : ftostr41sign (pos)) : ftostr63 (pos));
90
+ 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));
93
91
}
94
92
}
95
- void lcd_move_x () { _lcd_move_xyz (GET_TEXT_F (MSG_MOVE_X), X_AXIS); }
96
- #if HAS_Y_AXIS
97
- void lcd_move_y () { _lcd_move_xyz (GET_TEXT_F (MSG_MOVE_Y), Y_AXIS); }
98
- #endif
99
- #if HAS_Z_AXIS
100
- void lcd_move_z () { _lcd_move_xyz (GET_TEXT_F (MSG_MOVE_Z), Z_AXIS); }
101
- #endif
102
- #if HAS_I_AXIS
103
- void lcd_move_i () { _lcd_move_xyz (GET_TEXT_F (MSG_MOVE_I), I_AXIS); }
104
- #endif
105
- #if HAS_J_AXIS
106
- void lcd_move_j () { _lcd_move_xyz (GET_TEXT_F (MSG_MOVE_J), J_AXIS); }
107
- #endif
108
- #if HAS_K_AXIS
109
- void lcd_move_k () { _lcd_move_xyz (GET_TEXT_F (MSG_MOVE_K), K_AXIS); }
110
- #endif
93
+
94
+ void _lcd_move_axis_n () { _lcd_move_xyz (AxisEnum (MenuItemBase::itemIndex)); }
95
+
96
+ // Move functions for non-menu code that hasn't set itemIndex (e.g., keypad)
97
+ void lcd_move_axis (const AxisEnum axis) { MenuEditItemBase::itemIndex = int8_t (axis); _lcd_move_axis_n (); }
98
+
99
+ // Move Z easy accessor
100
+ void lcd_move_z () { lcd_move_axis (Z_AXIS); }
111
101
112
102
#if E_MANUAL
113
103
@@ -193,6 +183,8 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
193
183
END_MENU ();
194
184
}
195
185
186
+ void _menu_move_n_distance () { _menu_move_distance (AxisEnum (MenuItemBase::itemIndex), _lcd_move_axis_n); }
187
+
196
188
#if E_MANUAL
197
189
198
190
inline void _goto_menu_move_distance_e () {
@@ -226,29 +218,20 @@ void menu_move() {
226
218
EDIT_ITEM (bool , MSG_LCD_SOFT_ENDSTOPS, &soft_endstop._enabled );
227
219
#endif
228
220
221
+ // Move submenu for each axis
229
222
if (NONE (IS_KINEMATIC, NO_MOTION_BEFORE_HOMING) || all_axes_homed ()) {
230
223
if (TERN1 (DELTA, current_position.z <= delta_clip_start_height)) {
231
- SUBMENU (MSG_MOVE_X, []{ _menu_move_distance (X_AXIS, lcd_move_x); });
232
- #if HAS_Y_AXIS
233
- SUBMENU (MSG_MOVE_Y, []{ _menu_move_distance (Y_AXIS, lcd_move_y); });
234
- #endif
224
+ for (uint8_t a = X_AXIS; a <= min (int (Y_AXIS), LINEAR_AXES - 1 ); a++)
225
+ SUBMENU_N (a, MSG_MOVE_N, _menu_move_n_distance);
235
226
}
236
- # if ENABLED(DELTA)
237
- else
227
+ else {
228
+ # if ENABLED(DELTA)
238
229
ACTION_ITEM (MSG_FREE_XY, []{ line_to_z (delta_clip_start_height); ui.synchronize (); });
239
- #endif
240
-
230
+ #endif
231
+ }
241
232
#if HAS_Z_AXIS
242
- SUBMENU (MSG_MOVE_Z, []{ _menu_move_distance (Z_AXIS, lcd_move_z); });
243
- #endif
244
- #if HAS_I_AXIS
245
- SUBMENU (MSG_MOVE_I, []{ _menu_move_distance (I_AXIS, lcd_move_i); });
246
- #endif
247
- #if HAS_J_AXIS
248
- SUBMENU (MSG_MOVE_J, []{ _menu_move_distance (J_AXIS, lcd_move_j); });
249
- #endif
250
- #if HAS_K_AXIS
251
- SUBMENU (MSG_MOVE_K, []{ _menu_move_distance (K_AXIS, lcd_move_k); });
233
+ for (uint8_t a = Z_AXIS; a < LINEAR_AXES; a++)
234
+ SUBMENU_N (a, MSG_MOVE_N, _menu_move_n_distance);
252
235
#endif
253
236
}
254
237
else
0 commit comments