Browse Source

Adjust axis homed / trusted methods (#20323)

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
448cf2c357
  1. 9
      Marlin/src/gcode/calibrate/G28.cpp
  2. 2
      Marlin/src/gcode/calibrate/G34.cpp
  3. 2
      Marlin/src/gcode/calibrate/G34_M422.cpp
  4. 2
      Marlin/src/gcode/feature/pause/M600.cpp
  5. 12
      Marlin/src/gcode/feature/pause/M701_M702.cpp
  6. 18
      Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
  7. 18
      Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
  8. 18
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp
  9. 11
      Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp
  10. 3
      Marlin/src/lcd/dwin/e3v2/dwin.cpp
  11. 12
      Marlin/src/lcd/extui/ui_api.cpp
  12. 3
      Marlin/src/lcd/menu/menu.cpp
  13. 2
      Marlin/src/lcd/menu/menu_bed_corners.cpp
  14. 2
      Marlin/src/lcd/menu/menu_bed_leveling.cpp
  15. 2
      Marlin/src/lcd/menu/menu_configuration.cpp
  16. 2
      Marlin/src/lcd/menu/menu_ubl.cpp
  17. 31
      Marlin/src/lcd/tft/ui_320x240.cpp
  18. 31
      Marlin/src/lcd/tft/ui_480x320.cpp
  19. 35
      Marlin/src/module/motion.cpp
  20. 40
      Marlin/src/module/motion.h
  21. 4
      Marlin/src/module/probe.cpp
  22. 8
      Marlin/src/module/stepper/indirection.h

9
Marlin/src/gcode/calibrate/G28.cpp

@ -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)

2
Marlin/src/gcode/calibrate/G34.cpp

@ -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);

2
Marlin/src/gcode/calibrate/G34_M422.cpp

@ -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;

2
Marlin/src/gcode/feature/pause/M600.cpp

@ -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

12
Marlin/src/gcode/feature/pause/M701_M702.cpp

@ -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();
@ -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();

18
Marlin/src/lcd/HD44780/marlinui_HD44780.cpp

