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

Use Z-offset editing precision based on value limits #16425

Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 10 additions & 2 deletions Marlin/src/lcd/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,18 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
if (ui.should_draw()) {
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
if (!do_probe)
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), ftostr43sign(hotend_offset[active_extruder].z));
#if (Z_PROBE_OFFSET_RANGE_MIN < -9 || Z_PROBE_OFFSET_RANGE_MAX > 9)
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), ftostr52sign(hotend_offset[active_extruder].z));
#else
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), ftostr54sign(hotend_offset[active_extruder].z));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand ftostr54sign. How can that handle 9 digits but the others only handle 7?

Is ftostr54sign actually getting cropped to ftostr43sign elsewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<= -10.0 no ? 9.025 may be wanted :p

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preprocessor doesn't handle float math well so I kept it to closest int since im tossing it together at my desk between other things and not testing atm :)

Copy link
Contributor

@tpruvot tpruvot Jan 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right ok.. anyway, i dont really think the problem is there for the ABL issue.. maybe it could just be float vs double issue in the compensation code ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tpruvot there may still be other leveling problems. This is addressing an issue where you enter an edit screen which cannot handle the present value of the number, and the only way to exit the screen is to save the value shown on the screen, which is incorrect.

#endif
else
#endif
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), ftostr43sign(probe_offset.z));
#if (Z_PROBE_OFFSET_RANGE_MIN < -9 || Z_PROBE_OFFSET_RANGE_MAX > 9)
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), ftostr52sign(probe_offset.z));
#else
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), ftostr54sign(probe_offset.z));
#endif

#if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
if (do_probe) _lcd_zoffset_overlay_gfx(probe_offset.z);
Expand Down
6 changes: 5 additions & 1 deletion Marlin/src/lcd/menu/menu_bed_leveling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@ void menu_bed_leveling() {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
#elif HAS_BED_PROBE
EDIT_ITEM(float52, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#if (Z_PROBE_OFFSET_RANGE_MIN < -9 || Z_PROBE_OFFSET_RANGE_MAX > 9)
EDIT_ITEM(float52, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#else
EDIT_ITEM(float43, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#endif
#endif

#if ENABLED(LEVEL_BED_CORNERS)
Expand Down
6 changes: 5 additions & 1 deletion Marlin/src/lcd/menu/menu_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,11 @@ void menu_configuration() {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
#elif HAS_BED_PROBE
EDIT_ITEM(float52, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#if (Z_PROBE_OFFSET_RANGE_MIN < -9 || Z_PROBE_OFFSET_RANGE_MAX > 9)
EDIT_ITEM(float52, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#else
EDIT_ITEM(float43, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#endif
#endif

const bool busy = printer_busy();
Expand Down
12 changes: 10 additions & 2 deletions Marlin/src/lcd/menu/menu_tune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@
}
if (ui.should_draw()) {
const float spm = planner.steps_to_mm[axis];
MenuEditItemBase::draw_edit_screen(msg, ftostr54sign(spm * babystep.accum));
#if (Z_PROBE_OFFSET_RANGE_MIN < -9 || Z_PROBE_OFFSET_RANGE_MAX > 9)
MenuEditItemBase::draw_edit_screen(msg, ftostr52sign(spm * babystep.accum));
#else
MenuEditItemBase::draw_edit_screen(msg, ftostr54sign(spm * babystep.accum));
#endif
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
const bool in_view = (true
#if HAS_GRAPHICAL_LCD
Expand All @@ -81,7 +85,11 @@
#endif
lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
lcd_put_wchar(':');
lcd_put_u8str(ftostr54sign(spm * babystep.axis_total[BS_TOTAL_AXIS(axis)]));
#if (Z_PROBE_OFFSET_RANGE_MIN < -9 || Z_PROBE_OFFSET_RANGE_MAX > 9)
lcd_put_u8str(ftostr52sign(spm * babystep.axis_total[BS_TOTAL_AXIS(axis)]));
#else
lcd_put_u8str(ftostr54sign(spm * babystep.axis_total[BS_TOTAL_AXIS(axis)]));
#endif
}
#endif
}
Expand Down