mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 23:17:35 -06:00
ENH: add jerk parameter
thanks SoftFever Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: I6aadbffebc069167a460c991aa8fb711b754ff37
This commit is contained in:
parent
208f7c32da
commit
aa62c6e870
12 changed files with 189 additions and 14 deletions
|
@ -26,6 +26,7 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config)
|
|||
|| print_config.gcode_flavor.value == gcfMarlinFirmware
|
||||
|| print_config.gcode_flavor.value == gcfKlipper;
|
||||
m_max_acceleration = std::lrint(is_marlin ? print_config.machine_max_acceleration_extruding.values.front() : 0);
|
||||
m_max_jerk = std::lrint(is_marlin ? std::min(print_config.machine_max_jerk_x.values.front(), print_config.machine_max_jerk_y.values.front()) : 0);
|
||||
}
|
||||
|
||||
void GCodeWriter::set_extruders(std::vector<unsigned int> extruder_ids)
|
||||
|
@ -203,6 +204,27 @@ std::string GCodeWriter::set_pressure_advance(double pa) const
|
|||
return gcode.str();
|
||||
}
|
||||
|
||||
std::string GCodeWriter::set_jerk_xy(double jerk)
|
||||
{
|
||||
// Clamp the jerk to the allowed maximum.
|
||||
if (m_max_jerk > 0 && jerk > m_max_jerk) jerk = m_max_jerk;
|
||||
|
||||
if (jerk < 0.01 || is_approx(jerk, m_last_jerk)) return std::string();
|
||||
|
||||
m_last_jerk = jerk;
|
||||
|
||||
std::ostringstream gcode;
|
||||
if (FLAVOR_IS(gcfKlipper))
|
||||
gcode << "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=" << jerk;
|
||||
else
|
||||
gcode << "M205 X" << jerk << " Y" << jerk;
|
||||
|
||||
if (GCodeWriter::full_gcode_comment) gcode << " ; adjust jerk";
|
||||
gcode << "\n";
|
||||
|
||||
return gcode.str();
|
||||
}
|
||||
|
||||
std::string GCodeWriter::reset_e(bool force)
|
||||
{
|
||||
if (FLAVOR_IS(gcfMach3)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue