Skip to content

Commit

Permalink
🐛 Fix Polargraph without Z (MarlinFirmware#25514)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbubik authored and EvilGremlin committed May 17, 2023
1 parent 9fda29a commit 1c3ca23
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 36 deletions.
3 changes: 1 addition & 2 deletions Marlin/src/feature/mmu/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
resume_hotend_temp = thermalManager.degTargetHotend(active_extruder);
resume_position = current_position;

if (move_axes && all_axes_homed())
nozzle.park(0, park_point /*= NOZZLE_PARK_POINT*/);
if (move_axes && all_axes_homed()) nozzle.park(0, park_point);

if (turn_off_nozzle) thermalManager.setTargetHotend(0, active_extruder);

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1148,11 +1148,11 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS

#if ENABLED(NOZZLE_PARK_FEATURE)
constexpr float npp[] = NOZZLE_PARK_POINT;
static_assert(COUNT(npp) == XYZ, "NOZZLE_PARK_POINT requires X, Y, and Z values.");
static_assert(COUNT(npp) == _MIN(NUM_AXES, XYZ), "NOZZLE_PARK_POINT requires coordinates for enabled axes, but only up to X,Y,Z.");
constexpr xyz_pos_t npp_xyz = NOZZLE_PARK_POINT;
static_assert(WITHIN(npp_xyz.x, X_MIN_POS, X_MAX_POS), "NOZZLE_PARK_POINT.X is out of bounds (X_MIN_POS, X_MAX_POS).");
static_assert(WITHIN(npp_xyz.y, Y_MIN_POS, Y_MAX_POS), "NOZZLE_PARK_POINT.Y is out of bounds (Y_MIN_POS, Y_MAX_POS).");
static_assert(WITHIN(npp_xyz.z, Z_MIN_POS, Z_MAX_POS), "NOZZLE_PARK_POINT.Z is out of bounds (Z_MIN_POS, Z_MAX_POS).");
static_assert(TERN1(HAS_Y_AXIS, WITHIN(npp_xyz.y, Y_MIN_POS, Y_MAX_POS)), "NOZZLE_PARK_POINT.Y is out of bounds (Y_MIN_POS, Y_MAX_POS).");
static_assert(TERN1(HAS_Z_AXIS, WITHIN(npp_xyz.z, Z_MIN_POS, Z_MAX_POS)), "NOZZLE_PARK_POINT.Z is out of bounds (Z_MIN_POS, Z_MAX_POS).");
#endif

/**
Expand Down
13 changes: 7 additions & 6 deletions Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
else if (axis_should_home(axis))
while (const char c = *value++) lcd_put_lchar(c <= '.' ? c : '?');
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" "));
lcd_put_u8str(TERN0(HAS_Z_AXIS, axis == Z_AXIS) ? F(" ") : F(" "));
else
lcd_put_u8str(value);
}
Expand Down Expand Up @@ -998,11 +998,12 @@ void MarlinUI::draw_status_screen() {

#endif // LCD_WIDTH >= 20

lcd_moveto(LCD_WIDTH - 8, 1);
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);

#if HAS_LEVELING && !HAS_HEATED_BED
lcd_put_lchar(planner.leveling_active || blink ? '_' : ' ');
#if HAS_Z_AXIS
lcd_moveto(LCD_WIDTH - 8, 1);
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
#if HAS_LEVELING && !HAS_HEATED_BED
lcd_put_lchar(planner.leveling_active || blink ? '_' : ' ');
#endif
#endif

#endif // LCD_HEIGHT > 2
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ void menu_backlash();
;

LOOP_LOGICAL_AXES(a) {
if (a == C_AXIS || TERN0(HAS_EXTRUDERS, a == E_AXIS))
if (TERN0(HAS_C_AXIS, a == C_AXIS) || TERN0(HAS_EXTRUDERS, a == E_AXIS))
EDIT_ITEM_FAST_N(float52sign, a, MSG_VN_JERK, &planner.max_jerk[a], 0.1f, max_jerk_edit[a]);
else
EDIT_ITEM_FAST_N(float3, a, MSG_VN_JERK, &planner.max_jerk[a], 1.0f, max_jerk_edit[a]);
Expand Down
51 changes: 28 additions & 23 deletions Marlin/src/libs/nozzle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,38 +225,43 @@ Nozzle nozzle;

#if ENABLED(NOZZLE_PARK_FEATURE)

float Nozzle::park_mode_0_height(const_float_t park_z) {
// Apply a minimum raise, if specified. Use park.z as a minimum height instead.
return _MAX(park_z, // Minimum height over 0 based on input
_MIN(Z_MAX_POS, // Maximum height is fixed
#ifdef NOZZLE_PARK_Z_RAISE_MIN
NOZZLE_PARK_Z_RAISE_MIN + // Minimum raise...
#endif
current_position.z // ...over current position
)
);
}
#if HAS_Z_AXIS
float Nozzle::park_mode_0_height(const_float_t park_z) {
// Apply a minimum raise, if specified. Use park.z as a minimum height instead.
return _MAX(park_z, // Minimum height over 0 based on input
_MIN(Z_MAX_POS, // Maximum height is fixed
#ifdef NOZZLE_PARK_Z_RAISE_MIN
NOZZLE_PARK_Z_RAISE_MIN + // Minimum raise...
#endif
current_position.z // ...over current position
)
);
}
#endif // HAS_Z_AXIS

void Nozzle::park(const uint8_t z_action, const xyz_pos_t &park/*=NOZZLE_PARK_POINT*/) {
constexpr feedRate_t fr_xy = NOZZLE_PARK_XY_FEEDRATE, fr_z = NOZZLE_PARK_Z_FEEDRATE;
#if HAS_Z_AXIS
constexpr feedRate_t fr_z = NOZZLE_PARK_Z_FEEDRATE;

switch (z_action) {
case 1: // Go to Z-park height
do_blocking_move_to_z(park.z, fr_z);
break;
switch (z_action) {
case 1: // Go to Z-park height
do_blocking_move_to_z(park.z, fr_z);
break;

case 2: // Raise by Z-park height
do_blocking_move_to_z(_MIN(current_position.z + park.z, Z_MAX_POS), fr_z);
break;
case 2: // Raise by Z-park height
do_blocking_move_to_z(_MIN(current_position.z + park.z, Z_MAX_POS), fr_z);
break;

default: // Raise by NOZZLE_PARK_Z_RAISE_MIN, use park.z as a minimum height
do_blocking_move_to_z(park_mode_0_height(park.z), fr_z);
break;
}
default: // Raise by NOZZLE_PARK_Z_RAISE_MIN, use park.z as a minimum height
do_blocking_move_to_z(park_mode_0_height(park.z), fr_z);
break;
}
#endif // HAS_Z_AXIS

#ifndef NOZZLE_PARK_MOVE
#define NOZZLE_PARK_MOVE 0
#endif
constexpr feedRate_t fr_xy = NOZZLE_PARK_XY_FEEDRATE;
switch (NOZZLE_PARK_MOVE) {
case 0: do_blocking_move_to_xy(park, fr_xy); break;
case 1: do_blocking_move_to_x(park.x, fr_xy); break;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/polargraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ xy_pos_t draw_area_min, draw_area_max;

void inverse_kinematics(const xyz_pos_t &raw) {
const float x1 = raw.x - draw_area_min.x, x2 = draw_area_max.x - raw.x, y = raw.y - draw_area_max.y;
delta.set(HYPOT(x1, y), HYPOT(x2, y), raw.z);
delta.set(HYPOT(x1, y), HYPOT(x2, y) OPTARG(HAS_Z_AXIS, raw.z));
}

#endif // POLARGRAPH

0 comments on commit 1c3ca23

Please sign in to comment.