Merge branch 'lm_marlin_split' (#1089, #1234)

This commit is contained in:
Lukas Matena 2021-04-06 15:46:02 +02:00
commit 2418b3dbeb
11 changed files with 148 additions and 46 deletions

View file

@ -784,7 +784,8 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* re
namespace DoExport { namespace DoExport {
static void init_gcode_processor(const PrintConfig& config, GCodeProcessor& processor, bool& silent_time_estimator_enabled) static void init_gcode_processor(const PrintConfig& config, GCodeProcessor& processor, bool& silent_time_estimator_enabled)
{ {
silent_time_estimator_enabled = (config.gcode_flavor == gcfMarlin) && config.silent_mode; silent_time_estimator_enabled = (config.gcode_flavor == gcfMarlinLegacy || config.gcode_flavor == gcfMarlinFirmware)
&& config.silent_mode;
processor.reset(); processor.reset();
processor.apply_config(config); processor.apply_config(config);
processor.enable_stealth_time_estimator(silent_time_estimator_enabled); processor.enable_stealth_time_estimator(silent_time_estimator_enabled);
@ -1355,7 +1356,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
bbox_prime.offset(0.5f); bbox_prime.offset(0.5f);
bool overlap = bbox_prime.overlap(bbox_print); bool overlap = bbox_prime.overlap(bbox_print);
if (print.config().gcode_flavor == gcfMarlin) { if (print.config().gcode_flavor == gcfMarlinLegacy || print.config().gcode_flavor == gcfMarlinFirmware) {
_write(file, this->retract()); _write(file, this->retract());
_write(file, "M300 S800 P500\n"); // Beep for 500ms, tone 800Hz. _write(file, "M300 S800 P500\n"); // Beep for 500ms, tone 800Hz.
if (overlap) { if (overlap) {
@ -1558,7 +1559,8 @@ static bool custom_gcode_sets_temperature(const std::string &gcode, const int mc
// Do not process this piece of G-code by the time estimator, it already knows the values through another sources. // Do not process this piece of G-code by the time estimator, it already knows the values through another sources.
void GCode::print_machine_envelope(FILE *file, Print &print) void GCode::print_machine_envelope(FILE *file, Print &print)
{ {
if (print.config().gcode_flavor.value == gcfMarlin && print.config().machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) { if ((print.config().gcode_flavor.value == gcfMarlinLegacy || print.config().gcode_flavor.value == gcfMarlinFirmware)
&& print.config().machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) {
fprintf(file, "M201 X%d Y%d Z%d E%d ; sets maximum accelerations, mm/sec^2\n", fprintf(file, "M201 X%d Y%d Z%d E%d ; sets maximum accelerations, mm/sec^2\n",
int(print.config().machine_max_acceleration_x.values.front() + 0.5), int(print.config().machine_max_acceleration_x.values.front() + 0.5),
int(print.config().machine_max_acceleration_y.values.front() + 0.5), int(print.config().machine_max_acceleration_y.values.front() + 0.5),
@ -1569,10 +1571,20 @@ void GCode::print_machine_envelope(FILE *file, Print &print)
int(print.config().machine_max_feedrate_y.values.front() + 0.5), int(print.config().machine_max_feedrate_y.values.front() + 0.5),
int(print.config().machine_max_feedrate_z.values.front() + 0.5), int(print.config().machine_max_feedrate_z.values.front() + 0.5),
int(print.config().machine_max_feedrate_e.values.front() + 0.5)); int(print.config().machine_max_feedrate_e.values.front() + 0.5));
// Now M204 - acceleration. This one is quite hairy thanks to how Marlin guys care about
// backwards compatibility: https://github.com/prusa3d/PrusaSlicer/issues/1089
// Legacy Marlin should export travel acceleration the same as printing acceleration.
// MarlinFirmware has the two separated.
int travel_acc = print.config().gcode_flavor == gcfMarlinLegacy
? int(print.config().machine_max_acceleration_extruding.values.front() + 0.5)
: int(print.config().machine_max_acceleration_travel.values.front() + 0.5);
fprintf(file, "M204 P%d R%d T%d ; sets acceleration (P, T) and retract acceleration (R), mm/sec^2\n", fprintf(file, "M204 P%d R%d T%d ; sets acceleration (P, T) and retract acceleration (R), mm/sec^2\n",
int(print.config().machine_max_acceleration_extruding.values.front() + 0.5), int(print.config().machine_max_acceleration_extruding.values.front() + 0.5),
int(print.config().machine_max_acceleration_retracting.values.front() + 0.5), int(print.config().machine_max_acceleration_retracting.values.front() + 0.5),
int(print.config().machine_max_acceleration_extruding.values.front() + 0.5)); travel_acc);
fprintf(file, "M205 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/sec\n", fprintf(file, "M205 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/sec\n",
print.config().machine_max_jerk_x.values.front(), print.config().machine_max_jerk_x.values.front(),
print.config().machine_max_jerk_y.values.front(), print.config().machine_max_jerk_y.values.front(),

View file

@ -26,6 +26,7 @@
static const float INCHES_TO_MM = 25.4f; static const float INCHES_TO_MM = 25.4f;
static const float MMMIN_TO_MMSEC = 1.0f / 60.0f; static const float MMMIN_TO_MMSEC = 1.0f / 60.0f;
static const float DEFAULT_ACCELERATION = 1500.0f; // Prusa Firmware 1_75mm_MK2 static const float DEFAULT_ACCELERATION = 1500.0f; // Prusa Firmware 1_75mm_MK2
static const float DEFAULT_TRAVEL_ACCELERATION = 1250.0f;
namespace Slic3r { namespace Slic3r {
@ -190,6 +191,8 @@ void GCodeProcessor::TimeMachine::reset()
enabled = false; enabled = false;
acceleration = 0.0f; acceleration = 0.0f;
max_acceleration = 0.0f; max_acceleration = 0.0f;
travel_acceleration = 0.0f;
max_travel_acceleration = 0.0f;
extrude_factor_override_percentage = 1.0f; extrude_factor_override_percentage = 1.0f;
time = 0.0f; time = 0.0f;
#if ENABLE_EXTENDED_M73_LINES #if ENABLE_EXTENDED_M73_LINES
@ -823,8 +826,13 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
m_filament_diameters[i] = static_cast<float>(config.filament_diameter.values[i]); m_filament_diameters[i] = static_cast<float>(config.filament_diameter.values[i]);
} }
if (m_flavor == gcfMarlin && config.machine_limits_usage.value != MachineLimitsUsage::Ignore) if ((m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware) && config.machine_limits_usage.value != MachineLimitsUsage::Ignore) {
m_time_processor.machine_limits = reinterpret_cast<const MachineEnvelopeConfig&>(config); m_time_processor.machine_limits = reinterpret_cast<const MachineEnvelopeConfig&>(config);
if (m_flavor == gcfMarlinLegacy) {
// Legacy Marlin does not have separate travel acceleration, it uses the 'extruding' value instead.
m_time_processor.machine_limits.machine_max_acceleration_travel = m_time_processor.machine_limits.machine_max_acceleration_extruding;
}
}
// Filament load / unload times are not specific to a firmware flavor. Let anybody use it if they find it useful. // Filament load / unload times are not specific to a firmware flavor. Let anybody use it if they find it useful.
// As of now the fields are shown at the UI dialog in the same combo box as the ramming values, so they // As of now the fields are shown at the UI dialog in the same combo box as the ramming values, so they
@ -842,6 +850,9 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
float max_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_extruding, i); float max_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_extruding, i);
m_time_processor.machines[i].max_acceleration = max_acceleration; m_time_processor.machines[i].max_acceleration = max_acceleration;
m_time_processor.machines[i].acceleration = (max_acceleration > 0.0f) ? max_acceleration : DEFAULT_ACCELERATION; m_time_processor.machines[i].acceleration = (max_acceleration > 0.0f) ? max_acceleration : DEFAULT_ACCELERATION;
float max_travel_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_travel, i);
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.export_remaining_time_enabled = config.remaining_times.value; m_time_processor.export_remaining_time_enabled = config.remaining_times.value;
@ -934,7 +945,7 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
} }
} }
if (m_flavor == gcfMarlin) { if (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware) {
const ConfigOptionFloats* machine_max_acceleration_x = config.option<ConfigOptionFloats>("machine_max_acceleration_x"); const ConfigOptionFloats* machine_max_acceleration_x = config.option<ConfigOptionFloats>("machine_max_acceleration_x");
if (machine_max_acceleration_x != nullptr) if (machine_max_acceleration_x != nullptr)
m_time_processor.machine_limits.machine_max_acceleration_x.values = machine_max_acceleration_x->values; m_time_processor.machine_limits.machine_max_acceleration_x.values = machine_max_acceleration_x->values;
@ -991,6 +1002,15 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
if (machine_max_acceleration_retracting != nullptr) if (machine_max_acceleration_retracting != nullptr)
m_time_processor.machine_limits.machine_max_acceleration_retracting.values = machine_max_acceleration_retracting->values; m_time_processor.machine_limits.machine_max_acceleration_retracting.values = machine_max_acceleration_retracting->values;
// Legacy Marlin does not have separate travel acceleration, it uses the 'extruding' value instead.
const ConfigOptionFloats* machine_max_acceleration_travel = config.option<ConfigOptionFloats>(m_flavor == gcfMarlinLegacy
? "machine_max_acceleration_extruding"
: "machine_max_acceleration_travel");
if (machine_max_acceleration_travel != nullptr)
m_time_processor.machine_limits.machine_max_acceleration_travel.values = machine_max_acceleration_travel->values;
const ConfigOptionFloats* machine_min_extruding_rate = config.option<ConfigOptionFloats>("machine_min_extruding_rate"); const ConfigOptionFloats* machine_min_extruding_rate = config.option<ConfigOptionFloats>("machine_min_extruding_rate");
if (machine_min_extruding_rate != nullptr) if (machine_min_extruding_rate != nullptr)
m_time_processor.machine_limits.machine_min_extruding_rate.values = machine_min_extruding_rate->values; m_time_processor.machine_limits.machine_min_extruding_rate.values = machine_min_extruding_rate->values;
@ -1004,6 +1024,9 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
float max_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_extruding, i); float max_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_extruding, i);
m_time_processor.machines[i].max_acceleration = max_acceleration; m_time_processor.machines[i].max_acceleration = max_acceleration;
m_time_processor.machines[i].acceleration = (max_acceleration > 0.0f) ? max_acceleration : DEFAULT_ACCELERATION; m_time_processor.machines[i].acceleration = (max_acceleration > 0.0f) ? max_acceleration : DEFAULT_ACCELERATION;
float max_travel_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_travel, i);
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;
} }
if (m_time_processor.machine_limits.machine_max_acceleration_x.values.size() > 1) if (m_time_processor.machine_limits.machine_max_acceleration_x.values.size() > 1)
@ -1646,23 +1669,23 @@ bool GCodeProcessor::process_cura_tags(const std::string_view comment)
if (pos != comment.npos) { if (pos != comment.npos) {
const std::string_view flavor = comment.substr(pos + tag.length()); const std::string_view flavor = comment.substr(pos + tag.length());
if (flavor == "BFB") if (flavor == "BFB")
m_flavor = gcfMarlin; // << ??????????????????????? m_flavor = gcfMarlinLegacy; // is this correct ?
else if (flavor == "Mach3") else if (flavor == "Mach3")
m_flavor = gcfMach3; m_flavor = gcfMach3;
else if (flavor == "Makerbot") else if (flavor == "Makerbot")
m_flavor = gcfMakerWare; m_flavor = gcfMakerWare;
else if (flavor == "UltiGCode") else if (flavor == "UltiGCode")
m_flavor = gcfMarlin; // << ??????????????????????? m_flavor = gcfMarlinLegacy; // is this correct ?
else if (flavor == "Marlin(Volumetric)") else if (flavor == "Marlin(Volumetric)")
m_flavor = gcfMarlin; // << ??????????????????????? m_flavor = gcfMarlinLegacy; // is this correct ?
else if (flavor == "Griffin") else if (flavor == "Griffin")
m_flavor = gcfMarlin; // << ??????????????????????? m_flavor = gcfMarlinLegacy; // is this correct ?
else if (flavor == "Repetier") else if (flavor == "Repetier")
m_flavor = gcfRepetier; m_flavor = gcfRepetier;
else if (flavor == "RepRap") else if (flavor == "RepRap")
m_flavor = gcfRepRapFirmware; m_flavor = gcfRepRapFirmware;
else if (flavor == "Marlin") else if (flavor == "Marlin")
m_flavor = gcfMarlin; m_flavor = gcfMarlinLegacy;
else else
BOOST_LOG_TRIVIAL(warning) << "GCodeProcessor found unknown flavor: " << flavor; BOOST_LOG_TRIVIAL(warning) << "GCodeProcessor found unknown flavor: " << flavor;
@ -2226,9 +2249,11 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
} }
// calculates block acceleration // calculates block acceleration
float acceleration = is_extrusion_only_move(delta_pos) ? float acceleration =
get_retract_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i)) : (type == EMoveType::Travel) ? get_travel_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i)) :
get_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i)); (is_extrusion_only_move(delta_pos) ?
get_retract_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i)) :
get_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i)));
for (unsigned char a = X; a <= E; ++a) { for (unsigned char a = X; a <= E; ++a) {
float axis_max_acceleration = get_axis_max_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i), static_cast<Axis>(a)); float axis_max_acceleration = get_axis_max_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i), static_cast<Axis>(a));
@ -2575,7 +2600,7 @@ void GCodeProcessor::process_M203(const GCodeReader::GCodeLine& line)
// see http://reprap.org/wiki/G-code#M203:_Set_maximum_feedrate // see http://reprap.org/wiki/G-code#M203:_Set_maximum_feedrate
// http://smoothieware.org/supported-g-codes // http://smoothieware.org/supported-g-codes
float factor = (m_flavor == gcfMarlin || m_flavor == gcfSmoothie) ? 1.0f : MMMIN_TO_MMSEC; float factor = (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware || m_flavor == gcfSmoothie) ? 1.0f : MMMIN_TO_MMSEC;
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedTimeStatistics::ETimeMode::Count); ++i) { for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedTimeStatistics::ETimeMode::Count); ++i) {
if (static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i) == PrintEstimatedTimeStatistics::ETimeMode::Normal || if (static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i) == PrintEstimatedTimeStatistics::ETimeMode::Normal ||
@ -2602,10 +2627,11 @@ void GCodeProcessor::process_M204(const GCodeReader::GCodeLine& line)
if (static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i) == PrintEstimatedTimeStatistics::ETimeMode::Normal || if (static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i) == PrintEstimatedTimeStatistics::ETimeMode::Normal ||
m_time_processor.machine_envelope_processing_enabled) { m_time_processor.machine_envelope_processing_enabled) {
if (line.has_value('S', value)) { if (line.has_value('S', value)) {
// Legacy acceleration format. This format is used by the legacy Marlin, MK2 or MK3 firmware, // Legacy acceleration format. This format is used by the legacy Marlin, MK2 or MK3 firmware
// and it is also generated by Slic3r to control acceleration per extrusion type // It is also generated by PrusaSlicer to control acceleration per extrusion type
// (there is a separate acceleration settings in Slicer for perimeter, first layer etc). // (perimeters, first layer etc) when 'Marlin (legacy)' flavor is used.
set_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i), value); set_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i), value);
set_travel_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i), value);
if (line.has_value('T', value)) if (line.has_value('T', value))
set_option_value(m_time_processor.machine_limits.machine_max_acceleration_retracting, i, value); set_option_value(m_time_processor.machine_limits.machine_max_acceleration_retracting, i, value);
} }
@ -2615,11 +2641,9 @@ void GCodeProcessor::process_M204(const GCodeReader::GCodeLine& line)
set_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i), value); set_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i), value);
if (line.has_value('R', value)) if (line.has_value('R', value))
set_option_value(m_time_processor.machine_limits.machine_max_acceleration_retracting, i, value); set_option_value(m_time_processor.machine_limits.machine_max_acceleration_retracting, i, value);
if (line.has_value('T', value)) { if (line.has_value('T', value))
// Interpret the T value as the travel acceleration in the new Marlin format. // Interpret the T value as the travel acceleration in the new Marlin format.
//FIXME Prusa3D firmware currently does not support travel acceleration value independent from the extruding acceleration value. set_travel_acceleration(static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i), value);
// set_travel_acceleration(value);
}
} }
} }
} }
@ -2749,7 +2773,7 @@ void GCodeProcessor::process_T(const std::string_view command)
int eid = 0; int eid = 0;
if (! parse_number(command.substr(1), eid) || eid < 0 || eid > 255) { if (! parse_number(command.substr(1), eid) || eid < 0 || eid > 255) {
// Specific to the MMU2 V2 (see https://www.help.prusa3d.com/en/article/prusa-specific-g-codes_112173): // Specific to the MMU2 V2 (see https://www.help.prusa3d.com/en/article/prusa-specific-g-codes_112173):
if (m_flavor == gcfMarlin && (command == "Tx" || command == "Tc" || command == "T?")) if ((m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware) && (command == "Tx" || command == "Tc" || command == "T?"))
return; return;
// T-1 is a valid gcode line for RepRap Firmwares (used to deselects all tools) see https://github.com/prusa3d/PrusaSlicer/issues/5677 // T-1 is a valid gcode line for RepRap Firmwares (used to deselects all tools) see https://github.com/prusa3d/PrusaSlicer/issues/5677
@ -2890,6 +2914,22 @@ void GCodeProcessor::set_acceleration(PrintEstimatedTimeStatistics::ETimeMode mo
} }
} }
float GCodeProcessor::get_travel_acceleration(PrintEstimatedTimeStatistics::ETimeMode mode) const
{
size_t id = static_cast<size_t>(mode);
return (id < m_time_processor.machines.size()) ? m_time_processor.machines[id].travel_acceleration : DEFAULT_TRAVEL_ACCELERATION;
}
void GCodeProcessor::set_travel_acceleration(PrintEstimatedTimeStatistics::ETimeMode mode, float value)
{
size_t id = static_cast<size_t>(mode);
if (id < m_time_processor.machines.size()) {
m_time_processor.machines[id].travel_acceleration = (m_time_processor.machines[id].max_travel_acceleration == 0.0f) ? value :
// Clamp the acceleration with the maximum.
std::min(value, m_time_processor.machines[id].max_travel_acceleration);
}
}
float GCodeProcessor::get_filament_load_time(size_t extruder_id) float GCodeProcessor::get_filament_load_time(size_t extruder_id)
{ {
return (m_time_processor.filament_load_times.empty() || m_time_processor.extruder_unloaded) ? return (m_time_processor.filament_load_times.empty() || m_time_processor.extruder_unloaded) ?

View file

@ -251,6 +251,9 @@ namespace Slic3r {
float acceleration; // mm/s^2 float acceleration; // mm/s^2
// hard limit for the acceleration, to which the firmware will clamp. // hard limit for the acceleration, to which the firmware will clamp.
float max_acceleration; // mm/s^2 float max_acceleration; // mm/s^2
float travel_acceleration; // mm/s^2
// hard limit for the travel acceleration, to which the firmware will clamp.
float max_travel_acceleration; // mm/s^2
float extrude_factor_override_percentage; float extrude_factor_override_percentage;
float time; // s float time; // s
#if ENABLE_EXTENDED_M73_LINES #if ENABLE_EXTENDED_M73_LINES
@ -668,7 +671,9 @@ namespace Slic3r {
float get_axis_max_jerk(PrintEstimatedTimeStatistics::ETimeMode mode, Axis axis) const; float get_axis_max_jerk(PrintEstimatedTimeStatistics::ETimeMode mode, Axis axis) const;
float get_retract_acceleration(PrintEstimatedTimeStatistics::ETimeMode mode) const; float get_retract_acceleration(PrintEstimatedTimeStatistics::ETimeMode mode) const;
float get_acceleration(PrintEstimatedTimeStatistics::ETimeMode mode) const; float get_acceleration(PrintEstimatedTimeStatistics::ETimeMode mode) const;
void set_acceleration(PrintEstimatedTimeStatistics::ETimeMode mode, float value); void set_acceleration(PrintEstimatedTimeStatistics::ETimeMode mode, float value);
float get_travel_acceleration(PrintEstimatedTimeStatistics::ETimeMode mode) const;
void set_travel_acceleration(PrintEstimatedTimeStatistics::ETimeMode mode, float value);
float get_filament_load_time(size_t extruder_id); float get_filament_load_time(size_t extruder_id);
float get_filament_unload_time(size_t extruder_id); float get_filament_unload_time(size_t extruder_id);

View file

@ -342,7 +342,7 @@ public:
WipeTowerWriter& speed_override_backup() WipeTowerWriter& speed_override_backup()
{ {
// This is only supported by Prusa at this point (https://github.com/prusa3d/PrusaSlicer/issues/3114) // This is only supported by Prusa at this point (https://github.com/prusa3d/PrusaSlicer/issues/3114)
if (m_gcode_flavor == gcfMarlin) if (m_gcode_flavor == gcfMarlinLegacy || m_gcode_flavor == gcfMarlinFirmware)
m_gcode += "M220 B\n"; m_gcode += "M220 B\n";
return *this; return *this;
} }
@ -350,7 +350,7 @@ public:
// Let the firmware restore the active speed override value. // Let the firmware restore the active speed override value.
WipeTowerWriter& speed_override_restore() WipeTowerWriter& speed_override_restore()
{ {
if (m_gcode_flavor == gcfMarlin) if (m_gcode_flavor == gcfMarlinLegacy || m_gcode_flavor == gcfMarlinFirmware)
m_gcode += "M220 R\n"; m_gcode += "M220 R\n";
return *this; return *this;
} }

View file

@ -20,7 +20,8 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config)
this->config.apply(print_config, true); this->config.apply(print_config, true);
m_extrusion_axis = this->config.get_extrusion_axis(); m_extrusion_axis = this->config.get_extrusion_axis();
m_single_extruder_multi_material = print_config.single_extruder_multi_material.value; m_single_extruder_multi_material = print_config.single_extruder_multi_material.value;
m_max_acceleration = std::lrint((print_config.gcode_flavor.value == gcfMarlin && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) ? bool is_marlin = print_config.gcode_flavor.value == gcfMarlinLegacy || print_config.gcode_flavor.value == gcfMarlinFirmware;
m_max_acceleration = std::lrint((is_marlin && 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);
} }
@ -48,7 +49,8 @@ std::string GCodeWriter::preamble()
} }
if (FLAVOR_IS(gcfRepRapSprinter) || if (FLAVOR_IS(gcfRepRapSprinter) ||
FLAVOR_IS(gcfRepRapFirmware) || FLAVOR_IS(gcfRepRapFirmware) ||
FLAVOR_IS(gcfMarlin) || FLAVOR_IS(gcfMarlinLegacy) ||
FLAVOR_IS(gcfMarlinFirmware) ||
FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfTeacup) ||
FLAVOR_IS(gcfRepetier) || FLAVOR_IS(gcfRepetier) ||
FLAVOR_IS(gcfSmoothie)) FLAVOR_IS(gcfSmoothie))
@ -205,8 +207,12 @@ std::string GCodeWriter::set_acceleration(unsigned int acceleration)
// M202: Set max travel acceleration // M202: Set max travel acceleration
gcode << "M202 X" << acceleration << " Y" << acceleration; gcode << "M202 X" << acceleration << " Y" << acceleration;
} else if (FLAVOR_IS(gcfRepRapFirmware)) { } else if (FLAVOR_IS(gcfRepRapFirmware)) {
// M204: Set default acceleration // M204: Set default acceleration
gcode << "M204 P" << acceleration; gcode << "M204 P" << acceleration;
} else if (FLAVOR_IS(gcfMarlinFirmware)) {
// This is new MarlinFirmware with separated print/retraction/travel acceleration.
// Use M204 P, we don't want to override travel acc by M204 S (which is deprecated anyway).
gcode << "M204 P" << acceleration;
} else { } else {
// M204: Set default acceleration // M204: Set default acceleration
gcode << "M204 S" << acceleration; gcode << "M204 S" << acceleration;

View file

@ -468,7 +468,7 @@ const std::vector<std::string>& Preset::machine_limits_options()
static std::vector<std::string> s_opts; static std::vector<std::string> s_opts;
if (s_opts.empty()) { if (s_opts.empty()) {
s_opts = { s_opts = {
"machine_max_acceleration_extruding", "machine_max_acceleration_retracting", "machine_max_acceleration_extruding", "machine_max_acceleration_retracting", "machine_max_acceleration_travel",
"machine_max_acceleration_x", "machine_max_acceleration_y", "machine_max_acceleration_z", "machine_max_acceleration_e", "machine_max_acceleration_x", "machine_max_acceleration_y", "machine_max_acceleration_z", "machine_max_acceleration_e",
"machine_max_feedrate_x", "machine_max_feedrate_y", "machine_max_feedrate_z", "machine_max_feedrate_e", "machine_max_feedrate_x", "machine_max_feedrate_y", "machine_max_feedrate_z", "machine_max_feedrate_e",
"machine_min_extruding_rate", "machine_min_travel_rate", "machine_min_extruding_rate", "machine_min_travel_rate",

View file

@ -1293,7 +1293,7 @@ std::string Print::validate(std::string* warning) const
} }
if (m_config.gcode_flavor != gcfRepRapSprinter && m_config.gcode_flavor != gcfRepRapFirmware && if (m_config.gcode_flavor != gcfRepRapSprinter && m_config.gcode_flavor != gcfRepRapFirmware &&
m_config.gcode_flavor != gcfRepetier && m_config.gcode_flavor != gcfMarlin) m_config.gcode_flavor != gcfRepetier && m_config.gcode_flavor != gcfMarlinLegacy && m_config.gcode_flavor != gcfMarlinFirmware)
return L("The Wipe Tower is currently only supported for the Marlin, RepRap/Sprinter, RepRapFirmware and Repetier G-code flavors."); return L("The Wipe Tower is currently only supported for the Marlin, RepRap/Sprinter, RepRapFirmware and Repetier G-code flavors.");
if (! m_config.use_relative_e_distances) if (! m_config.use_relative_e_distances)
return L("The Wipe Tower is currently only supported with the relative extruder addressing (use_relative_e_distances=1)."); return L("The Wipe Tower is currently only supported with the relative extruder addressing (use_relative_e_distances=1).");

View file

@ -1103,6 +1103,7 @@ void PrintConfigDef::init_fff_params()
def->enum_values.push_back("teacup"); def->enum_values.push_back("teacup");
def->enum_values.push_back("makerware"); def->enum_values.push_back("makerware");
def->enum_values.push_back("marlin"); def->enum_values.push_back("marlin");
def->enum_values.push_back("marlinfirmware");
def->enum_values.push_back("sailfish"); def->enum_values.push_back("sailfish");
def->enum_values.push_back("mach3"); def->enum_values.push_back("mach3");
def->enum_values.push_back("machinekit"); def->enum_values.push_back("machinekit");
@ -1113,7 +1114,8 @@ void PrintConfigDef::init_fff_params()
def->enum_labels.push_back("Repetier"); def->enum_labels.push_back("Repetier");
def->enum_labels.push_back("Teacup"); def->enum_labels.push_back("Teacup");
def->enum_labels.push_back("MakerWare (MakerBot)"); def->enum_labels.push_back("MakerWare (MakerBot)");
def->enum_labels.push_back("Marlin"); def->enum_labels.push_back("Marlin (legacy)");
def->enum_labels.push_back("Marlin Firmware");
def->enum_labels.push_back("Sailfish (MakerBot)"); def->enum_labels.push_back("Sailfish (MakerBot)");
def->enum_labels.push_back("Mach3/LinuxCNC"); def->enum_labels.push_back("Mach3/LinuxCNC");
def->enum_labels.push_back("Machinekit"); def->enum_labels.push_back("Machinekit");
@ -1467,21 +1469,34 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 0., 0. }); def->set_default_value(new ConfigOptionFloats{ 0., 0. });
// M204 S... [mm/sec^2] // M204 P... [mm/sec^2]
def = this->add("machine_max_acceleration_extruding", coFloats); def = this->add("machine_max_acceleration_extruding", coFloats);
def->full_label = L("Maximum acceleration when extruding"); def->full_label = L("Maximum acceleration when extruding");
def->category = L("Machine limits"); def->category = L("Machine limits");
def->tooltip = L("Maximum acceleration when extruding (M204 S)"); def->tooltip = L("Maximum acceleration when extruding (M204 P)\n\n"
"Marlin (legacy) firmware flavor will use this also "
"as travel acceleration (M204 T).");
def->sidetext = L("mm/s²");
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 1500., 1250. });
// M204 R... [mm/sec^2]
def = this->add("machine_max_acceleration_retracting", coFloats);
def->full_label = L("Maximum acceleration when retracting");
def->category = L("Machine limits");
def->tooltip = L("Maximum acceleration when retracting (M204 R)");
def->sidetext = L("mm/s²"); def->sidetext = L("mm/s²");
def->min = 0; def->min = 0;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 1500., 1250. }); def->set_default_value(new ConfigOptionFloats{ 1500., 1250. });
// M204 T... [mm/sec^2] // M204 T... [mm/sec^2]
def = this->add("machine_max_acceleration_retracting", coFloats); def = this->add("machine_max_acceleration_travel", coFloats);
def->full_label = L("Maximum acceleration when retracting"); def->full_label = L("Maximum acceleration for travel moves");
def->category = L("Machine limits"); def->category = L("Machine limits");
def->tooltip = L("Maximum acceleration when retracting (M204 T)"); def->tooltip = L("Maximum acceleration for travel moves (M204 T)");
def->sidetext = L("mm/s²"); def->sidetext = L("mm/s²");
def->min = 0; def->min = 0;
def->mode = comAdvanced; def->mode = comAdvanced;
@ -3630,7 +3645,8 @@ std::string FullPrintConfig::validate()
this->gcode_flavor.value != gcfSmoothie && this->gcode_flavor.value != gcfSmoothie &&
this->gcode_flavor.value != gcfRepRapSprinter && this->gcode_flavor.value != gcfRepRapSprinter &&
this->gcode_flavor.value != gcfRepRapFirmware && this->gcode_flavor.value != gcfRepRapFirmware &&
this->gcode_flavor.value != gcfMarlin && this->gcode_flavor.value != gcfMarlinLegacy &&
this->gcode_flavor.value != gcfMarlinFirmware &&
this->gcode_flavor.value != gcfMachinekit && this->gcode_flavor.value != gcfMachinekit &&
this->gcode_flavor.value != gcfRepetier) this->gcode_flavor.value != gcfRepetier)
return "--use-firmware-retraction is only supported by Marlin, Smoothie, RepRapFirmware, Repetier and Machinekit firmware"; return "--use-firmware-retraction is only supported by Marlin, Smoothie, RepRapFirmware, Repetier and Machinekit firmware";

