change print flow ratio to float.

Also fixed an issue that maximum volumetric speed is not respected
#93 #103
This commit is contained in:
SoftFever 2023-01-04 11:29:13 +08:00
parent 6d99cfbaa2
commit 60acc6b4e8
4 changed files with 11 additions and 10 deletions

View file

@ -3699,7 +3699,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
}
// calculate extrusion length per distance unit
double e_per_mm = m_writer.extruder()->e_per_mm3() * path.mm3_per_mm * this->config().print_flow_ratio.get_abs_value(1);
const auto _mm3_per_mm = path.mm3_per_mm * this->config().print_flow_ratio;
double e_per_mm = m_writer.extruder()->e_per_mm3() * _mm3_per_mm;
double min_speed = double(m_config.slow_down_min_speed.get_at(m_writer.extruder()->id()));
// set speed
@ -3743,7 +3744,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
}
//BBS: if not set the speed, then use the filament_max_volumetric_speed directly
if (speed == 0)
speed = EXTRUDER_CONFIG(filament_max_volumetric_speed) / path.mm3_per_mm;
speed = EXTRUDER_CONFIG(filament_max_volumetric_speed) / _mm3_per_mm;
if (this->on_first_layer()) {
//BBS: for solid infill of initial layer, speed can be higher as long as
//wall lines have be attached
@ -3757,14 +3758,14 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
// // cap speed with max_volumetric_speed anyway (even if user is not using autospeed)
// speed = std::min(
// speed,
// m_config.max_volumetric_speed.value / path.mm3_per_mm
// m_config.max_volumetric_speed.value / _mm3_per_mm
// );
//}
if (EXTRUDER_CONFIG(filament_max_volumetric_speed) > 0) {
// cap speed with max_volumetric_speed anyway (even if user is not using autospeed)
speed = std::min(
speed,
EXTRUDER_CONFIG(filament_max_volumetric_speed) / path.mm3_per_mm
EXTRUDER_CONFIG(filament_max_volumetric_speed) / _mm3_per_mm
);
}
double F = speed * 60; // convert mm/sec to mm/min

View file

@ -1152,16 +1152,16 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats { 1. });
def = this->add("print_flow_ratio", coPercent);
def = this->add("print_flow_ratio", coFloat);
def->label = L("Flow ratio");
def->tooltip = L("The material may have volumetric change after switching between molten state and crystalline state. "
"This setting changes all extrusion flow of this filament in gcode proportionally. "
"Recommended value range is between 0.95 and 1.05. "
"Maybe you can tune this value to get nice flat surface when there has slight overflow or underflow");
def->sidetext = L("%");
def->mode = comAdvanced;
def->min = 2;
def->set_default_value(new ConfigOptionPercent(100));
def->max = 2;
def->min = 0.01;
def->set_default_value(new ConfigOptionFloat(1));
def = this->add("enable_pressure_advance", coBools);
def->label = L("Enable pressure advance");

View file

@ -755,7 +755,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, only_one_wall_top))
((ConfigOptionBool, only_one_wall_first_layer))
//SoftFever
((ConfigOptionPercent, print_flow_ratio))
((ConfigOptionFloat, print_flow_ratio))
)
PRINT_CONFIG_CLASS_DEFINE(

View file

@ -8014,7 +8014,7 @@ void Plater::calib_flowrate(int pass) {
if (obj_name[0] == 'm')
obj_name[0] = '-';
auto modifier = stof(obj_name);
_obj->config.set_key_value("print_flow_ratio", new ConfigOptionPercent(100 + modifier));
_obj->config.set_key_value("print_flow_ratio", new ConfigOptionFloat(1.0f + modifier/100.f));
}
print_config->set_key_value("layer_height", new ConfigOptionFloat(layer_height));