Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1d45243

Browse files
jbubikdwzg
authored andcommittedMar 16, 2023
🐛 Fix Polargraph without Z (MarlinFirmware#25514)
1 parent 14b921d commit 1d45243

File tree

6 files changed

+41
-36
lines changed

6 files changed

+41
-36
lines changed
 

‎Marlin/src/feature/mmu/mmu2.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
815815
resume_hotend_temp = thermalManager.degTargetHotend(active_extruder);
816816
resume_position = current_position;
817817

818-
if (move_axes && all_axes_homed())
819-
nozzle.park(0, park_point /*= NOZZLE_PARK_POINT*/);
818+
if (move_axes && all_axes_homed()) nozzle.park(0, park_point);
820819

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

‎Marlin/src/inc/SanityCheck.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1148,11 +1148,11 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
11481148

11491149
#if ENABLED(NOZZLE_PARK_FEATURE)
11501150
constexpr float npp[] = NOZZLE_PARK_POINT;
1151-
static_assert(COUNT(npp) == XYZ, "NOZZLE_PARK_POINT requires X, Y, and Z values.");
1151+
static_assert(COUNT(npp) == _MIN(NUM_AXES, XYZ), "NOZZLE_PARK_POINT requires coordinates for enabled axes, but only up to X,Y,Z.");
11521152
constexpr xyz_pos_t npp_xyz = NOZZLE_PARK_POINT;
11531153
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).");
1154-
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).");
1155-
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).");
1154+
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).");
1155+
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).");
11561156
#endif
11571157

11581158
/**

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
521521
else if (axis_should_home(axis))
522522
while (const char c = *value++) lcd_put_lchar(c <= '.' ? c : '?');
523523
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
524-
lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" "));
524+
lcd_put_u8str(TERN0(HAS_Z_AXIS, axis == Z_AXIS) ? F(" ") : F(" "));
525525
else
526526
lcd_put_u8str(value);
527527
}
@@ -998,11 +998,12 @@ void MarlinUI::draw_status_screen() {
998998

999999
#endif // LCD_WIDTH >= 20
10001000

1001-
lcd_moveto(LCD_WIDTH - 8, 1);
1002-
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
1003-
1004-
#if HAS_LEVELING && !HAS_HEATED_BED
1005-
lcd_put_lchar(planner.leveling_active || blink ? '_' : ' ');
1001+
#if HAS_Z_AXIS
1002+
lcd_moveto(LCD_WIDTH - 8, 1);
1003+
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
1004+
#if HAS_LEVELING && !HAS_HEATED_BED
1005+
lcd_put_lchar(planner.leveling_active || blink ? '_' : ' ');
1006+
#endif
10061007
#endif
10071008

10081009
#endif // LCD_HEIGHT > 2

‎Marlin/src/lcd/menu/menu_advanced.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ void menu_backlash();
597597
;
598598

599599
LOOP_LOGICAL_AXES(a) {
600-
if (a == C_AXIS || TERN0(HAS_EXTRUDERS, a == E_AXIS))
600+
if (TERN0(HAS_C_AXIS, a == C_AXIS) || TERN0(HAS_EXTRUDERS, a == E_AXIS))
601601
EDIT_ITEM_FAST_N(float52sign, a, MSG_VN_JERK, &planner.max_jerk[a], 0.1f, max_jerk_edit[a]);
602602
else
603603
EDIT_ITEM_FAST_N(float3, a, MSG_VN_JERK, &planner.max_jerk[a], 1.0f, max_jerk_edit[a]);

‎Marlin/src/libs/nozzle.cpp

+28-23
Original file line numberDiff line numberDiff line change
@@ -225,38 +225,43 @@ Nozzle nozzle;
225225

226226
#if ENABLED(NOZZLE_PARK_FEATURE)
227227

228-
float Nozzle::park_mode_0_height(const_float_t park_z) {
229-
// Apply a minimum raise, if specified. Use park.z as a minimum height instead.
230-
return _MAX(park_z, // Minimum height over 0 based on input
231-
_MIN(Z_MAX_POS, // Maximum height is fixed
232-
#ifdef NOZZLE_PARK_Z_RAISE_MIN
233-
NOZZLE_PARK_Z_RAISE_MIN + // Minimum raise...
234-
#endif
235-
current_position.z // ...over current position
236-
)
237-
);
238-
}
228+
#if HAS_Z_AXIS
229+
float Nozzle::park_mode_0_height(const_float_t park_z) {
230+
// Apply a minimum raise, if specified. Use park.z as a minimum height instead.
231+
return _MAX(park_z, // Minimum height over 0 based on input
232+
_MIN(Z_MAX_POS, // Maximum height is fixed
233+
#ifdef NOZZLE_PARK_Z_RAISE_MIN
234+
NOZZLE_PARK_Z_RAISE_MIN + // Minimum raise...
235+
#endif
236+
current_position.z // ...over current position
237+
)
238+
);
239+
}
240+
#endif // HAS_Z_AXIS
239241

240242
void Nozzle::park(const uint8_t z_action, const xyz_pos_t &park/*=NOZZLE_PARK_POINT*/) {
241-
constexpr feedRate_t fr_xy = NOZZLE_PARK_XY_FEEDRATE, fr_z = NOZZLE_PARK_Z_FEEDRATE;
243+
#if HAS_Z_AXIS
244+
constexpr feedRate_t fr_z = NOZZLE_PARK_Z_FEEDRATE;
242245

243-
switch (z_action) {
244-
case 1: // Go to Z-park height
245-
do_blocking_move_to_z(park.z, fr_z);
246-
break;
246+
switch (z_action) {
247+
case 1: // Go to Z-park height
248+
do_blocking_move_to_z(park.z, fr_z);
249+
break;
247250

248-
case 2: // Raise by Z-park height
249-
do_blocking_move_to_z(_MIN(current_position.z + park.z, Z_MAX_POS), fr_z);
250-
break;
251+
case 2: // Raise by Z-park height
252+
do_blocking_move_to_z(_MIN(current_position.z + park.z, Z_MAX_POS), fr_z);
253+
break;
251254

252-
default: // Raise by NOZZLE_PARK_Z_RAISE_MIN, use park.z as a minimum height
253-
do_blocking_move_to_z(park_mode_0_height(park.z), fr_z);
254-
break;
255-
}
255+
default: // Raise by NOZZLE_PARK_Z_RAISE_MIN, use park.z as a minimum height
256+
do_blocking_move_to_z(park_mode_0_height(park.z), fr_z);
257+
break;
258+
}
259+
#endif // HAS_Z_AXIS
256260

257261
#ifndef NOZZLE_PARK_MOVE
258262
#define NOZZLE_PARK_MOVE 0
259263
#endif
264+
constexpr feedRate_t fr_xy = NOZZLE_PARK_XY_FEEDRATE;
260265
switch (NOZZLE_PARK_MOVE) {
261266
case 0: do_blocking_move_to_xy(park, fr_xy); break;
262267
case 1: do_blocking_move_to_x(park.x, fr_xy); break;

‎Marlin/src/module/polargraph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ xy_pos_t draw_area_min, draw_area_max;
4343

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

4949
#endif // POLARGRAPH

0 commit comments

Comments
 (0)
Please sign in to comment.