Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix min layer time for gradual flow #1954

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,11 @@ class LayerPlan : public NoCopy
*/
void moveInsideCombBoundary(const coord_t distance, const std::optional<SliceLayerPart>& part = std::nullopt);

/*!
* If enabled, apply the modify plugin to the layer-plan.
*/
void applyModifyPlugin();

/*!
* Apply back-pressure compensation to this layer-plan.
* Since the total (filament) pressure in a feeder-system is not only dependent on the pressure that exists between the nozzle and the
Expand Down
1 change: 1 addition & 0 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@ LayerPlan& FffGcodeWriter::processLayer(const SliceDataStorage& storage, LayerIn
}
}

gcode_layer.applyModifyPlugin();
gcode_layer.applyBackPressureCompensation();
return gcode_layer;
}
Expand Down
84 changes: 44 additions & 40 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1852,46 +1852,6 @@ void LayerPlan::writeGCode(GCodeExport& gcode)
{
ExtruderPlan& extruder_plan = extruder_plans[extruder_plan_idx];

scripta::log(
"extruder_plan_0",
extruder_plan.paths,
SectionType::NA,
layer_nr,
scripta::CellVDI{ "flow", &GCodePath::flow },
scripta::CellVDI{ "width_factor", &GCodePath::width_factor },
scripta::CellVDI{ "spiralize", &GCodePath::spiralize },
scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor },
scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor },
scripta::CellVDI{ "retract", &GCodePath::retract },
scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move },
scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop },
scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime },
scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed },
scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath },
scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM });

extruder_plan.paths = slots::instance().modify<plugins::v0::SlotID::GCODE_PATHS_MODIFY>(extruder_plan.paths, extruder_plan.extruder_nr, layer_nr);

// Since the time/material estimates _may_ have changed during the plugin modify step we recalculate it
extruder_plan.computeNaiveTimeEstimates(gcode.getPositionXY());
scripta::log(
"extruder_plan_1",
extruder_plan.paths,
SectionType::NA,
layer_nr,
scripta::CellVDI{ "flow", &GCodePath::flow },
scripta::CellVDI{ "width_factor", &GCodePath::width_factor },
scripta::CellVDI{ "spiralize", &GCodePath::spiralize },
scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor },
scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor },
scripta::CellVDI{ "retract", &GCodePath::retract },
scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move },
scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop },
scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime },
scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed },
scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath },
scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM });

const RetractionAndWipeConfig* retraction_config
= current_mesh ? &current_mesh->retraction_wipe_config : &storage.retraction_wipe_config_per_extruder[extruder_plan.extruder_nr];
coord_t z_hop_height = retraction_config->retraction_config.zHop;
Expand Down Expand Up @@ -2402,6 +2362,50 @@ bool LayerPlan::writePathWithCoasting(
return true;
}

void LayerPlan::applyModifyPlugin()
{
for (auto& extruder_plan : extruder_plans)
{
scripta::log(
"extruder_plan_0",
extruder_plan.paths,
SectionType::NA,
layer_nr,
scripta::CellVDI{ "flow", &GCodePath::flow },
scripta::CellVDI{ "width_factor", &GCodePath::width_factor },
scripta::CellVDI{ "spiralize", &GCodePath::spiralize },
scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor },
scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor },
scripta::CellVDI{ "retract", &GCodePath::retract },
scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move },
scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop },
scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime },
scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed },
scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath },
scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM });

extruder_plan.paths = slots::instance().modify<plugins::v0::SlotID::GCODE_PATHS_MODIFY>(extruder_plan.paths, extruder_plan.extruder_nr, layer_nr);

scripta::log(
"extruder_plan_1",
extruder_plan.paths,
SectionType::NA,
layer_nr,
scripta::CellVDI{ "flow", &GCodePath::flow },
scripta::CellVDI{ "width_factor", &GCodePath::width_factor },
scripta::CellVDI{ "spiralize", &GCodePath::spiralize },
scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor },
scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor },
scripta::CellVDI{ "retract", &GCodePath::retract },
scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move },
scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop },
scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime },
scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed },
scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath },
scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM });
}
}

void LayerPlan::applyBackPressureCompensation()
{
for (auto& extruder_plan : extruder_plans)
Expand Down