🐛 Fix Manual Move axis selection (#24404)

This commit is contained in:
Scott Lahteine 2022-06-26 05:47:18 -05:00
parent ab2fceda2c
commit 0435b2220a
9 changed files with 46 additions and 62 deletions

View File

@ -283,7 +283,7 @@ CrealityDWINClass CrealityDWIN;
#endif
void manual_move(bool zmove=false) {
void manual_mesh_move(const bool zmove=false) {
if (zmove) {
planner.synchronize();
current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
@ -3035,7 +3035,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
mesh_conf.goto_mesh_value = true;
mesh_conf.mesh_x = mesh_conf.mesh_y = 0;
Popup_Handler(MoveWait);
mesh_conf.manual_move();
mesh_conf.manual_mesh_move();
Draw_Menu(UBLMesh);
#endif
#elif HAS_BED_PROBE
@ -3091,7 +3091,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating());
#endif
Popup_Handler(MoveWait);
mesh_conf.manual_move();
mesh_conf.manual_mesh_move();
Draw_Menu(LevelManual);
}
break;
@ -3328,7 +3328,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
mesh_conf.mesh_x++;
else
mesh_conf.mesh_x--;
mesh_conf.manual_move();
mesh_conf.manual_mesh_move();
}
}
break;
@ -3375,7 +3375,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
else {
mesh_conf.goto_mesh_value = !mesh_conf.goto_mesh_value;
current_position.z = 0;
mesh_conf.manual_move(true);
mesh_conf.manual_mesh_move(true);
Draw_Checkbox(row, mesh_conf.goto_mesh_value);
}
break;
@ -3428,7 +3428,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
mesh_conf.mesh_x++;
else
mesh_conf.mesh_x--;
mesh_conf.manual_move();
mesh_conf.manual_mesh_move();
}
else {
gcode.process_subcommands_now(F("G29 S"));
@ -3449,7 +3449,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
mesh_conf.mesh_x--;
else
mesh_conf.mesh_x++;
mesh_conf.manual_move();
mesh_conf.manual_mesh_move();
}
}
break;
@ -4109,8 +4109,8 @@ void CrealityDWINClass::Value_Control() {
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
planner.synchronize();
break;
case UBLMesh: mesh_conf.manual_move(true); break;
case LevelManual: mesh_conf.manual_move(selection == LEVELING_M_OFFSET); break;
case UBLMesh: mesh_conf.manual_mesh_move(true); break;
case LevelManual: mesh_conf.manual_mesh_move(selection == LEVELING_M_OFFSET); break;
#endif
}
if (valuepointer == &planner.flow_percentage[0])

View File

@ -410,8 +410,7 @@ void MarlinUI::draw_status_message(const bool blink) {
const dwin_coord_t by = (row * MENU_LINE_HEIGHT) + MENU_FONT_HEIGHT + EXTRA_ROW_HEIGHT / 2;
DWIN_Draw_String(true, font16x32, Color_Yellow, Color_Bg_Black, (LCD_PIXEL_WIDTH - vallen * 16) / 2, by, S(dwin_string.string()));
extern screenFunc_t _manual_move_func_ptr;
if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
if (ui.can_show_slider()) {
const dwin_coord_t slider_length = LCD_PIXEL_WIDTH - TERN(DWIN_MARLINUI_LANDSCAPE, 120, 20),
slider_height = 16,

View File

@ -309,7 +309,7 @@ namespace Language_en {
LSTR MSG_MOVE_Z = _UxGT("Move Z");
LSTR MSG_MOVE_N = _UxGT("Move @");
LSTR MSG_MOVE_E = _UxGT("Move Extruder");
LSTR MSG_MOVE_EN = _UxGT("Move E*");
LSTR MSG_MOVE_EN = _UxGT("Move *");
LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend too cold");
LSTR MSG_MOVE_N_MM = _UxGT("Move $mm");
LSTR MSG_MOVE_01MM = _UxGT("Move 0.1mm");

View File

@ -763,6 +763,7 @@ void MarlinUI::init() {
millis_t ManualMove::start_time = 0;
float ManualMove::menu_scale = 1;
screenFunc_t ManualMove::screen_ptr;
#if IS_KINEMATIC
float ManualMove::offset = 0;
xyze_pos_t ManualMove::all_axes_destination = { 0 };
@ -772,6 +773,9 @@ void MarlinUI::init() {
int8_t ManualMove::e_index = 0;
#endif
AxisEnum ManualMove::axis = NO_AXIS_ENUM;
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
float ManualMove::e_origin = 0;
#endif
/**
* If a manual move has been posted and its time has arrived, and if the planner
@ -788,9 +792,6 @@ void MarlinUI::init() {
* For kinematic machines:
* - Set manual_move.offset to modify one axis and post the move.
* This is used to achieve more rapid stepping on kinematic machines.
*
* Currently used by the _lcd_move_xyz function in menu_motion.cpp
* and the ubl_map_move_to_xy function in menu_ubl.cpp.
*/
void ManualMove::task() {

View File

@ -137,12 +137,16 @@ typedef bool (*statusResetFunc_t)();
static xyze_pos_t all_axes_destination;
#endif
public:
static screenFunc_t screen_ptr;
static float menu_scale;
#if IS_KINEMATIC
static float offset;
#endif
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
static float e_origin;
#endif
template <typename T>
void set_destination(const T& dest) {
static void set_destination(const T& dest) {
#if IS_KINEMATIC
// Moves are segmented, so the entire move is not submitted at once.
// Using a separate variable prevents corrupting the in-progress move.
@ -153,10 +157,10 @@ typedef bool (*statusResetFunc_t)();
current_position.set(dest);
#endif
}
float axis_value(const AxisEnum axis) {
static float axis_value(const AxisEnum axis) {
return NATIVE_TO_LOGICAL(processing ? destination[axis] : SUM_TERN(IS_KINEMATIC, current_position[axis], offset), axis);
}
bool apply_diff(const AxisEnum axis, const_float_t diff, const_float_t min, const_float_t max) {
static bool apply_diff(const AxisEnum axis, const_float_t diff, const_float_t min, const_float_t max) {
#if IS_KINEMATIC
float &valref = offset;
const float rmin = min - current_position[axis], rmax = max - current_position[axis];
@ -166,12 +170,7 @@ typedef bool (*statusResetFunc_t)();
#endif
valref += diff;
const float pre = valref;
if (min != max) {
if (diff < 0)
NOLESS(valref, rmin);
else
NOMORE(valref, rmax);
}
if (min != max) { if (diff < 0) NOLESS(valref, rmin); else NOMORE(valref, rmax); }
return pre != valref;
}
#if IS_KINEMATIC
@ -552,6 +551,7 @@ public:
// Manual Movement
static ManualMove manual_move;
static bool can_show_slider() { return !external_control && currentScreen != manual_move.screen_ptr; }
// Select Screen (modal NO/YES style dialog)
static bool selection;

View File

@ -46,15 +46,11 @@
#include "../../feature/bedlevel/bedlevel.h"
#endif
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
float manual_move_e_origin = 0;
#endif
//
// "Motion" > "Move Axis" submenu
//
static void _lcd_move_xyz(const AxisEnum axis) {
void lcd_move_axis(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
@ -88,11 +84,6 @@ static void _lcd_move_xyz(const AxisEnum axis) {
}
}
void _lcd_move_axis_n() { _lcd_move_xyz(AxisEnum(MenuItemBase::itemIndex)); }
// Move functions for non-menu code that hasn't set itemIndex (e.g., keypad)
void lcd_move_axis(const AxisEnum axis) { MenuEditItemBase::itemIndex = int8_t(axis); _lcd_move_axis_n(); }
// Move Z easy accessor
void lcd_move_z() { lcd_move_axis(Z_AXIS); }
@ -115,7 +106,7 @@ void lcd_move_z() { lcd_move_axis(Z_AXIS); }
GET_TEXT_F(TERN(MULTI_E_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)),
ftostr41sign(current_position.e
PLUS_TERN0(IS_KINEMATIC, ui.manual_move.offset)
MINUS_TERN0(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin)
MINUS_TERN0(MANUAL_E_MOVES_RELATIVE, ui.manual_move.e_origin)
)
);
} // should_draw
@ -140,26 +131,22 @@ void lcd_move_z() { lcd_move_axis(Z_AXIS); }
#define FINE_MANUAL_MOVE 0.025
#endif
screenFunc_t _manual_move_func_ptr;
void _goto_manual_move(const_float_t scale) {
ui.defer_status_screen();
ui.manual_move.menu_scale = scale;
ui.goto_screen(_manual_move_func_ptr);
ui.goto_screen(ui.manual_move.screen_ptr);
thermalManager.set_menu_cold_override(true);
}
void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=active_extruder) {
_manual_move_func_ptr = func;
ui.manual_move.screen_ptr = func;
START_MENU();
if (LCD_HEIGHT >= 4) {
switch (axis) {
#define _CASE_MOVE(N) case N##_AXIS: STATIC_ITEM_N(N##_AXIS, MSG_MOVE_N, SS_DEFAULT|SS_INVERT); break;
MAIN_AXIS_MAP(_CASE_MOVE)
default:
TERN_(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin = current_position.e);
STATIC_ITEM(MSG_MOVE_E, SS_DEFAULT|SS_INVERT);
break;
if (axis < NUM_AXES)
STATIC_ITEM_N(axis, MSG_MOVE_N, SS_DEFAULT|SS_INVERT);
else {
TERN_(MANUAL_E_MOVES_RELATIVE, ui.manual_move.e_origin = current_position.e);
STATIC_ITEM_N(eindex, MSG_MOVE_EN, SS_DEFAULT|SS_INVERT);
}
}
@ -181,8 +168,6 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
END_MENU();
}
void _menu_move_n_distance() { _menu_move_distance(AxisEnum(MenuItemBase::itemIndex), _lcd_move_axis_n); }
#if E_MANUAL
inline void _goto_menu_move_distance_e() {
@ -216,8 +201,10 @@ 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)) {
for (uint8_t a = X_AXIS; a <= min(int(Y_AXIS), NUM_AXES - 1); a++)
SUBMENU_N(a, MSG_MOVE_N, _menu_move_n_distance);
SUBMENU_N(X_AXIS, MSG_MOVE_N, []{ _menu_move_distance(X_AXIS, []{ lcd_move_axis(X_AXIS); }); });
#if HAS_Y_AXIS
SUBMENU_N(Y_AXIS, MSG_MOVE_N, []{ _menu_move_distance(Y_AXIS, []{ lcd_move_axis(Y_AXIS); }); });
#endif
}
else {
#if ENABLED(DELTA)
@ -225,8 +212,8 @@ void menu_move() {
#endif
}
#if HAS_Z_AXIS
for (uint8_t a = Z_AXIS; a < NUM_AXES; a++)
SUBMENU_N(a, MSG_MOVE_N, _menu_move_n_distance);
#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
}
else
@ -271,9 +258,9 @@ void menu_move() {
#if E_MANUAL
// The current extruder
SUBMENU(MSG_MOVE_E, []{ _menu_move_distance_e_maybe(); });
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(MenuItemBase::itemIndex); }, MenuItemBase::itemIndex); });
#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)
@ -285,7 +272,7 @@ void menu_move() {
#elif MULTI_E_MANUAL
// Independent extruders with one E stepper per hotend
LOOP_L_N(n, E_MANUAL) SUBMENU_MOVE_E(n);
REPEAT(E_MANUAL, SUBMENU_MOVE_E);
#endif

View File

@ -394,8 +394,7 @@ void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const va
}
#endif
extern screenFunc_t _manual_move_func_ptr;
if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
if (ui.can_show_slider()) {
#define SLIDER_LENGTH 600
#define SLIDER_Y_POSITION 200

View File

@ -383,8 +383,7 @@ void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const va
}
#endif
extern screenFunc_t _manual_move_func_ptr;
if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
if (ui.can_show_slider()) {
#define SLIDER_LENGTH 224
#define SLIDER_Y_POSITION 140

View File

@ -388,8 +388,7 @@ void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const va
}
#endif
extern screenFunc_t _manual_move_func_ptr;
if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
if (ui.can_show_slider()) {
#define SLIDER_LENGTH 336
#define SLIDER_Y_POSITION 186