Merge remote-tracking branch 'upstream/main' into dev/h2d-2

This commit is contained in:
Noisyfox
2025-10-20 09:37:23 +08:00
60 changed files with 460 additions and 221 deletions

View File

@@ -1462,43 +1462,31 @@ void Layer::make_ironing()
double height;
double speed;
double angle;
bool is_using_template_angle;
double inset;
bool operator<(const IroningParams &rhs) const {
if (this->extruder < rhs.extruder)
return true;
if (this->extruder > rhs.extruder)
return false;
if (int(this->just_infill) < int(rhs.just_infill))
return true;
if (int(this->just_infill) > int(rhs.just_infill))
return false;
if (this->line_spacing < rhs.line_spacing)
return true;
if (this->line_spacing > rhs.line_spacing)
return false;
if (this->height < rhs.height)
return true;
if (this->height > rhs.height)
return false;
if (this->speed < rhs.speed)
return true;
if (this->speed > rhs.speed)
return false;
if (this->angle < rhs.angle)
return true;
if (this->angle > rhs.angle)
return false;
if (this->inset < rhs.inset)
return true;
if (this->inset > rhs.inset)
return false;
RETURN_COMPARE_NON_EQUAL(extruder);
RETURN_COMPARE_NON_EQUAL(just_infill);
RETURN_COMPARE_NON_EQUAL(line_spacing);
RETURN_COMPARE_NON_EQUAL(height);
RETURN_COMPARE_NON_EQUAL(speed);
RETURN_COMPARE_NON_EQUAL(angle);
RETURN_COMPARE_NON_EQUAL(is_using_template_angle);
RETURN_COMPARE_NON_EQUAL(inset);
return false;
}
bool operator==(const IroningParams &rhs) const {
return this->extruder == rhs.extruder && this->just_infill == rhs.just_infill &&
this->line_spacing == rhs.line_spacing && this->height == rhs.height && this->speed == rhs.speed && this->angle == rhs.angle && this->pattern == rhs.pattern && this->inset == rhs.inset;
return this->extruder == rhs.extruder &&
this->just_infill == rhs.just_infill &&
this->line_spacing == rhs.line_spacing &&
this->height == rhs.height &&
this->speed == rhs.speed &&
this->angle == rhs.angle &&
this->is_using_template_angle == rhs.is_using_template_angle &&
this->pattern == rhs.pattern &&
this->inset == rhs.inset;
}
LayerRegion *layerm = nullptr;
@@ -1545,7 +1533,8 @@ void Layer::make_ironing()
ironing_params.inset = config.ironing_inset;
ironing_params.height = default_layer_height * 0.01 * config.ironing_flow;
ironing_params.speed = config.ironing_speed;
ironing_params.angle = (config.ironing_angle >= 0 ? config.ironing_angle : config.infill_direction) * M_PI / 180.;
ironing_params.angle = calculate_infill_rotation_angle(this->object(), this->id(), config.solid_infill_direction.value, config.solid_infill_rotate_template.value) + config.ironing_angle * M_PI / 180.;
ironing_params.is_using_template_angle = !config.solid_infill_rotate_template.value.empty();
ironing_params.pattern = config.ironing_pattern;
ironing_params.layerm = layerm;
by_extruder.emplace_back(ironing_params);
@@ -1641,6 +1630,7 @@ void Layer::make_ironing()
// Create the filler object.
f->spacing = ironing_params.line_spacing;
f->angle = float(ironing_params.angle);
f->is_using_template_angle = ironing_params.is_using_template_angle;
f->link_max_length = (coord_t) scale_(3. * f->spacing);
double extrusion_height = ironing_params.height * f->spacing / nozzle_dmr;
float extrusion_width = Flow::rounded_rectangle_extrusion_width_from_spacing(float(nozzle_dmr), float(extrusion_height));

View File

