mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 14:15:53 +08:00
Do not clamp travel acceleration when current firmware flavor does not allow separate setting of print and travel acceleration
This commit is contained in:
parent
51129fd4f3
commit
847a34c644
@ -3075,7 +3075,7 @@ std::string GCode::travel_to(const Point &point, ExtrusionRole role, std::string
|
|||||||
for (size_t i = 1; i < travel.size(); ++ i)
|
for (size_t i = 1; i < travel.size(); ++ i)
|
||||||
gcode += m_writer.travel_to_xy(this->point_to_gcode(travel.points[i]), comment);
|
gcode += m_writer.travel_to_xy(this->point_to_gcode(travel.points[i]), comment);
|
||||||
|
|
||||||
if (! m_writer.supports_PT()) {
|
if (! GCodeWriter::supports_separate_travel_acceleration(config().gcode_flavor)) {
|
||||||
// In case that this flavor does not support separate print and travel acceleration,
|
// In case that this flavor does not support separate print and travel acceleration,
|
||||||
// reset acceleration to default.
|
// reset acceleration to default.
|
||||||
gcode += m_writer.set_travel_acceleration((unsigned int)(m_config.travel_acceleration.value + 0.5));
|
gcode += m_writer.set_travel_acceleration((unsigned int)(m_config.travel_acceleration.value + 0.5));
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "libslic3r/Print.hpp"
|
#include "libslic3r/Print.hpp"
|
||||||
#include "libslic3r/LocalesUtils.hpp"
|
#include "libslic3r/LocalesUtils.hpp"
|
||||||
#include "libslic3r/format.hpp"
|
#include "libslic3r/format.hpp"
|
||||||
|
#include "libslic3r/GCodeWriter.hpp"
|
||||||
#include "GCodeProcessor.hpp"
|
#include "GCodeProcessor.hpp"
|
||||||
|
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
#include <boost/algorithm/string/case_conv.hpp>
|
||||||
@ -610,7 +611,12 @@ for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::
|
|||||||
float max_retract_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_retracting, i);
|
float max_retract_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_retracting, i);
|
||||||
m_time_processor.machines[i].max_retract_acceleration = max_retract_acceleration;
|
m_time_processor.machines[i].max_retract_acceleration = max_retract_acceleration;
|
||||||
m_time_processor.machines[i].retract_acceleration = (max_retract_acceleration > 0.0f) ? max_retract_acceleration : DEFAULT_RETRACT_ACCELERATION;
|
m_time_processor.machines[i].retract_acceleration = (max_retract_acceleration > 0.0f) ? max_retract_acceleration : DEFAULT_RETRACT_ACCELERATION;
|
||||||
|
|
||||||
float max_travel_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_travel, i);
|
float max_travel_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_travel, i);
|
||||||
|
if ( ! GCodeWriter::supports_separate_travel_acceleration(config.gcode_flavor.value) || config.machine_limits_usage.value != MachineLimitsUsage::EmitToGCode) {
|
||||||
|
// Only clamp travel acceleration when it is accessible in machine limits.
|
||||||
|
max_travel_acceleration = 0;
|
||||||
|
}
|
||||||
m_time_processor.machines[i].max_travel_acceleration = max_travel_acceleration;
|
m_time_processor.machines[i].max_travel_acceleration = max_travel_acceleration;
|
||||||
m_time_processor.machines[i].travel_acceleration = (max_travel_acceleration > 0.0f) ? max_travel_acceleration : DEFAULT_TRAVEL_ACCELERATION;
|
m_time_processor.machines[i].travel_acceleration = (max_travel_acceleration > 0.0f) ? max_travel_acceleration : DEFAULT_TRAVEL_ACCELERATION;
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
bool GCodeWriter::supports_PT() const
|
// static
|
||||||
|
bool GCodeWriter::supports_separate_travel_acceleration(GCodeFlavor flavor)
|
||||||
{
|
{
|
||||||
return (FLAVOR_IS(gcfRepetier) || FLAVOR_IS(gcfMarlinFirmware) || FLAVOR_IS(gcfRepRapFirmware));
|
return (flavor == gcfRepetier || flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeWriter::apply_print_config(const PrintConfig &print_config)
|
void GCodeWriter::apply_print_config(const PrintConfig &print_config)
|
||||||
@ -30,6 +31,8 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config)
|
|||||||
|| print_config.gcode_flavor.value == gcfRepRapFirmware;
|
|| print_config.gcode_flavor.value == gcfRepRapFirmware;
|
||||||
m_max_acceleration = static_cast<unsigned int>(std::round((use_mach_limits && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) ?
|
m_max_acceleration = static_cast<unsigned int>(std::round((use_mach_limits && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) ?
|
||||||
print_config.machine_max_acceleration_extruding.values.front() : 0));
|
print_config.machine_max_acceleration_extruding.values.front() : 0));
|
||||||
|
m_max_travel_acceleration = static_cast<unsigned int>(std::round((use_mach_limits && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode && supports_separate_travel_acceleration(print_config.gcode_flavor.value)) ?
|
||||||
|
print_config.machine_max_acceleration_travel.values.front() : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeWriter::set_extruders(std::vector<unsigned int> extruder_ids)
|
void GCodeWriter::set_extruders(std::vector<unsigned int> extruder_ids)
|
||||||
@ -163,12 +166,13 @@ std::string GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait
|
|||||||
std::string GCodeWriter::set_acceleration_internal(Acceleration type, unsigned int acceleration)
|
std::string GCodeWriter::set_acceleration_internal(Acceleration type, unsigned int acceleration)
|
||||||
{
|
{
|
||||||
// Clamp the acceleration to the allowed maximum.
|
// Clamp the acceleration to the allowed maximum.
|
||||||
// TODO: What about max travel acceleration ? Currently it is clamped by the extruding acceleration !!!
|
if (type == Acceleration::Print && m_max_acceleration > 0 && acceleration > m_max_acceleration)
|
||||||
if (m_max_acceleration > 0 && acceleration > m_max_acceleration)
|
|
||||||
acceleration = m_max_acceleration;
|
acceleration = m_max_acceleration;
|
||||||
|
if (type == Acceleration::Travel && m_max_travel_acceleration > 0 && acceleration > m_max_travel_acceleration)
|
||||||
|
acceleration = m_max_travel_acceleration;
|
||||||
|
|
||||||
// Are we setting travel acceleration for a flavour that supports separate travel and print acc?
|
// Are we setting travel acceleration for a flavour that supports separate travel and print acc?
|
||||||
bool separate_travel = (type == Acceleration::Travel && supports_PT());
|
bool separate_travel = (type == Acceleration::Travel && supports_separate_travel_acceleration(this->config.gcode_flavor));
|
||||||
|
|
||||||
auto& last_value = separate_travel ? m_last_travel_acceleration : m_last_acceleration ;
|
auto& last_value = separate_travel ? m_last_travel_acceleration : m_last_acceleration ;
|
||||||
if (acceleration == 0 || acceleration == last_value)
|
if (acceleration == 0 || acceleration == last_value)
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
Vec3d get_position() const { return m_pos; }
|
Vec3d get_position() const { return m_pos; }
|
||||||
|
|
||||||
// Returns whether this flavor supports separate print and travel acceleration.
|
// Returns whether this flavor supports separate print and travel acceleration.
|
||||||
bool supports_PT() const;
|
static bool supports_separate_travel_acceleration(GCodeFlavor flavor);
|
||||||
|
|
||||||
// To be called by the CoolingBuffer from another thread.
|
// To be called by the CoolingBuffer from another thread.
|
||||||
static std::string set_fan(const GCodeFlavor gcode_flavor, bool gcode_comments, unsigned int speed);
|
static std::string set_fan(const GCodeFlavor gcode_flavor, bool gcode_comments, unsigned int speed);
|
||||||
@ -90,6 +90,8 @@ private:
|
|||||||
// Limit for setting the acceleration, to respect the machine limits set for the Marlin firmware.
|
// Limit for setting the acceleration, to respect the machine limits set for the Marlin firmware.
|
||||||
// If set to zero, the limit is not in action.
|
// If set to zero, the limit is not in action.
|
||||||
unsigned int m_max_acceleration;
|
unsigned int m_max_acceleration;
|
||||||
|
unsigned int m_max_travel_acceleration;
|
||||||
|
|
||||||
unsigned int m_last_bed_temperature;
|
unsigned int m_last_bed_temperature;
|
||||||
bool m_last_bed_temperature_reached;
|
bool m_last_bed_temperature_reached;
|
||||||
double m_lifted;
|
double m_lifted;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
||||||
|
#include "libslic3r/GCodeWriter.hpp"
|
||||||
|
|
||||||
#include "slic3r/Utils/Http.hpp"
|
#include "slic3r/Utils/Http.hpp"
|
||||||
#include "slic3r/Utils/PrintHost.hpp"
|
#include "slic3r/Utils/PrintHost.hpp"
|
||||||
@ -2384,7 +2385,7 @@ void TabPrinter::build_fff()
|
|||||||
}
|
}
|
||||||
if (opt_key == "gcode_flavor") {
|
if (opt_key == "gcode_flavor") {
|
||||||
const GCodeFlavor flavor = static_cast<GCodeFlavor>(boost::any_cast<int>(value));
|
const GCodeFlavor flavor = static_cast<GCodeFlavor>(boost::any_cast<int>(value));
|
||||||
bool supports_travel_acceleration = (flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware);
|
bool supports_travel_acceleration = GCodeWriter::supports_separate_travel_acceleration(flavor);
|
||||||
bool supports_min_feedrates = (flavor == gcfMarlinFirmware || flavor == gcfMarlinLegacy);
|
bool supports_min_feedrates = (flavor == gcfMarlinFirmware || flavor == gcfMarlinLegacy);
|
||||||
if (supports_travel_acceleration != m_supports_travel_acceleration || supports_min_feedrates != m_supports_min_feedrates) {
|
if (supports_travel_acceleration != m_supports_travel_acceleration || supports_min_feedrates != m_supports_min_feedrates) {
|
||||||
m_rebuild_kinematics_page = true;
|
m_rebuild_kinematics_page = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user