Skip to content

Commit

Permalink
Revert move menu optimization
Browse files Browse the repository at this point in the history
🐛 Fix Axis Homing (#24425)
🐛 Fix Manual Move axis selection (#24404)
🎨 Simplify move menus with substitution (975c8f4)
  • Loading branch information
thinkyhead committed Jul 18, 2022
1 parent 559b3f3 commit eacf563
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 25 deletions.
11 changes: 7 additions & 4 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,13 @@ void MarlinUI::init() {
ui.manual_move.menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
ui.encoderPosition = dir;
switch (axis) {
case X_AXIS:
TERN_(HAS_Y_AXIS, case Y_AXIS:)
TERN_(HAS_Z_AXIS, case Z_AXIS:)
lcd_move_axis(axis);
case X_AXIS: { lcd_move_X(); } break;
#if HAS_Y_AXIS
case Y_AXIS: { lcd_move_Y(); } break;
#endif
#if HAS_Z_AXIS
case Z_AXIS: { lcd_move_Z(); } break;
#endif
default: break;
}
}
Expand Down
8 changes: 8 additions & 0 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ typedef bool (*statusResetFunc_t)();
static void soon(const AxisEnum axis OPTARG(MULTI_E_MANUAL, const int8_t eindex=active_extruder));
};

void lcd_move_X();
#if HAS_Y_AXIS
void lcd_move_Y();
#endif
#if HAS_Z_AXIS
void lcd_move_Z();
#endif

#endif

////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
else {
#if ENABLED(MOVE_Z_WHEN_IDLE)
ui.manual_move.menu_scale = MOVE_Z_IDLE_MULTIPLICATOR;
screen = lcd_move_z;
screen = lcd_move_Z;
#endif
}
}
Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/lcd/menu/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ void menu_move();
//////// Menu Item Helper Functions ////////
////////////////////////////////////////////

void lcd_move_axis(const AxisEnum);
void lcd_move_z();
void _lcd_draw_homing();

#define HAS_LINE_TO_Z ANY(DELTA, PROBE_MANUALLY, MESH_BED_LEVELING, LCD_BED_TRAMMING)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_delta_calibrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void _man_probe_pt(const xy_pos_t &xy) {
ui.wait_for_move = false;
ui.synchronize();
ui.manual_move.menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / planner.settings.axis_steps_per_mm[0]); // Use first axis as for delta XYZ should always match
ui.goto_screen(lcd_move_z);
ui.goto_screen(lcd_move_Z);
}
}

Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/lcd/menu/menu_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#include "../../module/planner.h"
#endif

void lcd_move_z();

////////////////////////////////////////////
///////////// Base Menu Items //////////////
////////////////////////////////////////////
Expand Down
29 changes: 14 additions & 15 deletions Marlin/src/lcd/menu/menu_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
// "Motion" > "Move Axis" submenu
//

void lcd_move_axis(const AxisEnum axis) {
// TODO: Use substitution here with MSG_MOVE_N
static void _lcd_move_xyz(FSTR_P const name, const AxisEnum axis) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
if (ui.encoderPosition && !ui.manual_move.processing) {
// Get motion limit from software endstops, if any
Expand All @@ -77,19 +78,19 @@ void lcd_move_axis(const AxisEnum axis) {
const float pos = ui.manual_move.axis_value(axis);
if (parser.using_inch_units()) {
const float imp_pos = LINEAR_UNIT(pos);
MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_MOVE_N), ftostr63(imp_pos));
MenuEditItemBase::draw_edit_screen(name, ftostr63(imp_pos));
}
else
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));
MenuEditItemBase::draw_edit_screen(name, ui.manual_move.menu_scale >= 0.1f ? (LARGE_AREA_TEST ? ftostr51sign(pos) : ftostr41sign(pos)) : ftostr63(pos));
}
}

// Move Z easy accessor
void lcd_move_z() { lcd_move_axis(Z_AXIS); }
#define _LCD_MOVE_FN(N) void lcd_move_##N() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_##N), _AXIS(N)); }
MAIN_AXIS_MAP(_LCD_MOVE_FN);

#if E_MANUAL

static void lcd_move_e(TERN_(MULTI_E_MANUAL, const int8_t eindex=active_extruder)) {
static void lcd_move_E(TERN_(MULTI_E_MANUAL, const int8_t eindex=active_extruder)) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
if (ui.encoderPosition) {
if (!ui.manual_move.processing) {
Expand Down Expand Up @@ -118,7 +119,7 @@ void lcd_move_z() { lcd_move_axis(Z_AXIS); }

void _goto_manual_move_z(const_float_t scale) {
ui.manual_move.menu_scale = scale;
ui.goto_screen(lcd_move_z);
ui.goto_screen(lcd_move_Z);
}

#endif
Expand Down Expand Up @@ -171,7 +172,7 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
#if E_MANUAL

inline void _goto_menu_move_distance_e() {
ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(); }); });
ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_E(); }); });
}

inline void _menu_move_distance_e_maybe() {
Expand Down Expand Up @@ -201,20 +202,18 @@ void menu_move() {
// Move submenu for each axis
if (NONE(IS_KINEMATIC, NO_MOTION_BEFORE_HOMING) || all_axes_homed()) {
if (TERN1(DELTA, current_position.z <= delta_clip_start_height)) {
SUBMENU_N(X_AXIS, MSG_MOVE_N, []{ _menu_move_distance(X_AXIS, []{ lcd_move_axis(X_AXIS); }); });
SUBMENU_N(X_AXIS, MSG_MOVE_N, []{ _menu_move_distance(X_AXIS, lcd_move_X); });
#if HAS_Y_AXIS
SUBMENU_N(Y_AXIS, MSG_MOVE_N, []{ _menu_move_distance(Y_AXIS, []{ lcd_move_axis(Y_AXIS); }); });
SUBMENU_N(Y_AXIS, MSG_MOVE_N, []{ _menu_move_distance(Y_AXIS, lcd_move_Y); });
#endif
}
else {
#if ENABLED(DELTA)
ACTION_ITEM(MSG_FREE_XY, []{ line_to_z(delta_clip_start_height); ui.synchronize(); });
#endif
}
#if HAS_Z_AXIS
#define _AXIS_MOVE(N) SUBMENU_N(N, MSG_MOVE_N, []{ _menu_move_distance(AxisEnum(N), []{ lcd_move_axis(AxisEnum(N)); }); });
REPEAT_S(2, NUM_AXES, _AXIS_MOVE);
#endif
#define _SUBMENU_MOVE(N) SUBMENU_N(_AXIS(N), MSG_MOVE_N, []{ _menu_move_distance(_AXIS(N), lcd_move_##N); });
MAP(_SUBMENU_MOVE, LIST_N(SUB2(NUM_AXES), X, Y, Z, I, J, K, U, V, W));
}
else
GCODES_ITEM(MSG_AUTO_HOME, FPSTR(G28_STR));
Expand Down Expand Up @@ -260,7 +259,7 @@ void menu_move() {
// The current extruder
SUBMENU(MSG_MOVE_E, _menu_move_distance_e_maybe);

#define SUBMENU_MOVE_E(N) SUBMENU_N(N, MSG_MOVE_EN, []{ _menu_move_distance(E_AXIS, []{ lcd_move_e(N); }, N); });
#define SUBMENU_MOVE_E(N) SUBMENU_N(N, MSG_MOVE_EN, []{ _menu_move_distance(E_AXIS, []{ lcd_move_E(N); }, N); });

#if EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE)

Expand Down

0 comments on commit eacf563

Please sign in to comment.