🐛 Fix Manual Move axis selection (#24404)

This commit is contained in:
Scott Lahteine 2022-06-26 05:47:18 -05:00
parent 3af5c32ea2
commit a7c58c1fd6
9 changed files with 44 additions and 58 deletions

View file

@ -283,7 +283,7 @@ CrealityDWINClass CrealityDWIN;
#endif #endif
void manual_move(bool zmove=false) { void manual_mesh_move(const bool zmove=false) {
if (zmove) { if (zmove) {
planner.synchronize(); planner.synchronize();
current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; 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.goto_mesh_value = true;
mesh_conf.mesh_x = mesh_conf.mesh_y = 0; mesh_conf.mesh_x = mesh_conf.mesh_y = 0;
Popup_Handler(MoveWait); Popup_Handler(MoveWait);
mesh_conf.manual_move(); mesh_conf.manual_mesh_move();
Draw_Menu(UBLMesh); Draw_Menu(UBLMesh);
#endif #endif
#elif HAS_BED_PROBE #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()); TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating());
#endif #endif
Popup_Handler(MoveWait); Popup_Handler(MoveWait);
mesh_conf.manual_move(); mesh_conf.manual_mesh_move();
Draw_Menu(LevelManual); Draw_Menu(LevelManual);
} }
break; break;
@ -3328,7 +3328,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
mesh_conf.mesh_x++; mesh_conf.mesh_x++;
else else
mesh_conf.mesh_x--; mesh_conf.mesh_x--;
mesh_conf.manual_move(); mesh_conf.manual_mesh_move();
} }
} }
break; break;
@ -3375,7 +3375,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
else { else {
mesh_conf.goto_mesh_value = !mesh_conf.goto_mesh_value; mesh_conf.goto_mesh_value = !mesh_conf.goto_mesh_value;
current_position.z = 0; current_position.z = 0;
mesh_conf.manual_move(true); mesh_conf.manual_mesh_move(true);
Draw_Checkbox(row, mesh_conf.goto_mesh_value); Draw_Checkbox(row, mesh_conf.goto_mesh_value);
} }
break; break;
@ -3428,7 +3428,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
mesh_conf.mesh_x++; mesh_conf.mesh_x++;
else else
mesh_conf.mesh_x--; mesh_conf.mesh_x--;
mesh_conf.manual_move(); mesh_conf.manual_mesh_move();
} }
else { else {
gcode.process_subcommands_now(F("G29 S")); 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--; mesh_conf.mesh_x--;
else else
mesh_conf.mesh_x++; mesh_conf.mesh_x++;
mesh_conf.manual_move(); mesh_conf.manual_mesh_move();
} }
} }
break; break;
@ -4109,8 +4109,8 @@ void CrealityDWINClass::Value_Control() {
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
planner.synchronize(); planner.synchronize();
break; break;
case UBLMesh: mesh_conf.manual_move(true); break; case UBLMesh: mesh_conf.manual_mesh_move(true); break;
case LevelManual: mesh_conf.manual_move(selection == LEVELING_M_OFFSET); break; case LevelManual: mesh_conf.manual_mesh_move(selection == LEVELING_M_OFFSET); break;
#endif #endif
} }
if (valuepointer == &planner.flow_percentage[0]) 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; 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())); 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.can_show_slider()) {
if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
const dwin_coord_t slider_length = LCD_PIXEL_WIDTH - TERN(DWIN_MARLINUI_LANDSCAPE, 120, 20), const dwin_coord_t slider_length = LCD_PIXEL_WIDTH - TERN(DWIN_MARLINUI_LANDSCAPE, 120, 20),
slider_height = 16, slider_height = 16,

View file

@ -309,7 +309,7 @@ namespace Language_en {
LSTR MSG_MOVE_Z = _UxGT("Move Z"); LSTR MSG_MOVE_Z = _UxGT("Move Z");
LSTR MSG_MOVE_N = _UxGT("Move @"); LSTR MSG_MOVE_N = _UxGT("Move @");
LSTR MSG_MOVE_E = _UxGT("Move Extruder"); 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_HOTEND_TOO_COLD = _UxGT("Hotend too cold");
LSTR MSG_MOVE_N_MM = _UxGT("Move $mm"); LSTR MSG_MOVE_N_MM = _UxGT("Move $mm");
LSTR MSG_MOVE_01MM = _UxGT("Move 0.1mm"); LSTR MSG_MOVE_01MM = _UxGT("Move 0.1mm");

View file

@ -766,6 +766,7 @@ void MarlinUI::init() {
millis_t ManualMove::start_time = 0; millis_t ManualMove::start_time = 0;
float ManualMove::menu_scale = 1; float ManualMove::menu_scale = 1;
screenFunc_t ManualMove::screen_ptr;
#if IS_KINEMATIC #if IS_KINEMATIC
float ManualMove::offset = 0; float ManualMove::offset = 0;
xyze_pos_t ManualMove::all_axes_destination = { 0 }; xyze_pos_t ManualMove::all_axes_destination = { 0 };
@ -775,6 +776,9 @@ void MarlinUI::init() {
int8_t ManualMove::e_index = 0; int8_t ManualMove::e_index = 0;
#endif #endif
AxisEnum ManualMove::axis = NO_AXIS_ENUM; 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 * If a manual move has been posted and its time has arrived, and if the planner
@ -791,9 +795,6 @@ void MarlinUI::init() {
* For kinematic machines: * For kinematic machines:
* - Set manual_move.offset to modify one axis and post the move. * - Set manual_move.offset to modify one axis and post the move.
* This is used to achieve more rapid stepping on kinematic machines. * 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() { void ManualMove::task() {
@ -864,7 +865,7 @@ void MarlinUI::init() {
void MarlinUI::external_encoder() { void MarlinUI::external_encoder() {
if (external_control && encoderDiff) { if (external_control && encoderDiff) {
bedlevel.encoder_diff += encoderDiff; // Encoder for UBL G29 mesh editing bedlevel.encoder_diff += encoderDiff; // Encoder for UBL G29 mesh editing
encoderDiff = 0; // Hide encoder events from the screen handler encoderDiff = 0; // Hide encoder events from the screen handler
refresh(LCDVIEW_REDRAW_NOW); // ...but keep the refresh. refresh(LCDVIEW_REDRAW_NOW); // ...but keep the refresh.
} }

View file

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

View file

@ -49,15 +49,11 @@
#include "../../feature/bedlevel/bedlevel.h" #include "../../feature/bedlevel/bedlevel.h"
#endif #endif
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
float manual_move_e_origin = 0;
#endif
// //
// "Motion" > "Move Axis" submenu // "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.use_click()) return ui.goto_previous_screen_no_defer();
if (ui.encoderPosition && !ui.manual_move.processing) { if (ui.encoderPosition && !ui.manual_move.processing) {
// Get motion limit from software endstops, if any // Get motion limit from software endstops, if any
@ -91,11 +87,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 // Move Z easy accessor
void lcd_move_z() { lcd_move_axis(Z_AXIS); } void lcd_move_z() { lcd_move_axis(Z_AXIS); }
@ -118,7 +109,7 @@ void lcd_move_z() { lcd_move_axis(Z_AXIS); }
GET_TEXT_F(TERN(MULTI_E_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)), GET_TEXT_F(TERN(MULTI_E_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)),
ftostr41sign(current_position.e ftostr41sign(current_position.e
PLUS_TERN0(IS_KINEMATIC, ui.manual_move.offset) 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 } // should_draw
@ -143,25 +134,23 @@ void lcd_move_z() { lcd_move_axis(Z_AXIS); }
#define FINE_MANUAL_MOVE 0.025 #define FINE_MANUAL_MOVE 0.025
#endif #endif
screenFunc_t _manual_move_func_ptr;
void _goto_manual_move(const_float_t scale) { void _goto_manual_move(const_float_t scale) {
ui.defer_status_screen(); ui.defer_status_screen();
ui.manual_move.menu_scale = scale; 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); thermalManager.set_menu_cold_override(true);
} }
void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=active_extruder) { 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(); START_MENU();
if (LCD_HEIGHT >= 4) { if (LCD_HEIGHT >= 4) {
if (axis < LINEAR_AXES) if (axis < LINEAR_AXES)
STATIC_ITEM_N(axis, MSG_MOVE_N, SS_DEFAULT|SS_INVERT); STATIC_ITEM_N(axis, MSG_MOVE_N, SS_DEFAULT|SS_INVERT);
else { else {
TERN_(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin = current_position.e); TERN_(MANUAL_E_MOVES_RELATIVE, ui.manual_move.e_origin = current_position.e);
STATIC_ITEM(MSG_MOVE_E, SS_DEFAULT|SS_INVERT); STATIC_ITEM_N(eindex, MSG_MOVE_EN, SS_DEFAULT|SS_INVERT);
} }
} }
@ -183,8 +172,6 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
END_MENU(); END_MENU();
} }
void _menu_move_n_distance() { _menu_move_distance(AxisEnum(MenuItemBase::itemIndex), _lcd_move_axis_n); }
#if E_MANUAL #if E_MANUAL
inline void _goto_menu_move_distance_e() { inline void _goto_menu_move_distance_e() {
@ -221,8 +208,10 @@ void menu_move() {
// Move submenu for each axis // Move submenu for each axis
if (NONE(IS_KINEMATIC, NO_MOTION_BEFORE_HOMING) || all_axes_homed()) { if (NONE(IS_KINEMATIC, NO_MOTION_BEFORE_HOMING) || all_axes_homed()) {
if (TERN1(DELTA, current_position.z <= delta_clip_start_height)) { if (TERN1(DELTA, current_position.z <= delta_clip_start_height)) {
for (uint8_t a = X_AXIS; a <= min(int(Y_AXIS), LINEAR_AXES - 1); a++) SUBMENU_N(X_AXIS, MSG_MOVE_N, []{ _menu_move_distance(X_AXIS, []{ lcd_move_axis(X_AXIS); }); });
SUBMENU_N(a, MSG_MOVE_N, _menu_move_n_distance); #if HAS_Y_AXIS
SUBMENU_N(Y_AXIS, MSG_MOVE_N, []{ _menu_move_distance(Y_AXIS, []{ lcd_move_axis(Y_AXIS); }); });
#endif
} }
else { else {
#if ENABLED(DELTA) #if ENABLED(DELTA)
@ -230,8 +219,8 @@ void menu_move() {
#endif #endif
} }
#if HAS_Z_AXIS #if HAS_Z_AXIS
for (uint8_t a = Z_AXIS; a < LINEAR_AXES; a++) #define _AXIS_MOVE(N) SUBMENU_N(N, MSG_MOVE_N, []{ _menu_move_distance(AxisEnum(N), []{ lcd_move_axis(AxisEnum(N)); }); });
SUBMENU_N(a, MSG_MOVE_N, _menu_move_n_distance); REPEAT_S(2, LINEAR_AXES, _AXIS_MOVE);
#endif #endif
} }
else else
@ -276,9 +265,9 @@ void menu_move() {
#if E_MANUAL #if E_MANUAL
// The current extruder // 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) #if EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE)
@ -289,8 +278,8 @@ void menu_move() {
#elif MULTI_E_MANUAL #elif MULTI_E_MANUAL
// Independent extruders with one E-stepper per hotend // 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 #endif

View file

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