Extend M217 with configurable park/raise (#12076)
This commit is contained in:
@ -36,25 +36,41 @@ void M217_report(const bool eeprom=false) {
|
||||
const int16_t port = command_queue_port[cmd_queue_index_r];
|
||||
#endif
|
||||
serialprintPGM_P(port, eeprom ? PSTR(" M217") : PSTR("Singlenozzle:"));
|
||||
SERIAL_ECHOPAIR_P(port, " S", sn_settings.swap_length);
|
||||
SERIAL_ECHOPAIR_P(port, " P", sn_settings.prime_speed);
|
||||
SERIAL_ECHOLNPAIR_P(port, " R", sn_settings.retract_speed);
|
||||
SERIAL_ECHOPAIR_P(port, " S", LINEAR_UNIT(sn_settings.swap_length));
|
||||
SERIAL_ECHOPAIR_P(port, " P", LINEAR_UNIT(sn_settings.prime_speed));
|
||||
SERIAL_ECHOPAIR_P(port, " R", LINEAR_UNIT(sn_settings.retract_speed));
|
||||
#if ENABLED(SINGLENOZZLE_SWAP_PARK)
|
||||
SERIAL_ECHOPAIR_P(port, " X", LINEAR_UNIT(sn_settings.change_point.x));
|
||||
SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(sn_settings.change_point.y));
|
||||
#endif
|
||||
SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(sn_settings.z_raise));
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
/**
|
||||
* M217 - Set SINGLENOZZLE toolchange parameters
|
||||
*
|
||||
* S[mm] Swap length
|
||||
* P[mm/m] Prime speed
|
||||
* R[mm/m] Retract speed
|
||||
* S[linear] Swap length
|
||||
* P[linear/m] Prime speed
|
||||
* R[linear/m] Retract speed
|
||||
* X[linear] Park X (Requires SINGLENOZZLE_SWAP_PARK)
|
||||
* Y[linear] Park Y (Requires SINGLENOZZLE_SWAP_PARK)
|
||||
* Z[linear] Z Raise
|
||||
*/
|
||||
void GcodeSuite::M217() {
|
||||
|
||||
bool report = true;
|
||||
|
||||
if (parser.seenval('S')) { report = false; const float v = parser.value_float(); sn_settings.swap_length = constrain(v, 0, 500); }
|
||||
if (parser.seenval('P')) { report = false; const int16_t v = parser.value_int(); sn_settings.prime_speed = constrain(v, 10, 5400); }
|
||||
if (parser.seenval('R')) { report = false; const int16_t v = parser.value_int(); sn_settings.retract_speed = constrain(v, 10, 5400); }
|
||||
if (parser.seenval('S')) { report = false; const float v = parser.value_linear_units(); sn_settings.swap_length = constrain(v, 0, 500); }
|
||||
if (parser.seenval('P')) { report = false; const int16_t v = parser.value_linear_units(); sn_settings.prime_speed = constrain(v, 10, 5400); }
|
||||
if (parser.seenval('R')) { report = false; const int16_t v = parser.value_linear_units(); sn_settings.retract_speed = constrain(v, 10, 5400); }
|
||||
|
||||
#if ENABLED(SINGLENOZZLE_SWAP_PARK)
|
||||
if (parser.seenval('X')) { report = false; sn_settings.change_point.x = parser.value_linear_units(); }
|
||||
if (parser.seenval('Y')) { report = false; sn_settings.change_point.y = parser.value_linear_units(); }
|
||||
#endif
|
||||
|
||||
if (parser.seenval('Z')) { report = false; sn_settings.z_raise = parser.value_linear_units(); }
|
||||
|
||||
if (report) M217_report();
|
||||
|
||||
|
@ -36,7 +36,7 @@ void GcodeSuite::M92() {
|
||||
LOOP_XYZE(i) {
|
||||
if (parser.seen(axis_codes[i])) {
|
||||
if (i == E_AXIS) {
|
||||
const float value = parser.value_per_axis_unit((AxisEnum)(E_AXIS + TARGET_EXTRUDER));
|
||||
const float value = parser.value_per_axis_units((AxisEnum)(E_AXIS + TARGET_EXTRUDER));
|
||||
if (value < 20) {
|
||||
float factor = planner.settings.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
|
||||
#if HAS_CLASSIC_JERK && (DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE))
|
||||
@ -48,7 +48,7 @@ void GcodeSuite::M92() {
|
||||
planner.settings.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] = value;
|
||||
}
|
||||
else {
|
||||
planner.settings.axis_steps_per_mm[i] = parser.value_per_axis_unit((AxisEnum)i);
|
||||
planner.settings.axis_steps_per_mm[i] = parser.value_per_axis_units((AxisEnum)i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -224,6 +224,9 @@ public:
|
||||
|
||||
#if ENABLED(INCH_MODE_SUPPORT)
|
||||
|
||||
static inline float mm_to_linear_unit(const float mm) { return mm / linear_unit_factor; }
|
||||
static inline float mm_to_volumetric_unit(const float mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); }
|
||||
|
||||
// Init linear units by constructor
|
||||
GCodeParser() { set_input_linear_units(LINEARUNIT_MM); }
|
||||
|
||||
@ -244,18 +247,28 @@ public:
|
||||
return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
|
||||
}
|
||||
|
||||
static inline float value_linear_units() { return value_float() * linear_unit_factor; }
|
||||
static inline float value_axis_units(const AxisEnum axis) { return value_float() * axis_unit_factor(axis); }
|
||||
static inline float value_per_axis_unit(const AxisEnum axis) { return value_float() / axis_unit_factor(axis); }
|
||||
FORCE_INLINE static float linear_value_to_mm(const float v) { return v * linear_unit_factor; }
|
||||
FORCE_INLINE static float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); }
|
||||
FORCE_INLINE static float per_axis_value(const AxisEnum axis, const float v) { return v / axis_unit_factor(axis); }
|
||||
|
||||
#else
|
||||
|
||||
FORCE_INLINE static float value_linear_units() { return value_float(); }
|
||||
FORCE_INLINE static float value_axis_units(const AxisEnum a) { UNUSED(a); return value_float(); }
|
||||
FORCE_INLINE static float value_per_axis_unit(const AxisEnum a) { UNUSED(a); return value_float(); }
|
||||
FORCE_INLINE static float mm_to_linear_unit(const float mm) { return mm; }
|
||||
FORCE_INLINE static float mm_to_volumetric_unit(const float mm) { return mm; }
|
||||
|
||||
FORCE_INLINE static float linear_value_to_mm(const float v) { return v; }
|
||||
FORCE_INLINE static float axis_value_to_mm(const AxisEnum axis, const float v) { UNUSED(axis); return v; }
|
||||
FORCE_INLINE static float per_axis_value(const AxisEnum axis, const float v) { UNUSED(axis); return v; }
|
||||
|
||||
#endif
|
||||
|
||||
#define LINEAR_UNIT(V) parser.mm_to_linear_unit(V)
|
||||
#define VOLUMETRIC_UNIT(V) parser.mm_to_volumetric_unit(V)
|
||||
|
||||
static inline float value_linear_units() { return linear_value_to_mm(value_float()); }
|
||||
static inline float value_axis_units(const AxisEnum axis) { return axis_value_to_mm(axis, value_float()); }
|
||||
static inline float value_per_axis_units(const AxisEnum axis) { return per_axis_value(axis, value_float()); }
|
||||
|
||||
#if ENABLED(TEMPERATURE_UNITS_SUPPORT)
|
||||
|
||||
static inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
|
||||
@ -306,11 +319,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#define TEMP_UNIT(N) parser.to_temp_units(N)
|
||||
|
||||
#else // !TEMPERATURE_UNITS_SUPPORT
|
||||
|
||||
FORCE_INLINE static float value_celsius() { return value_float(); }
|
||||
FORCE_INLINE static float value_celsius_diff() { return value_float(); }
|
||||
|
||||
#define TEMP_UNIT(N) (N)
|
||||
|
||||
#endif // !TEMPERATURE_UNITS_SUPPORT
|
||||
|
||||
FORCE_INLINE static float value_feedrate() { return value_linear_units(); }
|
||||
|
Reference in New Issue
Block a user