Add option to disable emitting M73 gcode (#2114) (#2940)

This commit is contained in:
Noisyfox 2023-12-03 09:36:27 +08:00 committed by GitHub
parent 0cee513416
commit a6c927d87f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 6 deletions

View file

@ -403,6 +403,8 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
if (in.f == nullptr) if (in.f == nullptr)
throw Slic3r::RuntimeError(std::string("Time estimator post process export failed.\nCannot open file for reading.\n")); throw Slic3r::RuntimeError(std::string("Time estimator post process export failed.\nCannot open file for reading.\n"));
const bool disable_m73 = this->disable_m73;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": before process %1%")%filename.c_str(); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": before process %1%")%filename.c_str();
// temporary file to contain modified gcode // temporary file to contain modified gcode
std::string out_path = filename + ".postprocess"; std::string out_path = filename + ".postprocess";
@ -473,7 +475,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
// replace placeholder lines with the proper final value // replace placeholder lines with the proper final value
// gcode_line is in/out parameter, to reduce expensive memory allocation // gcode_line is in/out parameter, to reduce expensive memory allocation
auto process_placeholders = [&](std::string& gcode_line) { auto process_placeholders = [&](std::string& gcode_line) {
unsigned int extra_lines_count = 0; int extra_lines_count = 0;
// remove trailing '\n' // remove trailing '\n'
auto line = std::string_view(gcode_line).substr(0, gcode_line.length() - 1); auto line = std::string_view(gcode_line).substr(0, gcode_line.length() - 1);
@ -482,6 +484,12 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
if (line.length() > 1) { if (line.length() > 1) {
line = line.substr(1); line = line.substr(1);
if (line == reserved_tag(ETags::First_Line_M73_Placeholder) || line == reserved_tag(ETags::Last_Line_M73_Placeholder)) { if (line == reserved_tag(ETags::First_Line_M73_Placeholder) || line == reserved_tag(ETags::Last_Line_M73_Placeholder)) {
if (disable_m73) {
// Remove current line
gcode_line = "";
return std::tuple(true, -1);
}
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) { for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
const TimeMachine& machine = machines[i]; const TimeMachine& machine = machines[i];
if (machine.enabled) { if (machine.enabled) {
@ -679,9 +687,10 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
gcode_line += '\n'; gcode_line += '\n';
// replace placeholder lines // replace placeholder lines
auto [processed, lines_added_count] = process_placeholders(gcode_line); auto [processed, lines_added_count] = process_placeholders(gcode_line);
if (processed && lines_added_count > 0) if (processed && lines_added_count != 0)
offsets.push_back({ line_id, lines_added_count }); offsets.push_back({ line_id, lines_added_count });
if (! processed && ! is_temporary_decoration(gcode_line) &&
if (!disable_m73 && !processed &&!is_temporary_decoration(gcode_line) &&
(GCodeReader::GCodeLine::cmd_is(gcode_line, "G1") || (GCodeReader::GCodeLine::cmd_is(gcode_line, "G1") ||
GCodeReader::GCodeLine::cmd_is(gcode_line, "G2") || GCodeReader::GCodeLine::cmd_is(gcode_line, "G2") ||
GCodeReader::GCodeLine::cmd_is(gcode_line, "G3"))) { GCodeReader::GCodeLine::cmd_is(gcode_line, "G3"))) {
@ -691,6 +700,12 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
offsets.push_back({ line_id, extra_lines_count }); offsets.push_back({ line_id, extra_lines_count });
} }
if (disable_m73 && !processed && GCodeReader::GCodeLine::cmd_is(gcode_line, "M73")) {
// Remove any existing M73 command
gcode_line = "";
offsets.push_back({line_id, -1});
}
export_line += gcode_line; export_line += gcode_line;
if (export_line.length() > 65535) if (export_line.length() > 65535)
write_string(export_line); write_string(export_line);
@ -1041,6 +1056,8 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
DEFAULT_TRAVEL_ACCELERATION; DEFAULT_TRAVEL_ACCELERATION;
} }
m_time_processor.disable_m73 = config.disable_m73;
const ConfigOptionFloat* initial_layer_print_height = config.option<ConfigOptionFloat>("initial_layer_print_height"); const ConfigOptionFloat* initial_layer_print_height = config.option<ConfigOptionFloat>("initial_layer_print_height");
if (initial_layer_print_height != nullptr) if (initial_layer_print_height != nullptr)
m_first_layer_height = std::abs(initial_layer_print_height->value); m_first_layer_height = std::abs(initial_layer_print_height->value);

View file

@ -478,6 +478,7 @@ namespace Slic3r {
// Additional load / unload times for a filament exchange sequence. // Additional load / unload times for a filament exchange sequence.
float filament_load_times; float filament_load_times;
float filament_unload_times; float filament_unload_times;
bool disable_m73;
std::array<TimeMachine, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)> machines; std::array<TimeMachine, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)> machines;

View file

@ -341,6 +341,10 @@ std::string GCodeWriter::update_progress(unsigned int num, unsigned int tot, boo
{ {
if (FLAVOR_IS_NOT(gcfMakerWare) && FLAVOR_IS_NOT(gcfSailfish)) if (FLAVOR_IS_NOT(gcfMakerWare) && FLAVOR_IS_NOT(gcfSailfish))
return ""; return "";
if (config.disable_m73) {
return "";
}
unsigned int percent = (unsigned int)floor(100.0 * num / tot + 0.5); unsigned int percent = (unsigned int)floor(100.0 * num / tot + 0.5);
if (!allow_100) percent = std::min(percent, (unsigned int)99); if (!allow_100) percent = std::min(percent, (unsigned int)99);

View file

@ -877,7 +877,8 @@ static std::vector<std::string> s_Preset_printer_options {
"use_firmware_retraction", "use_relative_e_distances", "printer_notes", "use_firmware_retraction", "use_relative_e_distances", "printer_notes",
"cooling_tube_retraction", "cooling_tube_retraction",
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "purge_in_prime_tower", "enable_filament_ramming", "cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "purge_in_prime_tower", "enable_filament_ramming",
"z_offset" "z_offset",
"disable_m73",
}; };
static std::vector<std::string> s_Preset_sla_print_options { static std::vector<std::string> s_Preset_sla_print_options {

View file

@ -206,8 +206,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"during_print_exhaust_fan_speed", "during_print_exhaust_fan_speed",
"complete_print_exhaust_fan_speed", "complete_print_exhaust_fan_speed",
"activate_chamber_temp_control", "activate_chamber_temp_control",
"manual_filament_change" "manual_filament_change",
"disable_m73",
}; };
static std::unordered_set<std::string> steps_ignore; static std::unordered_set<std::string> steps_ignore;

View file

@ -3253,6 +3253,12 @@ def = this->add("filament_loading_speed", coFloats);
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(true)); def->set_default_value(new ConfigOptionBool(true));
def = this->add("disable_m73", coBool);
def->label = L("Disable set remaining print time");
def->tooltip = "Disable generating of the M73: Set remaining print time in the final gcode";
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("seam_position", coEnum); def = this->add("seam_position", coEnum);
def->label = L("Seam position"); def->label = L("Seam position");
def->category = L("Quality"); def->category = L("Quality");

View file

@ -1016,6 +1016,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionPercent, accel_to_decel_factor)) ((ConfigOptionPercent, accel_to_decel_factor))
((ConfigOptionFloatOrPercent, initial_layer_travel_speed)) ((ConfigOptionFloatOrPercent, initial_layer_travel_speed))
((ConfigOptionBool, bbl_calib_mark_logo)) ((ConfigOptionBool, bbl_calib_mark_logo))
((ConfigOptionBool, disable_m73))
// Orca: mmu // Orca: mmu
((ConfigOptionFloat, cooling_tube_retraction)) ((ConfigOptionFloat, cooling_tube_retraction))

View file

@ -3405,6 +3405,7 @@ void TabPrinter::build_fff()
optgroup = page->new_optgroup(L("Advanced"), L"param_advanced"); optgroup = page->new_optgroup(L("Advanced"), L"param_advanced");
optgroup->append_single_option_line("printer_structure"); optgroup->append_single_option_line("printer_structure");
optgroup->append_single_option_line("gcode_flavor"); optgroup->append_single_option_line("gcode_flavor");
optgroup->append_single_option_line("disable_m73");
option = optgroup->get_option("thumbnails"); option = optgroup->get_option("thumbnails");
option.opt.full_width = true; option.opt.full_width = true;
optgroup->append_single_option_line(option); optgroup->append_single_option_line(option);