Prusa 2.7.1

This commit is contained in:
sunsets
2023-12-28 10:57:18 +08:00
parent 0a3c63dcb1
commit ab227dba3c
20 changed files with 197 additions and 151 deletions

View File

@@ -130,6 +130,8 @@ void AppConfig::set_defaults()
if (get("auto_toolbar_size").empty())
set("auto_toolbar_size", "100");
if (get("use_binary_gcode_when_supported").empty())
set("use_binary_gcode_when_supported", "1");
if (get("notify_release").empty())
set("notify_release", "all"); // or "none" or "release"
@@ -746,25 +748,7 @@ bool AppConfig::update_skein_dir(const std::string &dir)
return false; // do not save "shapes gallery" directory
return this->set("recent", "skein_directory", dir);
}
/*
std::string AppConfig::get_last_output_dir(const std::string &alt) const
{
const auto it = m_storage.find("");
if (it != m_storage.end()) {
const auto it2 = it->second.find("last_output_path");
const auto it3 = it->second.find("remember_output_path");
if (it2 != it->second.end() && it3 != it->second.end() && ! it2->second.empty() && it3->second == "1")
return it2->second;
}
return alt;
}
void AppConfig::update_last_output_dir(const std::string &dir)
{
this->set("", "last_output_path", dir);
}
*/
std::string AppConfig::get_last_output_dir(const std::string& alt, const bool removable) const
{
std::string s1 = (removable ? "last_output_path_removable" : "last_output_path");

View File

@@ -753,6 +753,7 @@ namespace DoExport {
print_statistics.total_used_filament += used_filament;
print_statistics.total_extruded_volume += extruded_volume;
print_statistics.total_wipe_tower_filament += has_wipe_tower ? used_filament - extruder.used_filament() : 0.;
print_statistics.total_wipe_tower_filament_weight += has_wipe_tower ? (extruded_volume - extruder.extruded_volume()) * extruder.filament_density() * 0.001 : 0.;
print_statistics.total_wipe_tower_cost += has_wipe_tower ? (extruded_volume - extruder.extruded_volume())* extruder.filament_density() * 0.001 * extruder.filament_cost() * 0.001 : 0.;
}
if (!export_binary_data) {
@@ -843,7 +844,7 @@ static inline GCode::SmoothPathCache smooth_path_interpolate_global(const Print&
void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb)
{
const bool export_to_binary_gcode = print.full_print_config().option<ConfigOptionBool>("gcode_binary")->value;
const bool export_to_binary_gcode = print.full_print_config().option<ConfigOptionBool>("binary_gcode")->value;
// if exporting gcode in binary format:
// we generate here the data to be passed to the post-processor, who is responsible to export them to file
// 1) generate the thumbnails
@@ -1404,6 +1405,7 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
file.write("\n");
file.write_format(PrintStatistics::TotalFilamentUsedGValueMask.c_str(), print.m_print_statistics.total_weight);
file.write_format(PrintStatistics::TotalFilamentCostValueMask.c_str(), print.m_print_statistics.total_cost);
file.write_format(PrintStatistics::TotalFilamentUsedWipeTowerValueMask.c_str(), print.m_print_statistics.total_wipe_tower_filament_weight);
if (print.m_print_statistics.total_toolchanges > 0)
file.write_format("; total toolchanges = %i\n", print.m_print_statistics.total_toolchanges);
file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder).c_str());
@@ -2192,7 +2194,7 @@ LayerResult GCodeGenerator::process_layer(
print.config().before_layer_gcode.value, m_writer.extruder()->id(), &config)
+ "\n";
}
gcode += this->change_layer(previous_layer_z, print_z); // this will increase m_layer_index
gcode += this->change_layer(previous_layer_z, print_z, result.spiral_vase_enable); // this will increase m_layer_index
m_layer = &layer;
if (this->line_distancer_is_required(layer_tools.extruders) && this->m_layer != nullptr && this->m_layer->lower_layer != nullptr) {
this->m_previous_layer_distancer = GCode::Impl::get_expolygons_distancer(m_layer->lower_layer->lslices);
@@ -2704,7 +2706,11 @@ Polygon Bed::get_inner_offset(const std::vector<Vec2d>& shape, const double padd
transform(begin(shape), end(shape), back_inserter(shape_scaled), [](const Vec2d& point){
return scaled(point);
});
return shrink({Polygon{shape_scaled}}, scaled(padding)).front();
Polygons inner_offset{shrink({Polygon{shape_scaled}}, scaled(padding))};
if (inner_offset.empty()) {
return Polygon{};
}
return inner_offset.front();
}
}
@@ -2724,21 +2730,18 @@ std::optional<std::string> GCodeGenerator::get_helical_layer_change_gcode(
const Point n_gon_start_point{this->last_pos()};
static GCode::Impl::Bed bed{
GCode::Impl::Bed bed{
this->m_config.bed_shape.values,
circle_radius
circle_radius * 2
};
if (!bed.contains_within_padding(this->point_to_gcode(n_gon_start_point))) {
return std::nullopt;
}
const Point n_gon_centeroid{
n_gon_start_point
+ scaled(Vec2d{
(bed.centroid - unscaled(n_gon_start_point)).normalized()
* circle_radius
})
};
const Vec2crd n_gon_vector{scaled(Vec2d{
(bed.centroid - this->point_to_gcode(n_gon_start_point)).normalized() * circle_radius
})};
const Point n_gon_centeroid{n_gon_start_point + n_gon_vector};
const Polygon n_gon{GCode::Impl::generate_regular_polygon(
n_gon_centeroid,
@@ -2763,8 +2766,11 @@ std::optional<std::string> GCodeGenerator::get_helical_layer_change_gcode(
}
// called by GCodeGenerator::process_layer()
std::string GCodeGenerator::change_layer(coordf_t previous_layer_z, coordf_t print_z)
{
std::string GCodeGenerator::change_layer(
coordf_t previous_layer_z,
coordf_t print_z,
const bool spiral_vase_enabled
) {
std::string gcode;
if (m_layer_count > 0)
// Increment a progress bar indicator.
@@ -2775,14 +2781,16 @@ std::string GCodeGenerator::change_layer(coordf_t previous_layer_z, coordf_t pri
const std::string comment{"move to next layer (" + std::to_string(m_layer_index) + ")"};
bool helical_layer_change{
(!this->m_spiral_vase || !this->m_spiral_vase->is_enabled())
bool do_helical_layer_change{
!spiral_vase_enabled
&& print_z > previous_layer_z
&& EXTRUDER_CONFIG(retract_layer_change)
&& EXTRUDER_CONFIG(retract_length) > 0
&& EXTRUDER_CONFIG(travel_ramping_lift)
&& EXTRUDER_CONFIG(travel_slope) > 0 && EXTRUDER_CONFIG(travel_slope) < 90
};
const std::optional<std::string> helix_gcode{
helical_layer_change ?
do_helical_layer_change ?
this->get_helical_layer_change_gcode(
m_config.z_offset.value + previous_layer_z,
m_config.z_offset.value + print_z,

View File

@@ -351,7 +351,11 @@ private:
const coordf_t print_z,
const std::string& comment
);
std::string change_layer(coordf_t previous_layer_z, coordf_t print_z);
std::string change_layer(
coordf_t previous_layer_z,
coordf_t print_z,
const bool spiral_vase_enabled
);
std::string extrude_entity(const ExtrusionEntityReference &entity, const GCode::SmoothPathCache &smooth_path_cache, const std::string_view description, double speed = -1.);
std::string extrude_loop(const ExtrusionLoop &loop, const GCode::SmoothPathCache &smooth_path_cache, const std::string_view description, double speed = -1.);
std::string extrude_skirt(const ExtrusionLoop &loop_src, const ExtrusionFlow &extrusion_flow_override,

View File

@@ -568,8 +568,8 @@ GCodeProcessor::GCodeProcessor()
void GCodeProcessor::apply_config(const PrintConfig& config)
{
m_parser.apply_config(config);
m_binarizer.set_enabled(config.gcode_binary);
m_result.is_binary_file = config.gcode_binary;
m_binarizer.set_enabled(config.binary_gcode);
m_result.is_binary_file = config.binary_gcode;
m_producer = EProducer::QIDISlicer;
m_flavor = config.gcode_flavor;
@@ -3687,6 +3687,7 @@ void GCodeProcessor::post_process()
filament_total_cost += filament_cost[id];
}
double total_g_wipe_tower = m_print->print_statistics().total_wipe_tower_filament_weight;
if (m_binarizer.is_enabled()) {
// update print metadata
auto stringify = [](const std::vector<double>& values) {
@@ -3707,11 +3708,13 @@ void GCodeProcessor::post_process()
binary_data.print_metadata.raw_data.emplace_back(PrintStatistics::FilamentCost, stringify(filament_cost));
binary_data.print_metadata.raw_data.emplace_back(PrintStatistics::TotalFilamentUsedG, stringify({ filament_total_g }));
binary_data.print_metadata.raw_data.emplace_back(PrintStatistics::TotalFilamentCost, stringify({ filament_total_cost }));
binary_data.print_metadata.raw_data.emplace_back(PrintStatistics::TotalFilamentUsedWipeTower, stringify({ total_g_wipe_tower }));
binary_data.printer_metadata.raw_data.emplace_back(PrintStatistics::FilamentUsedMm, stringify(filament_mm)); // duplicated into print metadata
binary_data.printer_metadata.raw_data.emplace_back(PrintStatistics::FilamentUsedG, stringify(filament_g)); // duplicated into print metadata
binary_data.printer_metadata.raw_data.emplace_back(PrintStatistics::FilamentCost, stringify(filament_cost)); // duplicated into print metadata
binary_data.printer_metadata.raw_data.emplace_back(PrintStatistics::FilamentUsedCm3, stringify(filament_cm3)); // duplicated into print metadata
binary_data.printer_metadata.raw_data.emplace_back(PrintStatistics::TotalFilamentUsedWipeTower, stringify({ total_g_wipe_tower })); // duplicated into print metadata
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
const TimeMachine& machine = m_time_processor.machines[i];

View File

@@ -19,9 +19,6 @@ public:
m_enabled = en;
}
bool is_enabled() const {
return m_enabled;
}
std::string process_layer(const std::string &gcode);
private:

View File

@@ -454,7 +454,7 @@ static std::vector<std::string> s_Preset_print_options {
"support_tree_angle", "support_tree_angle_slow", "support_tree_branch_diameter", "support_tree_branch_diameter_angle", "support_tree_branch_diameter_double_wall",
"support_tree_top_rate", "support_tree_branch_distance", "support_tree_tip_diameter",
"dont_support_bridges", "thick_bridges", "notes", "complete_objects", "extruder_clearance_radius",
"extruder_clearance_height", "gcode_comments", "gcode_label_objects", "output_filename_format", "post_process", "gcode_substitutions", "gcode_binary","perimeter_extruder",
"extruder_clearance_height", "gcode_comments", "gcode_label_objects", "output_filename_format", "post_process", "gcode_substitutions", "perimeter_extruder",
"infill_extruder", "solid_infill_extruder", "support_material_extruder", "support_material_interface_extruder",
"ooze_prevention", "standby_temperature_delta", "interface_shells", "extrusion_width", "first_layer_extrusion_width",
"perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width",
@@ -517,7 +517,7 @@ static std::vector<std::string> s_Preset_machine_limits_options {
static std::vector<std::string> s_Preset_printer_options {
"printer_technology", "autoemit_temperature_commands",
"bed_shape", "bed_custom_texture", "bed_custom_model", "z_offset", "gcode_flavor", "use_relative_e_distances",
"bed_shape", "bed_custom_texture", "bed_custom_model", "binary_gcode", "z_offset", "gcode_flavor", "use_relative_e_distances",
"use_firmware_retraction", "use_volumetric_e", "variable_layer_height",
//FIXME the print host keys are left here just for conversion from the Printer preset to Physical Printer preset.
"host_type", "print_host", "printhost_apikey", "printhost_cafile",

View File

@@ -64,6 +64,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"bed_temperature",
"before_layer_gcode",
"between_objects_gcode",
"binary_gcode",
"bridge_acceleration",
"bridge_fan_speed",
//B15
@@ -121,7 +122,6 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"perimeter_acceleration",
"post_process",
"gcode_substitutions",
"gcode_binary",
"printer_notes",
"travel_ramping_lift",
"travel_initial_part_length",
@@ -1588,7 +1588,14 @@ std::string Print::output_filename(const std::string &filename_base) const
DynamicConfig config = this->finished() ? this->print_statistics().config() : this->print_statistics().placeholders();
config.set_key_value("num_extruders", new ConfigOptionInt((int)m_config.nozzle_diameter.size()));
config.set_key_value("default_output_extension", new ConfigOptionString(".gcode"));
return this->PrintBase::output_filename(m_config.output_filename_format.value, ".gcode", filename_base, &config);
// Handle output_filename_format. There is a hack related to binary G-codes: gcode / bgcode substitution.
std::string output_filename_format = m_config.output_filename_format.value;
if (m_config.binary_gcode && boost::iends_with(output_filename_format, ".gcode"))
output_filename_format.insert(output_filename_format.end()-5, 'b');
if (! m_config.binary_gcode && boost::iends_with(output_filename_format, ".bgcode"))
output_filename_format.erase(output_filename_format.end()-6);
return this->PrintBase::output_filename(output_filename_format, ".gcode", filename_base, &config);
}
const std::string PrintStatistics::FilamentUsedG = "filament used [g]";
@@ -1610,6 +1617,8 @@ const std::string PrintStatistics::FilamentCostMask = "; filament cost =";
const std::string PrintStatistics::TotalFilamentCost = "total filament cost";
const std::string PrintStatistics::TotalFilamentCostMask = "; total filament cost =";
const std::string PrintStatistics::TotalFilamentCostValueMask = "; total filament cost = %.2lf\n";
const std::string PrintStatistics::TotalFilamentUsedWipeTower = "total filament used for wipe tower [g]";
const std::string PrintStatistics::TotalFilamentUsedWipeTowerValueMask = "; total filament used for wipe tower [g] = %.2lf\n";
DynamicConfig PrintStatistics::config() const
{
DynamicConfig config;

View File

@@ -486,6 +486,7 @@ struct PrintStatistics
double total_weight;
double total_wipe_tower_cost;
double total_wipe_tower_filament;
double total_wipe_tower_filament_weight;
std::vector<unsigned int> printing_extruders;
unsigned int initial_extruder_id;
std::string initial_filament_type;
@@ -507,6 +508,7 @@ struct PrintStatistics
total_weight = 0.;
total_wipe_tower_cost = 0.;
total_wipe_tower_filament = 0.;
total_wipe_tower_filament_weight = 0.;
initial_extruder_id = 0;
initial_filament_type.clear();
printing_filament_types.clear();
@@ -527,6 +529,8 @@ struct PrintStatistics
static const std::string TotalFilamentCost;
static const std::string TotalFilamentCostMask;
static const std::string TotalFilamentCostValueMask;
static const std::string TotalFilamentUsedWipeTower;
static const std::string TotalFilamentUsedWipeTowerValueMask;
};
using PrintObjectPtrs = std::vector<PrintObject*>;

View File

@@ -1546,11 +1546,6 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert;
def->set_default_value(new ConfigOptionStrings());
def = this->add("gcode_binary", coBool);
def->label = L("Export as binary G-code");
def->tooltip = L("Export G-code in binary format.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(0));
def = this->add("high_current_on_filament_swap", coBool);
def->label = L("High extruder current on filament swap");
def->tooltip = L("It may be beneficial to increase the extruder motor current during the filament exchange"
@@ -1826,6 +1821,12 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(true));
def = this->add("binary_gcode", coBool);
def->label = L("Supports binary G-code");
def->tooltip = L("Enable, if the firmware supports binary G-code format (bgcode). "
"To generate .bgcode files, make sure you have binary G-code enabled in Configuration->Preferences->Other.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("machine_limits_usage", coEnum);
def->label = L("How to apply limits");
def->full_label = L("Purpose of Machine Limits");
@@ -4452,6 +4453,7 @@ static std::set<std::string> PrintConfigDef_ignore = {
"ensure_vertical_shell_thickness",
// Disabled in 2.6.0-alpha6, this option is problematic
"infill_only_where_needed",
"gcode_binary" // Introduced in 2.7.0-alpha1, removed in 2.7.1 (replaced by binary_gcode).
};
void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &value)

View File

@@ -688,6 +688,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, autoemit_temperature_commands))
((ConfigOptionString, before_layer_gcode))
((ConfigOptionString, between_objects_gcode))
((ConfigOptionBool, binary_gcode))
((ConfigOptionFloats, deretract_speed))
((ConfigOptionString, end_gcode))
((ConfigOptionStrings, end_filament_gcode))
@@ -724,7 +725,6 @@ PRINT_CONFIG_CLASS_DEFINE(
// i - case insensitive
// w - whole word
((ConfigOptionStrings, gcode_substitutions))
((ConfigOptionBool, gcode_binary))
((ConfigOptionString, layer_gcode))
((ConfigOptionFloat, max_print_speed))
((ConfigOptionFloat, max_volumetric_speed))