From bfb721f3028895f0bd5540ba8457b1571901d876 Mon Sep 17 00:00:00 2001 From: n8bot <22458343+n8bot@users.noreply.github.com> Date: Mon, 22 Nov 2021 00:55:07 -0800 Subject: [PATCH 1/5] Add compatibility for Machine Limits and RRF (PR #7347) --- src/libslic3r/GCode.cpp | 45 +++++++++++++++----------- src/libslic3r/GCode/GCodeProcessor.cpp | 4 +-- src/libslic3r/GCodeWriter.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 15 +++++---- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index def30bbde..e76ae125c 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1685,18 +1685,19 @@ 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. void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print) { - if ((print.config().gcode_flavor.value == gcfMarlinLegacy || print.config().gcode_flavor.value == gcfMarlinFirmware) + if ((print.config().gcode_flavor.value == gcfMarlinLegacy || print.config().gcode_flavor.value == gcfMarlinFirmware || print.config().gcode_flavor.value == gcfRepRapFirmware) && print.config().machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) { + int factor = print.config().gcode_flavor.value == gcfRepRapFirmware ? 60 : 1; // RRF M203 and M566 are in mm/min file.write_format("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_y.values.front() + 0.5), int(print.config().machine_max_acceleration_z.values.front() + 0.5), int(print.config().machine_max_acceleration_e.values.front() + 0.5)); - file.write_format("M203 X%d Y%d Z%d E%d ; sets maximum feedrates, mm/sec\n", - int(print.config().machine_max_feedrate_x.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_e.values.front() + 0.5)); + file.write_format("M203 X%d Y%d Z%d E%d ; sets maximum feedrates, mm/sec (or mm/min for RRF)\n", + int(print.config().machine_max_feedrate_x.values.front() * factor + 0.5), + int(print.config().machine_max_feedrate_y.values.front() * factor + 0.5), + int(print.config().machine_max_feedrate_z.values.front() * factor + 0.5), + int(print.config().machine_max_feedrate_e.values.front() * factor + 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 @@ -1705,20 +1706,28 @@ void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print) 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); - file.write_format("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_retracting.values.front() + 0.5), - travel_acc); + // Retract acceleration not accepeted in M204 in RRF + if (print.config().gcode_flavor.value == gcfRepRapFirmware) + file.write_format("M204 P%d T%d ; sets acceleration (P, T), mm/sec^2\n", + int(print.config().machine_max_acceleration_extruding.values.front() + 0.5), + travel_acc); + else + file.write_format("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_retracting.values.front() + 0.5), + travel_acc); assert(is_decimal_separator_point()); - file.write_format("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_y.values.front(), - print.config().machine_max_jerk_z.values.front(), - print.config().machine_max_jerk_e.values.front()); - file.write_format("M205 S%d T%d ; sets the minimum extruding and travel feed rate, mm/sec\n", - int(print.config().machine_min_extruding_rate.values.front() + 0.5), - int(print.config().machine_min_travel_rate.values.front() + 0.5)); + file.write_format(print.config().gcode_flavor.value == gcfRepRapFirmware ? "M566 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/min\n" : "M205 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/sec\n", + print.config().machine_max_jerk_x.values.front() * factor, + print.config().machine_max_jerk_y.values.front() * factor, + print.config().machine_max_jerk_z.values.front() * factor, + print.config().machine_max_jerk_e.values.front() * factor); + // M205 Sn Tn not supported in RRF + if (print.config().gcode_flavor.value != gcfRepRapFirmware) + file.write_format("M205 S%d T%d ; sets the minimum extruding and travel feed rate, mm/sec\n", + int(print.config().machine_min_extruding_rate.values.front() + 0.5), + int(print.config().machine_min_travel_rate.values.front() + 0.5)); } } diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 33c1c31f3..309cffba3 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -848,7 +848,7 @@ void GCodeProcessor::apply_config(const PrintConfig& config) m_result.filament_densities[i] = static_cast(config.filament_density.get_at(i)); } - if ((m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware) && config.machine_limits_usage.value != MachineLimitsUsage::Ignore) { + if ((m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware || m_flavor == gcfRepRapFirmware) && config.machine_limits_usage.value != MachineLimitsUsage::Ignore) { m_time_processor.machine_limits = reinterpret_cast(config); if (m_flavor == gcfMarlinLegacy) { // Legacy Marlin does not have separate travel acceleration, it uses the 'extruding' value instead. @@ -1021,7 +1021,7 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) if (machine_limits_usage != nullptr) use_machine_limits = machine_limits_usage->value != MachineLimitsUsage::Ignore; - if (use_machine_limits && (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware)) { + if (use_machine_limits && (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware || m_flavor == gcfRepRapFirmware)) { const ConfigOptionFloats* machine_max_acceleration_x = config.option("machine_max_acceleration_x"); if (machine_max_acceleration_x != nullptr) m_time_processor.machine_limits.machine_max_acceleration_x.values = machine_max_acceleration_x->values; diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index 354c909e1..ddb70375e 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -20,7 +20,7 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config) this->config.apply(print_config, true); m_extrusion_axis = get_extrusion_axis(this->config); m_single_extruder_multi_material = print_config.single_extruder_multi_material.value; - bool is_marlin = print_config.gcode_flavor.value == gcfMarlinLegacy || print_config.gcode_flavor.value == gcfMarlinFirmware; + bool is_marlin = print_config.gcode_flavor.value == gcfMarlinLegacy || print_config.gcode_flavor.value == gcfMarlinFirmware || print_config.gcode_flavor.value == gcfRepRapFirmware; m_max_acceleration = std::lrint((is_marlin && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) ? print_config.machine_max_acceleration_extruding.values.front() : 0); } diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 5e6e2c633..8bbff1f35 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2351,7 +2351,7 @@ void TabPrinter::build_fff() } } if (opt_key == "gcode_flavor") { - bool supports_travel_acceleration = (boost::any_cast(value) == int(gcfMarlinFirmware)); + bool supports_travel_acceleration = (boost::any_cast(value) == int(gcfMarlinFirmware)) || (boost::any_cast(value) == int(gcfRepRapFirmware)); if (supports_travel_acceleration != m_supports_travel_acceleration) { m_rebuild_kinematics_page = true; m_supports_travel_acceleration = supports_travel_acceleration; @@ -2656,7 +2656,7 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/) { size_t n_before_extruders = 2; // Count of pages before Extruder pages auto flavor = m_config->option>("gcode_flavor")->value; - bool is_marlin_flavor = (flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware); + bool is_marlin_flavor = (flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware); /* ! 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, @@ -2928,7 +2928,7 @@ void TabPrinter::toggle_options() toggle_option("single_extruder_multi_material", have_multiple_extruders); auto flavor = m_config->option>("gcode_flavor")->value; - bool is_marlin_flavor = flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware; + bool is_marlin_flavor = flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware; // Disable silent mode for non-marlin firmwares. toggle_option("silent_mode", is_marlin_flavor); } @@ -2998,7 +2998,8 @@ void TabPrinter::toggle_options() if (m_active_page->title() == "Machine limits" && m_machine_limits_description_line) { assert(m_config->option>("gcode_flavor")->value == gcfMarlinLegacy - || m_config->option>("gcode_flavor")->value == gcfMarlinFirmware); + || m_config->option>("gcode_flavor")->value == gcfMarlinFirmware + || m_config->option>("gcode_flavor")->value == gcfRepRapFirmware); const auto *machine_limits_usage = m_config->option>("machine_limits_usage"); bool enabled = machine_limits_usage->value != MachineLimitsUsage::Ignore; bool silent_mode = m_config->opt_bool("silent_mode"); @@ -3030,7 +3031,7 @@ void TabPrinter::update_fff() m_use_silent_mode = m_config->opt_bool("silent_mode"); } - bool supports_travel_acceleration = (m_config->option>("gcode_flavor")->value == gcfMarlinFirmware); + bool supports_travel_acceleration = (m_config->option>("gcode_flavor")->value == gcfMarlinFirmware || m_config->option>("gcode_flavor")->value == gcfRepRapFirmware); if (m_supports_travel_acceleration != supports_travel_acceleration) { m_rebuild_kinematics_page = true; m_supports_travel_acceleration = supports_travel_acceleration; @@ -3954,7 +3955,9 @@ void TabPrinter::update_machine_limits_description(const MachineLimitsUsage usag break; case MachineLimitsUsage::TimeEstimateOnly: text = _L("Machine limits will NOT be emitted to G-code, however they will be used to estimate print time, " - "which may therefore not be accurate as the printer may apply a different set of machine limits."); + "which may therefore not be accurate as the printer may apply a different set of machine limits. " + "This newly works with RepRapFirmware to estimate time, but the algorithm is unchanged from Marlin. " + "Estimates work well when machine limits are accurately described."); break; case MachineLimitsUsage::Ignore: text = _L("Machine limits are not set, therefore the print time estimate may not be accurate."); From f3e14865e53c15e304e17cec7ebc9c9b4668c287 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 4 Jan 2022 16:01:03 +0100 Subject: [PATCH 2/5] Minor tweaks in machine limits handling: - renamed some variables so the names are not misleading - improved readability a bit - disabled silent mode for RRF (it was apparently enabled by mistake) - set default value of machine_limits_usage to TimeEstimateOnly --- src/libslic3r/GCode.cpp | 15 +++++++++------ src/libslic3r/GCodeWriter.cpp | 6 ++++-- src/libslic3r/PrintConfig.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 14 +++++++------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index e76ae125c..138f6ea72 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1685,9 +1685,10 @@ 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. void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print) { - if ((print.config().gcode_flavor.value == gcfMarlinLegacy || print.config().gcode_flavor.value == gcfMarlinFirmware || print.config().gcode_flavor.value == gcfRepRapFirmware) + const GCodeFlavor flavor = print.config().gcode_flavor.value; + if ( (flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware) && print.config().machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) { - int factor = print.config().gcode_flavor.value == gcfRepRapFirmware ? 60 : 1; // RRF M203 and M566 are in mm/min + int factor = flavor == gcfRepRapFirmware ? 60 : 1; // RRF M203 and M566 are in mm/min file.write_format("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_y.values.front() + 0.5), @@ -1703,11 +1704,11 @@ void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print) // 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 travel_acc = flavor == gcfMarlinLegacy ? int(print.config().machine_max_acceleration_extruding.values.front() + 0.5) : int(print.config().machine_max_acceleration_travel.values.front() + 0.5); // Retract acceleration not accepeted in M204 in RRF - if (print.config().gcode_flavor.value == gcfRepRapFirmware) + if (flavor == gcfRepRapFirmware) file.write_format("M204 P%d T%d ; sets acceleration (P, T), mm/sec^2\n", int(print.config().machine_max_acceleration_extruding.values.front() + 0.5), travel_acc); @@ -1718,13 +1719,15 @@ void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print) travel_acc); assert(is_decimal_separator_point()); - file.write_format(print.config().gcode_flavor.value == gcfRepRapFirmware ? "M566 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/min\n" : "M205 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/sec\n", + file.write_format(flavor == gcfRepRapFirmware + ? "M566 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/min\n" + : "M205 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/sec\n", print.config().machine_max_jerk_x.values.front() * factor, print.config().machine_max_jerk_y.values.front() * factor, print.config().machine_max_jerk_z.values.front() * factor, print.config().machine_max_jerk_e.values.front() * factor); // M205 Sn Tn not supported in RRF - if (print.config().gcode_flavor.value != gcfRepRapFirmware) + if (flavor != gcfRepRapFirmware) file.write_format("M205 S%d T%d ; sets the minimum extruding and travel feed rate, mm/sec\n", int(print.config().machine_min_extruding_rate.values.front() + 0.5), int(print.config().machine_min_travel_rate.values.front() + 0.5)); diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index ddb70375e..233976b19 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -20,8 +20,10 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config) this->config.apply(print_config, true); m_extrusion_axis = get_extrusion_axis(this->config); m_single_extruder_multi_material = print_config.single_extruder_multi_material.value; - bool is_marlin = print_config.gcode_flavor.value == gcfMarlinLegacy || print_config.gcode_flavor.value == gcfMarlinFirmware || print_config.gcode_flavor.value == gcfRepRapFirmware; - m_max_acceleration = std::lrint((is_marlin && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) ? + bool use_mach_limits = print_config.gcode_flavor.value == gcfMarlinLegacy + || print_config.gcode_flavor.value == gcfMarlinFirmware + || print_config.gcode_flavor.value == gcfRepRapFirmware; + m_max_acceleration = std::lrint((use_mach_limits && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) ? print_config.machine_max_acceleration_extruding.values.front() : 0); } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 77a76ab8e..2048dc66e 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1614,7 +1614,7 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back(L("Use for time estimate")); def->enum_labels.push_back(L("Ignore")); def->mode = comAdvanced; - def->set_default_value(new ConfigOptionEnum(MachineLimitsUsage::EmitToGCode)); + def->set_default_value(new ConfigOptionEnum(MachineLimitsUsage::TimeEstimateOnly)); { struct AxisDefault { diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 8bbff1f35..e8f0a5efb 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2656,7 +2656,7 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/) { size_t n_before_extruders = 2; // Count of pages before Extruder pages auto flavor = m_config->option>("gcode_flavor")->value; - bool is_marlin_flavor = (flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware); + bool show_mach_limits = (flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware); /* ! 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, @@ -2664,26 +2664,26 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/) * */ Freeze(); - // Add/delete Kinematics page according to is_marlin_flavor + // Add/delete Kinematics page according to show_mach_limits size_t existed_page = 0; for (size_t i = n_before_extruders; i < m_pages.size(); ++i) // first make sure it's not there already if (m_pages[i]->title().find(L("Machine limits")) != std::string::npos) { - if (!is_marlin_flavor || m_rebuild_kinematics_page) + if (!show_mach_limits || m_rebuild_kinematics_page) m_pages.erase(m_pages.begin() + i); else existed_page = i; break; } - if (existed_page < n_before_extruders && (is_marlin_flavor || from_initial_build)) { + if (existed_page < n_before_extruders && (show_mach_limits || from_initial_build)) { auto page = build_kinematics_page(); - if (from_initial_build && !is_marlin_flavor) + if (from_initial_build && !show_mach_limits) page->clear(); else m_pages.insert(m_pages.begin() + n_before_extruders, page); } - if (is_marlin_flavor) + if (show_mach_limits) n_before_extruders++; size_t n_after_single_extruder_MM = 2; // Count of pages after single_extruder_multi_material page @@ -2928,7 +2928,7 @@ void TabPrinter::toggle_options() toggle_option("single_extruder_multi_material", have_multiple_extruders); auto flavor = m_config->option>("gcode_flavor")->value; - bool is_marlin_flavor = flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware; + bool is_marlin_flavor = flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware; // Disable silent mode for non-marlin firmwares. toggle_option("silent_mode", is_marlin_flavor); } From b3726f1f8873ecc5872e84796071c2fc8e465390 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 4 Jan 2022 16:44:39 +0100 Subject: [PATCH 3/5] Fixed RRF time estimate, so it does not use min feedrate limits from previously selected printer (RRF itself does not support them) --- src/libslic3r/GCode/GCodeProcessor.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 309cffba3..f54e38eec 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -854,6 +854,11 @@ void GCodeProcessor::apply_config(const PrintConfig& config) // 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; } + if (m_flavor == gcfRepRapFirmware) { + // RRF does not support setting min feedrates. Set them to zero. + m_time_processor.machine_limits.machine_min_travel_rate.values.assign(m_time_processor.machine_limits.machine_min_travel_rate.size(), 0.); + m_time_processor.machine_limits.machine_min_extruding_rate.values.assign(m_time_processor.machine_limits.machine_min_extruding_rate.size(), 0.); + } } // Filament load / unload times are not specific to a firmware flavor. Let anybody use it if they find it useful. @@ -1088,12 +1093,22 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) const ConfigOptionFloats* machine_min_extruding_rate = config.option("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; + if (m_flavor == gcfRepRapFirmware) { + // RRF does not support setting min feedrates. Set zero. + m_time_processor.machine_limits.machine_min_extruding_rate.values.assign(m_time_processor.machine_limits.machine_min_extruding_rate.size(), 0.); + } + } const ConfigOptionFloats* machine_min_travel_rate = config.option("machine_min_travel_rate"); - if (machine_min_travel_rate != nullptr) + if (machine_min_travel_rate != nullptr) { m_time_processor.machine_limits.machine_min_travel_rate.values = machine_min_travel_rate->values; + if (m_flavor == gcfRepRapFirmware) { + // RRF does not support setting min feedrates. Set zero. + m_time_processor.machine_limits.machine_min_travel_rate.values.assign(m_time_processor.machine_limits.machine_min_travel_rate.size(), 0.); + } + } } for (size_t i = 0; i < static_cast(PrintEstimatedStatistics::ETimeMode::Count); ++i) { From 85f98b880aa58564cff79c8c222fafdbb653715a Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 4 Jan 2022 16:28:40 +0100 Subject: [PATCH 4/5] Hide min feedrate from machine limits page for RRF (which does not use them) --- src/slic3r/GUI/Tab.cpp | 22 +++++++++++++++------- src/slic3r/GUI/Tab.hpp | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index e8f0a5efb..2fc54465a 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2351,10 +2351,13 @@ void TabPrinter::build_fff() } } if (opt_key == "gcode_flavor") { - bool supports_travel_acceleration = (boost::any_cast(value) == int(gcfMarlinFirmware)) || (boost::any_cast(value) == int(gcfRepRapFirmware)); - if (supports_travel_acceleration != m_supports_travel_acceleration) { + const int flavor = boost::any_cast(value); + bool supports_travel_acceleration = (flavor == int(gcfMarlinFirmware) || flavor == int(gcfRepRapFirmware)); + bool supports_min_feedrates = (flavor == int(gcfMarlinFirmware) || flavor == int(gcfMarlinLegacy)); + if (supports_travel_acceleration != m_supports_travel_acceleration || supports_min_feedrates != m_supports_min_feedrates) { m_rebuild_kinematics_page = true; m_supports_travel_acceleration = supports_travel_acceleration; + m_supports_min_feedrates = supports_min_feedrates; } } build_unregular_pages(); @@ -2639,9 +2642,11 @@ PageShp TabPrinter::build_kinematics_page() append_option_line(optgroup, "machine_max_jerk_" + axis); } - optgroup = page->new_optgroup(L("Minimum feedrates")); - append_option_line(optgroup, "machine_min_extruding_rate"); - append_option_line(optgroup, "machine_min_travel_rate"); + if (m_supports_min_feedrates) { + optgroup = page->new_optgroup(L("Minimum feedrates")); + append_option_line(optgroup, "machine_min_extruding_rate"); + append_option_line(optgroup, "machine_min_travel_rate"); + } return page; } @@ -3031,10 +3036,13 @@ void TabPrinter::update_fff() m_use_silent_mode = m_config->opt_bool("silent_mode"); } - bool supports_travel_acceleration = (m_config->option>("gcode_flavor")->value == gcfMarlinFirmware || m_config->option>("gcode_flavor")->value == gcfRepRapFirmware); - if (m_supports_travel_acceleration != supports_travel_acceleration) { + const auto flavor = m_config->option>("gcode_flavor")->value; + bool supports_travel_acceleration = (flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware); + bool supports_min_feedrates = (flavor == gcfMarlinFirmware || flavor == gcfMarlinLegacy); + if (m_supports_travel_acceleration != supports_travel_acceleration || m_supports_min_feedrates != supports_min_feedrates) { m_rebuild_kinematics_page = true; m_supports_travel_acceleration = supports_travel_acceleration; + m_supports_min_feedrates = supports_min_feedrates; } toggle_options(); diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 38e142591..e8d939cf7 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -421,6 +421,7 @@ private: bool m_has_single_extruder_MM_page = false; bool m_use_silent_mode = false; bool m_supports_travel_acceleration = false; + bool m_supports_min_feedrates = false; void append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key); bool m_rebuild_kinematics_page = false; ogStaticText* m_machine_limits_description_line {nullptr}; From da8e4b6fda473d4f81f285da6af75f51f905d10e Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 5 Jan 2022 10:00:35 +0100 Subject: [PATCH 5/5] Some more beautifications --- src/libslic3r/GCode.cpp | 12 ++++++++---- src/slic3r/GUI/Tab.cpp | 12 +++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 138f6ea72..ce646d1d3 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1694,11 +1694,12 @@ void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print) int(print.config().machine_max_acceleration_y.values.front() + 0.5), int(print.config().machine_max_acceleration_z.values.front() + 0.5), int(print.config().machine_max_acceleration_e.values.front() + 0.5)); - file.write_format("M203 X%d Y%d Z%d E%d ; sets maximum feedrates, mm/sec (or mm/min for RRF)\n", + file.write_format("M203 X%d Y%d Z%d E%d ; sets maximum feedrates, %s\n", int(print.config().machine_max_feedrate_x.values.front() * factor + 0.5), int(print.config().machine_max_feedrate_y.values.front() * factor + 0.5), int(print.config().machine_max_feedrate_z.values.front() * factor + 0.5), - int(print.config().machine_max_feedrate_e.values.front() * factor + 0.5)); + int(print.config().machine_max_feedrate_e.values.front() * factor + 0.5), + factor == 60 ? "mm / min" : "mm / sec"); // Now M204 - acceleration. This one is quite hairy thanks to how Marlin guys care about // backwards compatibility: https://github.com/prusa3d/PrusaSlicer/issues/1089 @@ -1707,7 +1708,7 @@ void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print) int travel_acc = flavor == gcfMarlinLegacy ? int(print.config().machine_max_acceleration_extruding.values.front() + 0.5) : int(print.config().machine_max_acceleration_travel.values.front() + 0.5); - // Retract acceleration not accepeted in M204 in RRF + // Retract acceleration not accepted in M204 in RRF if (flavor == gcfRepRapFirmware) file.write_format("M204 P%d T%d ; sets acceleration (P, T), mm/sec^2\n", int(print.config().machine_max_acceleration_extruding.values.front() + 0.5), @@ -1726,11 +1727,14 @@ void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print) print.config().machine_max_jerk_y.values.front() * factor, print.config().machine_max_jerk_z.values.front() * factor, print.config().machine_max_jerk_e.values.front() * factor); - // M205 Sn Tn not supported in RRF if (flavor != gcfRepRapFirmware) file.write_format("M205 S%d T%d ; sets the minimum extruding and travel feed rate, mm/sec\n", int(print.config().machine_min_extruding_rate.values.front() + 0.5), int(print.config().machine_min_travel_rate.values.front() + 0.5)); + else { + // M205 Sn Tn not supported in RRF. They use M203 Inn to set minimum feedrate for + // all moves. This is currently not implemented. + } } } diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 2fc54465a..044a0c77d 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2926,13 +2926,13 @@ void TabPrinter::toggle_options() if (!m_active_page || m_presets->get_edited_preset().printer_technology() == ptSLA) return; + const GCodeFlavor flavor = m_config->option>("gcode_flavor")->value; bool have_multiple_extruders = m_extruders_count > 1; if (m_active_page->title() == "Custom G-code") toggle_option("toolchange_gcode", have_multiple_extruders); if (m_active_page->title() == "General") { toggle_option("single_extruder_multi_material", have_multiple_extruders); - auto flavor = m_config->option>("gcode_flavor")->value; bool is_marlin_flavor = flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware; // Disable silent mode for non-marlin firmwares. toggle_option("silent_mode", is_marlin_flavor); @@ -3002,9 +3002,9 @@ void TabPrinter::toggle_options() } if (m_active_page->title() == "Machine limits" && m_machine_limits_description_line) { - assert(m_config->option>("gcode_flavor")->value == gcfMarlinLegacy - || m_config->option>("gcode_flavor")->value == gcfMarlinFirmware - || m_config->option>("gcode_flavor")->value == gcfRepRapFirmware); + assert(flavor == gcfMarlinLegacy + || flavor == gcfMarlinFirmware + || flavor == gcfRepRapFirmware); const auto *machine_limits_usage = m_config->option>("machine_limits_usage"); bool enabled = machine_limits_usage->value != MachineLimitsUsage::Ignore; bool silent_mode = m_config->opt_bool("silent_mode"); @@ -3963,9 +3963,7 @@ void TabPrinter::update_machine_limits_description(const MachineLimitsUsage usag break; case MachineLimitsUsage::TimeEstimateOnly: text = _L("Machine limits will NOT be emitted to G-code, however they will be used to estimate print time, " - "which may therefore not be accurate as the printer may apply a different set of machine limits. " - "This newly works with RepRapFirmware to estimate time, but the algorithm is unchanged from Marlin. " - "Estimates work well when machine limits are accurately described."); + "which may therefore not be accurate as the printer may apply a different set of machine limits."); break; case MachineLimitsUsage::Ignore: text = _L("Machine limits are not set, therefore the print time estimate may not be accurate.");