@ -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) {

18
Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp

@ -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) {

18
Marlin/src/lcd/dogm/status_screen_DOGM.cpp

@ -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);
}
/**

11
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp

@ -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');
@ -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
}
@ -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) {

3
Marlin/src/lcd/dwin/e3v2/dwin.cpp

@ -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();

12
Marlin/src/lcd/extui/ui_api.cpp

@ -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
@ -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() {

3
Marlin/src/lcd/menu/menu.cpp

@ -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)

2
Marlin/src/lcd/menu/menu_bed_corners.cpp

@ -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);
}

2
Marlin/src/lcd/menu/menu_bed_leveling.cpp

@ -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();

2
Marlin/src/lcd/menu/menu_configuration.cpp

@ -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;
}

2
Marlin/src/lcd/menu/menu_ubl.cpp

@ -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);
}

31
Marlin/src/lcd/tft/ui_320x240.cpp

@ -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('%');

31
Marlin/src/lcd/tft/ui_480x320.cpp

@ -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('%');

35
Marlin/src/module/motion.cpp

@ -79,11 +79,11 @@
* Flags that each linear axis was homed.
* XYZ on cartesian, ABC on delta, ABZ on SCARA.
*
* axis_known_position
* Flags that the position is known in each linear axis. Set when homed.
* axis_trusted
* Flags that the position is trusted in each linear axis. Set when homed.
* Cleared whenever a stepper powers off, potentially losing its position.
*/
uint8_t axis_homed, axis_known_position; // = 0
uint8_t axis_homed, axis_trusted; // = 0
// Relative Mode. Enable with G91, disable with G90.
bool relative_mode; // = false;
@ -506,8 +506,8 @@ void do_blocking_move_to_xy_z(const xy_pos_t &raw, const float &z, const feedRat
do_blocking_move_to(raw.x, raw.y, z, fr_mm_s);
}
void do_z_clearance(const float &zclear, const bool z_known/*=true*/, const bool raise_on_unknown/*=true*/, const bool lower_allowed/*=false*/) {
const bool rel = raise_on_unknown && !z_known;
void do_z_clearance(const float &zclear, const bool z_trusted/*=true*/, const bool raise_on_untrusted/*=true*/, const bool lower_allowed/*=false*/) {
const bool rel = raise_on_untrusted && !z_trusted;
float zdest = zclear + (rel ? current_position.z : 0.0f);
if (!lower_allowed) NOLESS(zdest, current_position.z);
do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), MMM_TO_MMS(TERN(HAS_BED_PROBE, Z_PROBE_SPEED_FAST, HOMING_FEEDRATE_Z)));
@ -649,7 +649,7 @@ void restore_feedrate_and_scaling() {
constexpr xy_pos_t offs{0};
#endif
if (TERN1(IS_SCARA, TEST(axis_homed, X_AXIS) && TEST(axis_homed, Y_AXIS))) {
if (TERN1(IS_SCARA, axis_was_homed(X_AXIS) && axis_was_homed(Y_AXIS))) {
const float dist_2 = HYPOT2(target.x - offs.x, target.y - offs.y);
if (dist_2 > delta_max_radius_2)
target *= float(delta_max_radius / SQRT(dist_2)); // 200 / 300 = 0.66
@ -657,7 +657,7 @@ void restore_feedrate_and_scaling() {
#else
if (TEST(axis_homed, X_AXIS)) {
if (axis_was_homed(X_AXIS)) {
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_X)
NOLESS(target.x, soft_endstop.min.x);
#endif
@ -666,7 +666,7 @@ void restore_feedrate_and_scaling() {
#endif
}
if (TEST(axis_homed, Y_AXIS)) {
if (axis_was_homed(Y_AXIS)) {
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
NOLESS(target.y, soft_endstop.min.y);
#endif
@ -677,7 +677,7 @@ void restore_feedrate_and_scaling() {
#endif
if (TEST(axis_homed, Z_AXIS)) {
if (axis_was_homed(Z_AXIS)) {
#if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
NOLESS(target.z, soft_endstop.min.z);
#endif
@ -1124,10 +1124,11 @@ void prepare_line_to_destination() {
}
uint8_t axes_should_home(uint8_t axis_bits/*=0x07*/) {
#define SHOULD_HOME(A) TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(A)
// Clear test bits that are trusted
if (TEST(axis_bits, X_AXIS) && TEST(axis_homed, X_AXIS)) CBI(axis_bits, X_AXIS);
if (TEST(axis_bits, Y_AXIS) && TEST(axis_homed, Y_AXIS)) CBI(axis_bits, Y_AXIS);
if (TEST(axis_bits, Z_AXIS) && TEST(axis_homed, Z_AXIS)) CBI(axis_bits, Z_AXIS);
if (TEST(axis_bits, X_AXIS) && SHOULD_HOME(X_AXIS)) CBI(axis_bits, X_AXIS);
if (TEST(axis_bits, Y_AXIS) && SHOULD_HOME(Y_AXIS)) CBI(axis_bits, Y_AXIS);
if (TEST(axis_bits, Z_AXIS) && SHOULD_HOME(Z_AXIS)) CBI(axis_bits, Z_AXIS);
return axis_bits;
}
@ -1388,7 +1389,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
*
* DELTA should wait until all homing is done before setting the XYZ
* current_position to home, because homing is a single operation.
* In the case where the axis positions are already known and previously
* In the case where the axis positions are trusted and previously
* homed, DELTA could home to X or Y individually by moving either one
* to the center. However, homing Z always homes XY and Z.
*
@ -1401,8 +1402,8 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
void set_axis_is_at_home(const AxisEnum axis) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", axis_codes[axis], ")");
SBI(axis_known_position, axis);
SBI(axis_homed, axis);
set_axis_trusted(axis);
set_axis_homed(axis);
#if ENABLED(DUAL_X_CARRIAGE)
if (axis == X_AXIS && (active_extruder == 1 || dual_x_carriage_mode == DXC_DUPLICATION_MODE)) {
@ -1462,8 +1463,8 @@ void set_axis_is_at_home(const AxisEnum axis) {
void set_axis_never_homed(const AxisEnum axis) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", axis_codes[axis], ")");
CBI(axis_known_position, axis);
CBI(axis_homed, axis);
set_axis_untrusted(axis);
set_axis_unhomed(axis);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", axis_codes[axis], ")");

40
Marlin/src/module/motion.h

@ -34,19 +34,6 @@
#include "scara.h"
#endif
// Axis homed and known-position states
extern uint8_t axis_homed, axis_known_position;
constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);
FORCE_INLINE bool no_axes_homed() { return !axis_homed; }
FORCE_INLINE bool all_axes_homed() { return (axis_homed & xyz_bits) == xyz_bits; }
FORCE_INLINE bool all_axes_known() { return (axis_known_position & xyz_bits) == xyz_bits; }
FORCE_INLINE void set_all_homed() { axis_homed = axis_known_position = xyz_bits; }
FORCE_INLINE void set_all_unhomed() { axis_homed = axis_known_position = 0; }
FORCE_INLINE bool homing_needed() {
return !TERN(HOME_AFTER_DEACTIVATE, all_axes_known, all_axes_homed)();
}
// Error margin to work around float imprecision
constexpr float fslop = 0.0001;
@ -269,23 +256,42 @@ void remember_feedrate_and_scaling();
void remember_feedrate_scaling_off();
void restore_feedrate_and_scaling();
void do_z_clearance(const float &zclear, const bool z_known=true, const bool raise_on_unknown=true, const bool lower_allowed=false);
void do_z_clearance(const float &zclear, const bool z_trusted=true, const bool raise_on_untrusted=true, const bool lower_allowed=false);
/**
* Homing and Trusted Axes
*/
constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);
extern uint8_t axis_homed, axis_trusted;
//
// Homing
//
void homeaxis(const AxisEnum axis);
void set_axis_is_at_home(const AxisEnum axis);
void set_axis_never_homed(const AxisEnum axis);
uint8_t axes_should_home(uint8_t axis_bits=0x07);
bool homing_needed_error(uint8_t axis_bits=0x07);
FORCE_INLINE bool axis_was_homed(const AxisEnum axis) { return TEST(axis_homed, axis); }
FORCE_INLINE bool axis_is_trusted(const AxisEnum axis) { return TEST(axis_trusted, axis); }
FORCE_INLINE bool axis_should_home(const AxisEnum axis) { return (axes_should_home() & _BV(axis)) != 0; }
FORCE_INLINE bool no_axes_homed() { return !axis_homed; }
FORCE_INLINE bool all_axes_homed() { return xyz_bits == (axis_homed & xyz_bits); }
FORCE_INLINE bool homing_needed() { return !all_axes_homed(); }
FORCE_INLINE bool all_axes_trusted() { return xyz_bits == (axis_trusted & xyz_bits); }
FORCE_INLINE void set_axis_homed(const AxisEnum axis) { SBI(axis_homed, axis); }
FORCE_INLINE void set_axis_unhomed(const AxisEnum axis) { CBI(axis_homed, axis); }
FORCE_INLINE void set_axis_trusted(const AxisEnum axis) { SBI(axis_trusted, axis); }
FORCE_INLINE void set_axis_untrusted(const AxisEnum axis) { CBI(axis_trusted, axis); }
FORCE_INLINE void set_all_homed() { axis_homed = axis_trusted = xyz_bits; }
FORCE_INLINE void set_all_unhomed() { axis_homed = axis_trusted = 0; }
#if ENABLED(NO_MOTION_BEFORE_HOMING)
#define MOTION_CONDITIONS (IsRunning() && !homing_needed_error())
#else
#define MOTION_CONDITIONS IsRunning()
#endif
#define BABYSTEP_ALLOWED() ((ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_trusted()) && (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy()))
/**
* Workspace offsets
*/

4
Marlin/src/module/probe.cpp

@ -350,7 +350,7 @@ bool Probe::set_deployed(const bool deploy) {
// For beds that fall when Z is powered off only raise for trusted Z
#if ENABLED(UNKNOWN_Z_NO_RAISE)
const bool unknown_condition = TEST(axis_known_position, Z_AXIS);
const bool unknown_condition = axis_is_trusted(Z_AXIS);
#else
constexpr float unknown_condition = true;
#endif
@ -510,7 +510,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
// Stop the probe before it goes too low to prevent damage.
// If Z isn't known then probe to -10mm.
const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -offset.z + Z_PROBE_LOW_POINT : -10.0;
const float z_probe_low_point = axis_is_trusted(Z_AXIS) ? -offset.z + Z_PROBE_LOW_POINT : -10.0;
// Double-probing does a fast probe followed by a slow probe
#if TOTAL_PROBING == 2

8
Marlin/src/module/stepper/indirection.h

@ -856,13 +856,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#endif
#define ENABLE_AXIS_X() if (SHOULD_ENABLE(x)) { ENABLE_STEPPER_X(); ENABLE_STEPPER_X2(); AFTER_CHANGE(x, true); }
#define DISABLE_AXIS_X() if (SHOULD_DISABLE(x)) { DISABLE_STEPPER_X(); DISABLE_STEPPER_X2(); AFTER_CHANGE(x, false); FORGET_AXIS(X_AXIS); }
#define DISABLE_AXIS_X() if (SHOULD_DISABLE(x)) { DISABLE_STEPPER_X(); DISABLE_STEPPER_X2(); AFTER_CHANGE(x, false); set_axis_untrusted(X_AXIS); }
#define ENABLE_AXIS_Y() if (SHOULD_ENABLE(y)) { ENABLE_STEPPER_Y(); ENABLE_STEPPER_Y2(); AFTER_CHANGE(y, true); }
#define DISABLE_AXIS_Y() if (SHOULD_DISABLE(y)) { DISABLE_STEPPER_Y(); DISABLE_STEPPER_Y2(); AFTER_CHANGE(y, false); FORGET_AXIS(Y_AXIS); }
#define DISABLE_AXIS_Y() if (SHOULD_DISABLE(y)) { DISABLE_STEPPER_Y(); DISABLE_STEPPER_Y2(); AFTER_CHANGE(y, false); set_axis_untrusted(Y_AXIS); }
#define ENABLE_AXIS_Z() if (SHOULD_ENABLE(z)) { ENABLE_STEPPER_Z(); ENABLE_STEPPER_Z2(); ENABLE_STEPPER_Z3(); ENABLE_STEPPER_Z4(); AFTER_CHANGE(z, true); }
#define DISABLE_AXIS_Z() if (SHOULD_DISABLE(z)) { DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); AFTER_CHANGE(z, false); FORGET_AXIS(Z_AXIS); Z_RESET(); }
#define FORGET_AXIS(A) TERN(HOME_AFTER_DEACTIVATE, set_axis_never_homed(A), CBI(axis_known_position, A))
#define DISABLE_AXIS_Z() if (SHOULD_DISABLE(z)) { DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); AFTER_CHANGE(z, false); set_axis_untrusted(Z_AXIS); Z_RESET(); }
#ifdef Z_AFTER_DEACTIVATE
#define Z_RESET() do{ current_position.z = Z_AFTER_DEACTIVATE; sync_plan_position(); }while(0)

Loading…
Cancel
Save