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

Adjust axis homed / trusted methods #20323

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
9 changes: 4 additions & 5 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,14 @@ void GcodeSuite::G28() {

#endif

const float z_homing_height =
ENABLED(UNKNOWN_Z_NO_RAISE) && !TEST(axis_known_position, Z_AXIS)
? 0
: (parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT);
const float z_homing_height = TERN1(UNKNOWN_Z_NO_RAISE, axis_is_trusted(Z_AXIS))
? (parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT)
: 0;

if (z_homing_height && (doX || doY || TERN0(Z_SAFE_HOMING, doZ))) {
// Raise Z before homing any other axes and z is not already high enough (never lower z)
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height);
do_z_clearance(z_homing_height, true, DISABLED(UNKNOWN_Z_NO_RAISE));
do_z_clearance(z_homing_height, axis_is_trusted(Z_AXIS), DISABLED(UNKNOWN_Z_NO_RAISE));
}

#if ENABLED(QUICK_HOME)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/calibrate/G34.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
void GcodeSuite::G34() {

// Home before the alignment procedure
if (!all_axes_known()) home_all_axes();
if (!all_axes_trusted()) home_all_axes();

SET_SOFT_ENDSTOP_LOOSE(true);
TEMPORARY_BED_LEVELING_STATE(false);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/calibrate/G34_M422.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void GcodeSuite::G34() {
);

// Home before the alignment procedure
if (!all_axes_known()) home_all_axes();
if (!all_axes_trusted()) home_all_axes();

// Move the Z coordinate realm towards the positive - dirty trick
current_position.z += z_probe * 0.5f;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/feature/pause/M600.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void GcodeSuite::M600() {

#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
// If needed, home before parking for filament change
if (!all_axes_known()) home_all_axes();
if (!all_axes_trusted()) home_all_axes();
#endif

#if HAS_MULTI_EXTRUDER
Expand Down
12 changes: 4 additions & 8 deletions Marlin/src/gcode/feature/pause/M701_M702.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@
void GcodeSuite::M701() {
xyz_pos_t park_point = NOZZLE_PARK_POINT;

#if ENABLED(NO_MOTION_BEFORE_HOMING)
// Don't raise Z if the machine isn't homed
if (axes_should_home()) park_point.z = 0;
#endif
// Don't raise Z if the machine isn't homed
if (TERN0(NO_MOTION_BEFORE_HOMING, axes_should_home())) park_point.z = 0;

#if ENABLED(MIXING_EXTRUDER)
const int8_t target_e_stepper = get_target_e_stepper_from_command();
Expand Down Expand Up @@ -147,10 +145,8 @@ void GcodeSuite::M701() {
void GcodeSuite::M702() {
xyz_pos_t park_point = NOZZLE_PARK_POINT;

#if ENABLED(NO_MOTION_BEFORE_HOMING)
// Don't raise Z if the machine isn't homed
if (axes_should_home()) park_point.z = 0;
#endif
// Don't raise Z if the machine isn't homed
if (TERN0(NO_MOTION_BEFORE_HOMING, axes_should_home())) park_point.z = 0;

#if ENABLED(MIXING_EXTRUDER)
const uint8_t old_mixing_tool = mixer.get_current_vtool();
Expand Down
18 changes: 6 additions & 12 deletions Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,18 +506,12 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
lcd_put_wchar('X' + uint8_t(axis));
if (blink)
lcd_put_u8str(value);
else {
if (!TEST(axis_homed, axis))
while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
else {
#if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
if (!TEST(axis_known_position, axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
#endif
lcd_put_u8str(value);
}
}
else if (axis_should_home(axis))
while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
lcd_put_u8str(value);
}

FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) {
Expand Down
18 changes: 6 additions & 12 deletions Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,18 +422,12 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
lcd.write('X' + uint8_t(axis));
if (blink)
lcd.print(value);
else {
if (!TEST(axis_homed, axis))
while (const char c = *value++) lcd.write(c <= '.' ? c : '?');
else {
#if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
if (!TEST(axis_known_position, axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
#endif
lcd_put_u8str(value);
}
}
else if (axis_should_home(axis))
while (const char c = *value++) lcd.write(c <= '.' ? c : '?');
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
lcd_put_u8str(value);
}

FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *prefix, const bool blink) {
Expand Down
18 changes: 6 additions & 12 deletions Marlin/src/lcd/dogm/status_screen_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,12 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const

if (blink)
lcd_put_u8str(value);
else {
if (!TEST(axis_homed, axis))
while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
else {
#if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
if (!TEST(axis_known_position, axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
#endif
lcd_put_u8str(value);
}
}
else if (axis_should_home(axis))
while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
lcd_put_u8str(value);
}

/**
Expand Down
11 changes: 5 additions & 6 deletions Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,13 +659,13 @@ void ST7920_Lite_Status_Screen::draw_status_message() {
#endif
}

void ST7920_Lite_Status_Screen::draw_position(const xyze_pos_t &pos, const bool position_known) {
void ST7920_Lite_Status_Screen::draw_position(const xyze_pos_t &pos, const bool position_trusted) {
char str[7];
set_ddram_address(DDRAM_LINE_4);
begin_data();

// If position is unknown, flash the labels.
const unsigned char alt_label = position_known ? 0 : (ui.get_blink() ? ' ' : 0);
const unsigned char alt_label = position_trusted ? 0 : (ui.get_blink() ? ' ' : 0);

if (TERN1(LCD_SHOW_E_TOTAL, !printingIsActive())) {
write_byte(alt_label ? alt_label : 'X');
Expand Down Expand Up @@ -831,9 +831,8 @@ void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) {
}
}

if (countdown == 0 && (forceUpdate || position_changed()
|| TERN(DISABLE_REDUCED_ACCURACY_WARNING, 0, blink_changed())
)) draw_position(current_position, TERN(DISABLE_REDUCED_ACCURACY_WARNING, 1, all_axes_known()));
if (countdown == 0 && (forceUpdate || position_changed() || TERN(DISABLE_REDUCED_ACCURACY_WARNING, 0, blink_changed())))
draw_position(current_position, TERN(DISABLE_REDUCED_ACCURACY_WARNING, 1, all_axes_trusted()));
#endif
}

Expand All @@ -855,7 +854,7 @@ void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) {

UNUSED(forceUpdate);

#endif // LCD_SET_PROGRESS_MANUALLY || SDSUPPORT
#endif
}

void ST7920_Lite_Status_Screen::update(const bool forceUpdate) {
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/dwin/e3v2/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,8 +1281,7 @@ void HMI_Move_Z() {
last_zoffset = dwin_zoffset;
dwin_zoffset = HMI_ValueStruct.offset_value / 100.0f;
#if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP)
if ( (ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_known()) && (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy()) )
babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset);
if (BABYSTEP_ALLOWED()) babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset);
#endif
DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(zoff_line), HMI_ValueStruct.offset_value);
DWIN_UpdateLCD();
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/lcd/extui/ui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ namespace ExtUI {
bool canMove(const axis_t axis) {
switch (axis) {
#if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
case X: return TEST(axis_homed, X_AXIS);
case Y: return TEST(axis_homed, Y_AXIS);
case Z: return TEST(axis_homed, Z_AXIS);
case X: return axis_should_home(X_AXIS);
case Y: return axis_should_home(Y_AXIS);
case Z: return axis_should_home(Z_AXIS);
#else
case X: case Y: case Z: return true;
#endif
Expand Down Expand Up @@ -889,9 +889,9 @@ namespace ExtUI {

bool commandsInQueue() { return (planner.movesplanned() || queue.has_commands_queued()); }

bool isAxisPositionKnown(const axis_t axis) { return TEST(axis_known_position, axis); }
bool isAxisPositionKnown(const extruder_t) { return TEST(axis_known_position, E_AXIS); }
bool isPositionKnown() { return all_axes_known(); }
bool isAxisPositionKnown(const axis_t axis) { return axis_is_trusted((AxisEnum)axis); }
bool isAxisPositionKnown(const extruder_t) { return axis_is_trusted(E_AXIS); }
bool isPositionKnown() { return all_axes_trusted(); }
bool isMachineHomed() { return all_axes_homed(); }

PGM_P getFirmwareName_str() {
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
doubleclick_expire_ms = millis() + DOUBLECLICK_MAX_INTERVAL;
}
else if (screen == status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
if ( (ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_known())
&& (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy()) )
if (BABYSTEP_ALLOWED())
screen = TERN(BABYSTEP_ZPROBE_OFFSET, lcd_babystep_zoffset, lcd_babystep_z);
else {
#if ENABLED(MOVE_Z_WHEN_IDLE)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_bed_corners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ static inline void _lcd_level_bed_corners_homing() {

void _lcd_level_bed_corners() {
ui.defer_status_screen();
if (!all_axes_known()) {
if (!all_axes_trusted()) {
set_all_unhomed();
queue.inject_P(G28_STR);
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_bed_leveling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
* Save Settings (Req: EEPROM_SETTINGS)
*/
void menu_bed_leveling() {
const bool is_homed = all_axes_known(),
const bool is_homed = all_axes_trusted(),
is_valid = leveling_is_valid();

START_MENU();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void menu_advanced_settings();
void menu_tool_offsets() {

auto _recalc_offsets = []{
if (active_extruder && all_axes_known()) { // For the 2nd extruder re-home so the next tool-change gets the new offsets.
if (active_extruder && all_axes_trusted()) { // For the 2nd extruder re-home so the next tool-change gets the new offsets.
queue.inject_P(G28_STR); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
active_extruder = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_ubl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ void _ubl_map_screen_homing() {
*/
void _ubl_goto_map_screen() {
if (planner.movesplanned()) return; // The ACTION_ITEM will do nothing
if (!all_axes_known()) {
if (!all_axes_trusted()) {
set_all_unhomed();
queue.inject_P(G28_STR);
}
Expand Down
31 changes: 13 additions & 18 deletions Marlin/src/lcd/tft/ui_320x240.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,42 +257,37 @@ void MarlinUI::draw_status_screen() {
tft.set_background(COLOR_BACKGROUND);
tft.add_rectangle(0, 0, 312, 24, COLOR_AXIS_HOMED);

uint16_t color;
uint16_t offset;
bool is_homed;

tft.add_text( 10, 3, COLOR_AXIS_HOMED , "X");
tft.add_text(127, 3, COLOR_AXIS_HOMED , "Y");
tft.add_text(219, 3, COLOR_AXIS_HOMED , "Z");

is_homed = TEST(axis_homed, X_AXIS);
tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
tft.add_text( 68 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
bool not_homed = axis_should_home(X_AXIS);
tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
tft.add_text( 68 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);

is_homed = TEST(axis_homed, Y_AXIS);
tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
tft.add_text(185 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
not_homed = axis_should_home(Y_AXIS);
tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
tft.add_text(185 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);

is_homed = TEST(axis_homed, Z_AXIS);
if (blink & !is_homed) {
not_homed = axis_should_home(Z_AXIS);
uint16_t offset = 25;
if (blink && not_homed)
tft_string.set("?");
offset = 25; // ".00"
}
else {
const float z = LOGICAL_Z_POSITION(current_position.z);
tft_string.set(ftostr52sp((int16_t)z));
tft_string.rtrim();
offset = tft_string.width();
offset += tft_string.width();

tft_string.set(ftostr52sp(z));
offset += 25 - tft_string.width();
offset -= tft_string.width();
}
tft.add_text(301 - tft_string.width() - offset, 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
tft.add_text(301 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);

// feed rate
tft.canvas(70, 136, 80, 32);
tft.set_background(COLOR_BACKGROUND);
color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
tft.add_image(0, 0, imgFeedRate, color);
tft_string.set(i16tostr3rj(feedrate_percentage));
tft_string.add('%');
Expand Down
31 changes: 13 additions & 18 deletions Marlin/src/lcd/tft/ui_480x320.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,43 +262,38 @@ void MarlinUI::draw_status_screen() {
tft.set_background(COLOR_BACKGROUND);
tft.add_rectangle(0, 0, TFT_WIDTH - 8, 34, COLOR_AXIS_HOMED);

uint16_t color;
uint16_t offset;
bool is_homed;

tft.add_text( 16, 3, COLOR_AXIS_HOMED , "X");
tft.add_text(192, 3, COLOR_AXIS_HOMED , "Y");
tft.add_text(330, 3, COLOR_AXIS_HOMED , "Z");

is_homed = TEST(axis_homed, X_AXIS);
tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
tft.add_text(102 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
bool not_homed = axis_should_home(X_AXIS);
tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
tft.add_text(102 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);

is_homed = TEST(axis_homed, Y_AXIS);
tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
tft.add_text(280 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
not_homed = axis_should_home(Y_AXIS);
tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
tft.add_text(280 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);

is_homed = TEST(axis_homed, Z_AXIS);
if (blink & !is_homed) {
uint16_t offset = 32;
not_homed = axis_should_home(Z_AXIS);
if (blink && not_homed)
tft_string.set("?");
offset = 32; // ".00"
}
else {
const float z = LOGICAL_Z_POSITION(current_position.z);
tft_string.set(ftostr52sp((int16_t)z));
tft_string.rtrim();
offset = tft_string.width();
offset += tft_string.width();

tft_string.set(ftostr52sp(z));
offset += 32 - tft_string.width();
offset -= tft_string.width();
}
tft.add_text(455 - tft_string.width() - offset, 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
tft.add_text(455 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, 132, TFT_WIDTH - 8, 34));

// feed rate
tft.canvas(96, 180, 100, 32);
tft.set_background(COLOR_BACKGROUND);
color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
tft.add_image(0, 0, imgFeedRate, color);
tft_string.set(i16tostr3rj(feedrate_percentage));
tft_string.add('%');
Expand Down
Loading