@@ -4234,23 +4234,31 @@ LayerResult GCode::process_layer(
}
case CalibMode::Calib_Input_shaping_freq: {
if (m_layer_index == 1){
gcode += writer().set_input_shaping('A', print.calib_params().start, 0.f);
gcode += writer().set_input_shaping('A', print.calib_params().start, 0.f, print.calib_params().shaper_type);
if (m_writer.get_gcode_flavor() == gcfKlipper) {
// Disable minimum cruise ratio to ensure consistent motion for calibration
gcode += "SET_VELOCITY_LIMIT MINIMUM_CRUISE_RATIO=0\n";
}
} else {
if (print.calib_params().freqStartX == print.calib_params().freqStartY && print.calib_params().freqEndX == print.calib_params().freqEndY) {
gcode += writer().set_input_shaping('A', 0.f, (print.calib_params().freqStartX) + ((print.calib_params().freqEndX)-(print.calib_params().freqStartX)) * (m_layer_index - 2) / (m_layer_count - 3));
gcode += writer().set_input_shaping('A', 0.f, (print.calib_params().freqStartX) + ((print.calib_params().freqEndX)-(print.calib_params().freqStartX)) * (m_layer_index - 2) / (m_layer_count - 3), "");
} else {
gcode += writer().set_input_shaping('X', 0.f, (print.calib_params().freqStartX) + ((print.calib_params().freqEndX)-(print.calib_params().freqStartX)) * (m_layer_index - 2) / (m_layer_count - 3));
gcode += writer().set_input_shaping('Y', 0.f, (print.calib_params().freqStartY) + ((print.calib_params().freqEndY)-(print.calib_params().freqStartY)) * (m_layer_index - 2) / (m_layer_count - 3));
gcode += writer().set_input_shaping('X', 0.f, (print.calib_params().freqStartX) + ((print.calib_params().freqEndX)-(print.calib_params().freqStartX)) * (m_layer_index - 2) / (m_layer_count - 3), "");
gcode += writer().set_input_shaping('Y', 0.f, (print.calib_params().freqStartY) + ((print.calib_params().freqEndY)-(print.calib_params().freqStartY)) * (m_layer_index - 2) / (m_layer_count - 3), "");
}
}
break;
}
case CalibMode::Calib_Input_shaping_damp: {
if (m_layer_index == 1){
gcode += writer().set_input_shaping('X', 0.f, print.calib_params().freqStartX);
gcode += writer().set_input_shaping('Y', 0.f, print.calib_params().freqStartY);
if (m_writer.get_gcode_flavor() == gcfKlipper) {
// Disable minimum cruise ratio to ensure consistent motion for calibration
gcode += "SET_VELOCITY_LIMIT MINIMUM_CRUISE_RATIO=0\n";
}
gcode += writer().set_input_shaping('X', 0.f, print.calib_params().freqStartX, print.calib_params().shaper_type);
gcode += writer().set_input_shaping('Y', 0.f, print.calib_params().freqStartY, print.calib_params().shaper_type);
} else {
gcode += writer().set_input_shaping('A', print.calib_params().start + ((print.calib_params().end)-(print.calib_params().start)) * (m_layer_index) / (m_layer_count), 0.f);
gcode += writer().set_input_shaping('A', print.calib_params().start + ((print.calib_params().end)-(print.calib_params().start)) * (m_layer_index) / (m_layer_count), 0.f, "");
}
break;
}

View File

