From 6460b5c00420dd4f1f922c6046df27bbe5246047 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 10 Jul 2022 23:40:32 -0500 Subject: [PATCH] merge followup --- Marlin/src/gcode/bedlevel/G26.cpp | 2 +- Marlin/src/module/motion.cpp | 12 ++++---- Marlin/src/module/motion.h | 49 ++++++++++++++++--------------- Marlin/src/module/polargraph.cpp | 7 +++-- Marlin/src/module/polargraph.h | 3 +- 5 files changed, 39 insertions(+), 34 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 21fa08fc107a0..1e436ffd969f5 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -306,7 +306,7 @@ typedef struct { LIMIT(e.x, X_MIN_POS + 1, X_MAX_POS - 1); #endif - if (position_is_reachable(s.x, s.y) && position_is_reachable(e.x, e.y)) + if (position_is_reachable(s) && position_is_reachable(e)) print_line_from_here_to_there(s, e); } } diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 2acb3a319b90b..d485b9ca3d6f5 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -301,13 +301,13 @@ void report_current_position_projected() { #endif #if ENABLED(POLARGRAPH) -bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset/*=0*/) { - const float x1 = rx - (draw_area_min.x), x2 = (draw_area_max.x) - rx, y = ry - (draw_area_max.y), - a = HYPOT(x1, y), b = HYPOT(x2, y); - return a < (polargraph_max_belt_len) + 1 - && b < (polargraph_max_belt_len) + 1 + bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset/*=0*/) { + const float x1 = rx - (draw_area_min.x), x2 = (draw_area_max.x) - rx, + y = ry - (draw_area_max.y), a = HYPOT(x1, y), b = HYPOT(x2, y); + return a < polargraph_max_belt_len + 1 + && b < polargraph_max_belt_len + 1 && (a + b) > _MIN(draw_area_size.x, draw_area_size.y); -} + } #endif void home_if_needed(const bool keeplev/*=false*/) { diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 7203b74eb26c0..591ac6e96d91f 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -549,39 +549,42 @@ void home_if_needed(const bool keeplev=false); #endif #if ENABLED(POLARGRAPH) + + // Return true if the given point is within the printable area bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset=0); + #else - // Return true if the given point is within the printable area - inline bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset=0) { - #if ENABLED(DELTA) + inline bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset=0) { + #if ENABLED(DELTA) - return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS - inset + fslop); + return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS - inset + fslop); - #elif ENABLED(AXEL_TPARA) + #elif ENABLED(AXEL_TPARA) - const float R2 = HYPOT2(rx - TPARA_OFFSET_X, ry - TPARA_OFFSET_Y); - return ( - R2 <= sq(L1 + L2) - inset - #if MIDDLE_DEAD_ZONE_R > 0 - && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) - #endif - ); + const float R2 = HYPOT2(rx - TPARA_OFFSET_X, ry - TPARA_OFFSET_Y); + return ( + R2 <= sq(L1 + L2) - inset + #if MIDDLE_DEAD_ZONE_R > 0 + && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) + #endif + ); - #elif IS_SCARA + #elif IS_SCARA - const float R2 = HYPOT2(rx - SCARA_OFFSET_X, ry - SCARA_OFFSET_Y); - return ( - R2 <= sq(L1 + L2) - inset - #if MIDDLE_DEAD_ZONE_R > 0 - && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) - #endif - ); + const float R2 = HYPOT2(rx - SCARA_OFFSET_X, ry - SCARA_OFFSET_Y); + return ( + R2 <= sq(L1 + L2) - inset + #if MIDDLE_DEAD_ZONE_R > 0 + && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) + #endif + ); + + #endif + } - #endif - } #endif - + inline bool position_is_reachable(const xy_pos_t &pos, const float inset=0) { return position_is_reachable(pos.x, pos.y, inset); } diff --git a/Marlin/src/module/polargraph.cpp b/Marlin/src/module/polargraph.cpp index 32719cfe1197e..42f99304d7899 100644 --- a/Marlin/src/module/polargraph.cpp +++ b/Marlin/src/module/polargraph.cpp @@ -38,9 +38,12 @@ #include "../MarlinCore.h" float segments_per_second; // Initialized by settings.load() -xy_pos_t draw_area_min = { X_MIN_POS, Y_MIN_POS }; -xy_pos_t draw_area_max = { X_MAX_POS, Y_MAX_POS }; + +xy_pos_t draw_area_min = { X_MIN_POS, Y_MIN_POS }, + draw_area_max = { X_MAX_POS, Y_MAX_POS }; + xy_float_t draw_area_size = { X_MAX_POS - X_MIN_POS, Y_MAX_POS - Y_MIN_POS }; + float polargraph_max_belt_len = HYPOT(draw_area_size.x, draw_area_size.y); void inverse_kinematics(const xyz_pos_t &raw) { diff --git a/Marlin/src/module/polargraph.h b/Marlin/src/module/polargraph.h index 1725725ea6064..b465de32874c3 100644 --- a/Marlin/src/module/polargraph.h +++ b/Marlin/src/module/polargraph.h @@ -29,8 +29,7 @@ #include "../core/macros.h" extern float segments_per_second; -extern xy_pos_t draw_area_min; -extern xy_pos_t draw_area_max; +extern xy_pos_t draw_area_min, draw_area_max; extern xy_float_t draw_area_size; extern float polargraph_max_belt_len;