Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simpler mesh edit loop #18373

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
if (ENABLED(DISABLE_INACTIVE_Z)) DISABLE_AXIS_Z();
if (ENABLED(DISABLE_INACTIVE_E)) disable_e_steppers();

#if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL)
if (ubl.lcd_map_control) {
ubl.lcd_map_control = false;
ui.defer_status_screen(false);
}
#endif
TERN_(AUTO_BED_LEVELING_UBL, ubl.steppers_were_disabled());
}
}
else
Expand Down
6 changes: 1 addition & 5 deletions Marlin/src/feature/bedlevel/ubl/ubl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@
_GRIDPOS(Y, 12), _GRIDPOS(Y, 13), _GRIDPOS(Y, 14), _GRIDPOS(Y, 15)
);

#if HAS_LCD_MENU
bool unified_bed_leveling::lcd_map_control = false;
#endif

volatile int unified_bed_leveling::encoder_diff;
volatile int16_t unified_bed_leveling::encoder_diff;

unified_bed_leveling::unified_bed_leveling() {
reset();
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/feature/bedlevel/ubl/ubl.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,12 @@ class unified_bed_leveling {

#if HAS_LCD_MENU
static bool lcd_map_control;
static void steppers_were_disabled();
#else
static inline void steppers_were_disabled() {}
#endif

static volatile int encoder_diff; // Volatile because it's changed at interrupt time.
static volatile int16_t encoder_diff; // Volatile because buttons may changed it at interrupt time

unified_bed_leveling();

Expand Down
25 changes: 18 additions & 7 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,18 @@
#define UBL_G29_P31

#if HAS_LCD_MENU
void _lcd_ubl_output_map_lcd();

bool unified_bed_leveling::lcd_map_control = false;

void unified_bed_leveling::steppers_were_disabled() {
if (lcd_map_control) {
lcd_map_control = false;
ui.defer_status_screen(false);
}
}

void ubl_map_screen();

#endif

#define SIZE_OF_LITTLE_RAISE 1
Expand Down Expand Up @@ -789,11 +800,11 @@

bool click_and_hold(const clickFunc_t func=nullptr) {
if (ui.button_pressed()) {
ui.quick_feedback(false); // Preserve button state for click-and-hold
ui.quick_feedback(false); // Preserve button state for click-and-hold
const millis_t nxt = millis() + 1500UL;
while (ui.button_pressed()) { // Loop while the encoder is pressed. Uses hardware flag!
idle(); // idle, of course
if (ELAPSED(millis(), nxt)) { // After 1.5 seconds
while (ui.button_pressed()) { // Loop while the encoder is pressed. Uses hardware flag!
idle(); // idle, of course
if (ELAPSED(millis(), nxt)) { // After 1.5 seconds
ui.quick_feedback();
if (func) (*func)();
ui.wait_for_release();
Expand Down Expand Up @@ -995,9 +1006,9 @@
lcd_mesh_edit_setup(new_z);

do {
idle();
new_z = lcd_mesh_edit();
TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset + new_z)); // Move the nozzle as the point is edited
idle();
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
} while (!ui.button_pressed());

Expand All @@ -1022,7 +1033,7 @@
SERIAL_ECHOLNPGM("Done Editing Mesh");

if (lcd_map_control)
ui.goto_screen(_lcd_ubl_output_map_lcd);
ui.goto_screen(ubl_map_screen);
else
ui.return_to_status();
}
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/feature/touch/xpt2046.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
#endif

XPT2046 touch;
extern int8_t encoderDiff;

void XPT2046::init() {
SET_INPUT(TOUCH_MISO_PIN);
Expand Down
7 changes: 1 addition & 6 deletions Marlin/src/gcode/control/M17_M18_M84.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ void GcodeSuite::M18_M84() {
else
planner.finish_and_disable();

#if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL)
if (ubl.lcd_map_control) {
ubl.lcd_map_control = false;
ui.defer_status_screen(false);
}
#endif
TERN_(AUTO_BED_LEVELING_UBL, ubl.steppers_were_disabled());
}
}
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
screen = TERN(BABYSTEP_ZPROBE_OFFSET, lcd_babystep_zoffset, lcd_babystep_z);
else {
#if ENABLED(MOVE_Z_WHEN_IDLE)
move_menu_scale = MOVE_Z_IDLE_MULTIPLICATOR;
ui.manual_move.menu_scale = MOVE_Z_IDLE_MULTIPLICATOR;
screen = lcd_move_z;
#endif
}
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 @@ -46,7 +46,7 @@ void _man_probe_pt(const xy_pos_t &xy) {
do_blocking_move_to_xy_z(xy, Z_CLEARANCE_BETWEEN_PROBES);
ui.wait_for_move = false;
ui.synchronize();
move_menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
ui.manual_move.menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
ui.goto_screen(lcd_move_z);
}
}
Expand Down
43 changes: 14 additions & 29 deletions Marlin/src/lcd/menu/menu_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,13 @@
float manual_move_e_origin = 0;
#endif

//
// Tell ui.update() to start a move to current_position" after a short delay.
//
inline void manual_move_to_current(AxisEnum axis
#if MULTI_MANUAL
, const int8_t eindex=-1
#endif
) {
#if MULTI_MANUAL
if (axis == E_AXIS) ui.manual_move_e_index = eindex >= 0 ? eindex : active_extruder;
#endif
ui.manual_move_start_time = millis() + (move_menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
ui.manual_move_axis = (int8_t)axis;
}

//
// "Motion" > "Move Axis" submenu
//

static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
if (ui.encoderPosition && !ui.processing_manual_move) {
if (ui.encoderPosition && !ui.manual_move.processing) {

// Start with no limits to movement
float min = current_position[axis] - 1000,
Expand Down Expand Up @@ -105,13 +90,13 @@ static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) {
#endif

// Get the new position
const float diff = float(int32_t(ui.encoderPosition)) * move_menu_scale;
const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale;
#if IS_KINEMATIC
ui.manual_move_offset += diff;
ui.manual_move.offset += diff;
if (int32_t(ui.encoderPosition) < 0)
NOLESS(ui.manual_move_offset, min - current_position[axis]);
NOLESS(ui.manual_move.offset, min - current_position[axis]);
else
NOMORE(ui.manual_move_offset, max - current_position[axis]);
NOMORE(ui.manual_move.offset, max - current_position[axis]);
#else
current_position[axis] += diff;
if (int32_t(ui.encoderPosition) < 0)
Expand All @@ -120,16 +105,16 @@ static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) {
NOMORE(current_position[axis], max);
#endif

manual_move_to_current(axis);
ui.manual_move.soon(axis);
ui.refresh(LCDVIEW_REDRAW_NOW);
}
ui.encoderPosition = 0;
if (ui.should_draw()) {
const float pos = NATIVE_TO_LOGICAL(
ui.processing_manual_move ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move_offset),
ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset),
axis
);
MenuEditItemBase::draw_edit_screen(name, move_menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr43sign(pos));
MenuEditItemBase::draw_edit_screen(name, ui.manual_move.menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr43sign(pos));
}
}
void lcd_move_x() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_X), X_AXIS); }
Expand All @@ -141,10 +126,10 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); }
static void lcd_move_e(TERN_(MULTI_MANUAL, const int8_t eindex=-1)) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
if (ui.encoderPosition) {
if (!ui.processing_manual_move) {
const float diff = float(int32_t(ui.encoderPosition)) * move_menu_scale;
TERN(IS_KINEMATIC, ui.manual_move_offset, current_position.e) += diff;
manual_move_to_current(E_AXIS
if (!ui.manual_move.processing) {
const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale;
TERN(IS_KINEMATIC, ui.manual_move.offset, current_position.e) += diff;
ui.manual_move.soon(E_AXIS
#if MULTI_MANUAL
, eindex
#endif
Expand All @@ -160,7 +145,7 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); }
MenuEditItemBase::draw_edit_screen(
GET_TEXT(TERN(MULTI_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)),
ftostr41sign(current_position.e
+ TERN0(IS_KINEMATIC, ui.manual_move_offset)
+ TERN0(IS_KINEMATIC, ui.manual_move.offset)
- TERN0(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin)
)
);
Expand All @@ -181,7 +166,7 @@ screenFunc_t _manual_move_func_ptr;

void _goto_manual_move(const float scale) {
ui.defer_status_screen();
move_menu_scale = scale;
ui.manual_move.menu_scale = scale;
ui.goto_screen(_manual_move_func_ptr);
}

Expand Down
Loading