@@ -351,8 +351,10 @@ std::string GCodeWriter::set_pressure_advance(double pa) const
return gcode.str();
}
std::string GCodeWriter::set_input_shaping(char axis, float damp, float freq) const
std::string GCodeWriter::set_input_shaping(char axis, float damp, float freq, std::string type) const
{
if (FLAVOR_IS(gcfMarlinLegacy))
throw std::runtime_error("Input shaping is not supported by Marlin < 2.1.2.\nCheck your firmware version and update your G-code flavor to ´Marlin 2´");
if (freq < 0.0f || damp < 0.f || damp > 1.0f || (axis != 'X' && axis != 'Y' && axis != 'Z' && axis != 'A'))// A = all axis
{
throw std::runtime_error("Invalid input shaping parameters: freq=" + std::to_string(freq) + ", damp=" + std::to_string(damp));
@@ -360,14 +362,17 @@ std::string GCodeWriter::set_input_shaping(char axis, float damp, float freq) co
std::ostringstream gcode;
if (FLAVOR_IS(gcfKlipper)) {
gcode << "SET_INPUT_SHAPER";
if (!type.empty() && type != "Default") {
gcode << " SHAPER_TYPE=" << type;
}
if (axis != 'A')
{
if (freq > 0.0f) {
gcode << " SHAPER_FREQ_" << axis << "=" << std::fixed << std::setprecision(2) << freq;
}
if (damp > 0.0f){
gcode << " DAMPING_RATIO_" << axis << "=" << damp;
}
gcode << " DAMPING_RATIO_" << axis << "=" << std::fixed << std::setprecision(3) << damp;
}
} else {
if (freq > 0.0f) {
gcode << " SHAPER_FREQ_X=" << std::fixed << std::setprecision(2) << freq << " SHAPER_FREQ_Y=" << std::fixed << std::setprecision(2) << freq;
@@ -376,7 +381,18 @@ std::string GCodeWriter::set_input_shaping(char axis, float damp, float freq) co
gcode << " DAMPING_RATIO_X=" << std::fixed << std::setprecision(3) << damp << " DAMPING_RATIO_Y=" << std::fixed << std::setprecision(3) << damp;
}
}
} else {
} else if (FLAVOR_IS(gcfRepRapFirmware)) {
gcode << "M593";
if (!type.empty() && type != "Default" && type != "DAA") {
gcode << " P\"" << type << "\"";
}
if (freq > 0.0f) {
gcode << " F" << std::fixed << std::setprecision(2) << freq;
}
if (damp > 0.0f){
gcode << " S" << std::fixed << std::setprecision(3) << damp;
}
} else if (FLAVOR_IS(gcfMarlinFirmware)) {
gcode << "M593";
if (axis != 'A')
{
@@ -390,6 +406,8 @@ std::string GCodeWriter::set_input_shaping(char axis, float damp, float freq) co
{
gcode << " D" << std::fixed << std::setprecision(3) << damp;
}
} else {
throw std::runtime_error("Input shaping is only supported by Klipper, RepRapFirmware and Marlin 2");
}
if (GCodeWriter::full_gcode_comment){
gcode << " ; Override input shaping";

View File

@@ -58,7 +58,7 @@ public:
std::string set_accel_and_jerk(unsigned int acceleration, double jerk);
std::string set_junction_deviation(double junction_deviation);
std::string set_pressure_advance(double pa) const;
std::string set_input_shaping(char axis, float damp, float freq) const;
std::string set_input_shaping(char axis, float damp, float freq, std::string type) const;
std::string reset_e(bool force = false);
std::string update_progress(unsigned int num, unsigned int tot, bool allow_100 = false) const;
// return false if this extruder was already selected

View File

@@ -3780,14 +3780,14 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionFloat(20));
def = this->add("ironing_angle", coFloat);
def->label = L("Ironing angle");
def->label = L("Ironing angle offset");
def->category = L("Quality");
def->tooltip = L("The angle ironing is done at. A negative number disables this function and uses the default method.");
def->tooltip = L("The angle of ironing lines offset from the top surface.");
def->sidetext = u8"°"; // degrees, don't need translation
def->min = -1;
def->min = 0;
def->max = 359;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(-1));
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("layer_change_gcode", coString);
def->label = L("Layer change G-code");
@@ -7290,6 +7290,8 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
opt_key = "bottom_solid_infill_flow_ratio";
} else if (opt_key == "ironing_direction") {
opt_key = "ironing_angle";
} else if (opt_key == "ironing_angle" && boost::starts_with(value, "-")) {
value = "0";
} else if (opt_key == "counterbole_hole_bridging") {
opt_key = "counterbore_hole_bridging";
} else if (opt_key == "draft_shield" && value == "limited") {

View File

@@ -39,6 +39,7 @@ struct Calib_Params
bool print_numbers;
double freqStartX, freqEndX, freqStartY, freqEndY;
int test_model;
std::string shaper_type;
std::vector<double> accelerations;
std::vector<double> speeds;