View file

@ -24,7 +24,7 @@
namespace Slic3r { namespace Slic3r {
enum GCodeFlavor : unsigned char { enum GCodeFlavor : unsigned char {
gcfRepRapSprinter, gcfRepRapFirmware, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlin, gcfSailfish, gcfMach3, gcfMachinekit, gcfRepRapSprinter, gcfRepRapFirmware, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlinLegacy, gcfMarlinFirmware, gcfSailfish, gcfMach3, gcfMachinekit,
gcfSmoothie, gcfNoExtrusion, gcfSmoothie, gcfNoExtrusion,
}; };
@ -120,7 +120,8 @@ template<> inline const t_config_enum_values& ConfigOptionEnum<GCodeFlavor>::get
keys_map["repetier"] = gcfRepetier; keys_map["repetier"] = gcfRepetier;
keys_map["teacup"] = gcfTeacup; keys_map["teacup"] = gcfTeacup;
keys_map["makerware"] = gcfMakerWare; keys_map["makerware"] = gcfMakerWare;
keys_map["marlin"] = gcfMarlin; keys_map["marlin"] = gcfMarlinLegacy;
keys_map["marlinfirmware"] = gcfMarlinFirmware;
keys_map["sailfish"] = gcfSailfish; keys_map["sailfish"] = gcfSailfish;
keys_map["smoothie"] = gcfSmoothie; keys_map["smoothie"] = gcfSmoothie;
keys_map["mach3"] = gcfMach3; keys_map["mach3"] = gcfMach3;
@ -725,10 +726,12 @@ public:
ConfigOptionFloats machine_max_feedrate_y; ConfigOptionFloats machine_max_feedrate_y;
ConfigOptionFloats machine_max_feedrate_z; ConfigOptionFloats machine_max_feedrate_z;
ConfigOptionFloats machine_max_feedrate_e; ConfigOptionFloats machine_max_feedrate_e;
// M204 S... [mm/sec^2]
// M204 P... R... T...[mm/sec^2]
ConfigOptionFloats machine_max_acceleration_extruding; ConfigOptionFloats machine_max_acceleration_extruding;
// M204 T... [mm/sec^2]
ConfigOptionFloats machine_max_acceleration_retracting; ConfigOptionFloats machine_max_acceleration_retracting;
ConfigOptionFloats machine_max_acceleration_travel;
// M205 X... Y... Z... E... [mm/sec] // M205 X... Y... Z... E... [mm/sec]
ConfigOptionFloats machine_max_jerk_x; ConfigOptionFloats machine_max_jerk_x;
ConfigOptionFloats machine_max_jerk_y; ConfigOptionFloats machine_max_jerk_y;
@ -753,6 +756,7 @@ protected:
OPT_PTR(machine_max_feedrate_e); OPT_PTR(machine_max_feedrate_e);
OPT_PTR(machine_max_acceleration_extruding); OPT_PTR(machine_max_acceleration_extruding);
OPT_PTR(machine_max_acceleration_retracting); OPT_PTR(machine_max_acceleration_retracting);
OPT_PTR(machine_max_acceleration_travel);
OPT_PTR(machine_max_jerk_x); OPT_PTR(machine_max_jerk_x);
OPT_PTR(machine_max_jerk_y); OPT_PTR(machine_max_jerk_y);
OPT_PTR(machine_max_jerk_z); OPT_PTR(machine_max_jerk_z);

View file

@ -2264,6 +2264,13 @@ void TabPrinter::build_fff()
m_use_silent_mode = val; m_use_silent_mode = val;
} }
} }
if (opt_key == "gcode_flavor") {
bool supports_travel_acceleration = (boost::any_cast<int>(value) == int(gcfMarlinFirmware));
if (supports_travel_acceleration != m_supports_travel_acceleration) {
m_rebuild_kinematics_page = true;
m_supports_travel_acceleration = supports_travel_acceleration;
}
}
build_unregular_pages(); build_unregular_pages();
update_dirty(); update_dirty();
on_value_change(opt_key, value); on_value_change(opt_key, value);
@ -2560,6 +2567,8 @@ PageShp TabPrinter::build_kinematics_page()
} }
append_option_line(optgroup, "machine_max_acceleration_extruding"); append_option_line(optgroup, "machine_max_acceleration_extruding");
append_option_line(optgroup, "machine_max_acceleration_retracting"); append_option_line(optgroup, "machine_max_acceleration_retracting");
if (m_supports_travel_acceleration)
append_option_line(optgroup, "machine_max_acceleration_travel");
optgroup = page->new_optgroup(L("Jerk limits")); optgroup = page->new_optgroup(L("Jerk limits"));
for (const std::string &axis : axes) { for (const std::string &axis : axes) {
@ -2582,7 +2591,8 @@ PageShp TabPrinter::build_kinematics_page()
void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/) void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/)
{ {
size_t n_before_extruders = 2; // Count of pages before Extruder pages size_t n_before_extruders = 2; // Count of pages before Extruder pages
bool is_marlin_flavor = m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value == gcfMarlin; auto flavor = m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value;
bool is_marlin_flavor = (flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware);
/* ! Freeze/Thaw in this function is needed to avoid call OnPaint() for erased pages /* ! Freeze/Thaw in this function is needed to avoid call OnPaint() for erased pages
* and be cause of application crash, when try to change Preset in moment, * and be cause of application crash, when try to change Preset in moment,
@ -2852,7 +2862,8 @@ void TabPrinter::toggle_options()
if (m_active_page->title() == "General") { if (m_active_page->title() == "General") {
toggle_option("single_extruder_multi_material", have_multiple_extruders); toggle_option("single_extruder_multi_material", have_multiple_extruders);
bool is_marlin_flavor = m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value == gcfMarlin; auto flavor = m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value;
bool is_marlin_flavor = flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware;
// Disable silent mode for non-marlin firmwares. // Disable silent mode for non-marlin firmwares.
toggle_option("silent_mode", is_marlin_flavor); toggle_option("silent_mode", is_marlin_flavor);
} }
@ -2920,7 +2931,8 @@ void TabPrinter::toggle_options()
} }
if (m_active_page->title() == "Machine limits" && m_machine_limits_description_line) { if (m_active_page->title() == "Machine limits" && m_machine_limits_description_line) {
assert(m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value == gcfMarlin); assert(m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value == gcfMarlinLegacy
|| m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value == gcfMarlinFirmware);
const auto *machine_limits_usage = m_config->option<ConfigOptionEnum<MachineLimitsUsage>>("machine_limits_usage"); const auto *machine_limits_usage = m_config->option<ConfigOptionEnum<MachineLimitsUsage>>("machine_limits_usage");
bool enabled = machine_limits_usage->value != MachineLimitsUsage::Ignore; bool enabled = machine_limits_usage->value != MachineLimitsUsage::Ignore;
bool silent_mode = m_config->opt_bool("silent_mode"); bool silent_mode = m_config->opt_bool("silent_mode");
@ -2951,6 +2963,12 @@ void TabPrinter::update_fff()
m_use_silent_mode = m_config->opt_bool("silent_mode"); m_use_silent_mode = m_config->opt_bool("silent_mode");
} }
bool supports_travel_acceleration = (m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value == gcfMarlinFirmware);
if (m_supports_travel_acceleration != supports_travel_acceleration) {
m_rebuild_kinematics_page = true;
m_supports_travel_acceleration = supports_travel_acceleration;
}
toggle_options(); toggle_options();
} }

View file

@ -425,6 +425,7 @@ class TabPrinter : public Tab
private: private:
bool m_has_single_extruder_MM_page = false; bool m_has_single_extruder_MM_page = false;
bool m_use_silent_mode = false; bool m_use_silent_mode = false;
bool m_supports_travel_acceleration = false;
void append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key); void append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key);
bool m_rebuild_kinematics_page = false; bool m_rebuild_kinematics_page = false;
ogStaticText* m_machine_limits_description_line {nullptr}; ogStaticText* m_machine_limits_description_line {nullptr};