Skip to content

Commit

Permalink
Fix min layer time for gradual flow (#1954)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperlamboo authored Sep 20, 2023
2 parents b65a057 + 4a6daa0 commit 7d67915
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 40 deletions.
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 @@ -1049,6 +1049,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 @@ -1853,46 +1853,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 @@ -2403,6 +2363,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

0 comments on commit 7d67915

Please sign in to comment.