🐛 Fix and improve Polargraph (#24847)

Co-Authored-By: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Dan Royer
2022-10-15 22:03:42 -07:00
committed by Scott Lahteine
parent b3e7d1e91e
commit 031ff2d024
13 changed files with 109 additions and 41 deletions

View File

@ -341,7 +341,6 @@ void report_current_position_projected() {
can_reach = (
a < polargraph_max_belt_len + 1
&& b < polargraph_max_belt_len + 1
&& (a + b) > _MIN(draw_area_size.x, draw_area_size.y)
);
#endif
@ -562,7 +561,8 @@ void do_blocking_move_to(NUM_AXIS_ARGS(const float), const_feedRate_t fr_mm_s/*=
const feedRate_t w_feedrate = fr_mm_s ?: homing_feedrate(W_AXIS)
);
#if IS_KINEMATIC
#if IS_KINEMATIC && DISABLED(POLARGRAPH)
// kinematic machines are expected to home to a point 1.5x their range? never reachable.
if (!position_is_reachable(x, y)) return;
destination = current_position; // sync destination at the start
#endif
@ -919,11 +919,16 @@ void restore_feedrate_and_scaling() {
constexpr xy_pos_t offs{0};
#endif
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
}
#if ENABLED(POLARGRAPH)
LIMIT(target.x, draw_area_min.x, draw_area_max.x);
LIMIT(target.y, draw_area_min.y, draw_area_max.y);
#else
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
}
#endif
#else

View File

@ -2244,7 +2244,6 @@ bool Planner::_populate_block(
TERN_(MIXING_EXTRUDER, mixer.populate_block(block->b_color));
#if HAS_FAN
FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i];
#endif

View File

@ -37,17 +37,12 @@
#include "../lcd/marlinui.h"
#include "../MarlinCore.h"
float segments_per_second; // Initialized by settings.load()
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);
// Initialized by settings.load()
float segments_per_second, polargraph_max_belt_len;
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);
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);
}

View File

@ -30,7 +30,6 @@
extern float segments_per_second;
extern xy_pos_t draw_area_min, draw_area_max;
extern xy_float_t draw_area_size;
extern float polargraph_max_belt_len;
void inverse_kinematics(const xyz_pos_t &raw);

View File

@ -257,7 +257,7 @@ typedef struct SettingsDataStruct {
// HAS_BED_PROBE
//
xyz_pos_t probe_offset;
xyz_pos_t probe_offset; // M851 X Y Z
//
// ABL_PLANAR
@ -319,7 +319,7 @@ typedef struct SettingsDataStruct {
#endif
//
// Kinematic Settings
// Kinematic Settings (Delta, SCARA, TPARA, Polargraph...)
//
#if IS_KINEMATIC
float segments_per_second; // M665 S
@ -330,7 +330,11 @@ typedef struct SettingsDataStruct {
delta_diagonal_rod; // M665 L
abc_float_t delta_tower_angle_trim, // M665 X Y Z
delta_diagonal_rod_trim; // M665 A B C
#elif ENABLED(POLARGRAPH)
xy_pos_t draw_area_min, draw_area_max; // M665 L R T B
float polargraph_max_belt_len; // M665 H
#endif
#endif
//
@ -468,7 +472,7 @@ typedef struct SettingsDataStruct {
//
// SKEW_CORRECTION
//
skew_factor_t planner_skew_factor; // M852 I J K planner.skew_factor
skew_factor_t planner_skew_factor; // M852 I J K
//
// ADVANCED_PAUSE_FEATURE
@ -988,7 +992,7 @@ void MarlinSettings::postprocess() {
}
//
// Kinematic Settings
// Kinematic Settings (Delta, SCARA, TPARA, Polargraph...)
//
#if IS_KINEMATIC
{
@ -1001,6 +1005,11 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(delta_diagonal_rod); // 1 float
EEPROM_WRITE(delta_tower_angle_trim); // 3 floats
EEPROM_WRITE(delta_diagonal_rod_trim); // 3 floats
#elif ENABLED(POLARGRAPH)
_FIELD_TEST(draw_area_min);
EEPROM_WRITE(draw_area_min); // 2 floats
EEPROM_WRITE(draw_area_max); // 2 floats
EEPROM_WRITE(polargraph_max_belt_len); // 1 float
#endif
}
#endif
@ -1923,7 +1932,7 @@ void MarlinSettings::postprocess() {
}
//
// Kinematic Segments-per-second
// Kinematic Settings (Delta, SCARA, TPARA, Polargraph...)
//
#if IS_KINEMATIC
{
@ -1936,6 +1945,11 @@ void MarlinSettings::postprocess() {
EEPROM_READ(delta_diagonal_rod); // 1 float
EEPROM_READ(delta_tower_angle_trim); // 3 floats
EEPROM_READ(delta_diagonal_rod_trim); // 3 floats
#elif ENABLED(POLARGRAPH)
_FIELD_TEST(draw_area_min);
EEPROM_READ(draw_area_min); // 2 floats
EEPROM_READ(draw_area_max); // 2 floats
EEPROM_READ(polargraph_max_belt_len); // 1 float
#endif
}
#endif
@ -2979,7 +2993,7 @@ void MarlinSettings::reset() {
#endif
//
// Kinematic settings
// Kinematic Settings (Delta, SCARA, TPARA, Polargraph...)
//
#if IS_KINEMATIC
@ -2996,6 +3010,10 @@ void MarlinSettings::reset() {
delta_diagonal_rod = DELTA_DIAGONAL_ROD;
delta_tower_angle_trim = dta;
delta_diagonal_rod_trim = ddr;
#elif ENABLED(POLARGRAPH)
draw_area_min.set(X_MIN_POS, Y_MIN_POS);
draw_area_max.set(X_MAX_POS, Y_MAX_POS);
polargraph_max_belt_len = POLARGRAPH_MAX_BELT_LEN;
#endif
#endif
@ -3492,9 +3510,7 @@ void MarlinSettings::reset() {
//
// LCD Preheat Settings
//
#if HAS_PREHEAT
gcode.M145_report(forReplay);
#endif
TERN_(HAS_PREHEAT, gcode.M145_report(forReplay));
//
// PID