Fan Speed Delay + Fan Kickstart Feature (#910)

Initial commit for fan speed delay, required some changes when porting from SuperSlicer.

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Scott Mudge 2023-05-06 01:41:47 -04:00 committed by GitHub
parent d6290fdbbb
commit 2e223551e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 691 additions and 4 deletions

View file

@ -1443,6 +1443,8 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
m_last_mm3_per_mm = 0.;
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
m_fan_mover.release();
m_writer.set_is_bbl_machine(is_bbl_printers);
@ -1810,6 +1812,10 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_writer.set_current_position_clear(false);
m_start_gcode_filament = GCodeProcessor::get_gcode_last_filament(machine_start_gcode);
//flush FanMover buffer to avoid modifying the start gcode if it's manual.
if (!machine_start_gcode.empty() && this->m_fan_mover.get() != nullptr)
file.write(this->m_fan_mover.get()->process_gcode("", true));
// Process filament-specific gcode.
/* if (has_wipe_tower) {
// Wipe tower will control the extruder switching, it will call the filament_start_gcode.
@ -2186,11 +2192,30 @@ void GCode::process_layers(
[&output_stream](std::string s) { output_stream.write(s); }
);
const auto fan_mover = tbb::make_filter<std::string, std::string>(slic3r_tbb_filtermode::serial_in_order,
[&fan_mover = this->m_fan_mover, &config = this->config(), &writer = this->m_writer](std::string in)->std::string {
CNumericLocalesSetter locales_setter;
if (config.fan_speedup_time.value != 0 || config.fan_kickstart.value > 0) {
if (fan_mover.get() == nullptr)
fan_mover.reset(new Slic3r::FanMover(
writer,
std::abs((float)config.fan_speedup_time.value),
config.fan_speedup_time.value > 0,
config.use_relative_e_distances.value,
config.fan_speedup_overhangs.value,
(float)config.fan_kickstart.value));
//flush as it's a whole layer
return fan_mover->process_gcode(in, true);
}
return in;
});
// The pipeline elements are joined using const references, thus no copying is performed.
if (m_spiral_vase)
tbb::parallel_pipeline(12, generator & spiral_mode & cooling & output);
tbb::parallel_pipeline(12, generator & spiral_mode & cooling & fan_mover & output);
else
tbb::parallel_pipeline(12, generator & cooling & output);
tbb::parallel_pipeline(12, generator & cooling & fan_mover & output);
}
// Process all layers of a single object instance (sequential mode) with a parallel pipeline:
@ -2234,11 +2259,29 @@ void GCode::process_layers(
[&output_stream](std::string s) { output_stream.write(s); }
);
const auto fan_mover = tbb::make_filter<std::string, std::string>(slic3r_tbb_filtermode::serial_in_order,
[&fan_mover = this->m_fan_mover, &config = this->config(), &writer = this->m_writer](std::string in)->std::string {
if (config.fan_speedup_time.value != 0 || config.fan_kickstart.value > 0) {
if (fan_mover.get() == nullptr)
fan_mover.reset(new Slic3r::FanMover(
writer,
std::abs((float)config.fan_speedup_time.value),
config.fan_speedup_time.value > 0,
config.use_relative_e_distances.value,
config.fan_speedup_overhangs.value,
(float)config.fan_kickstart.value));
//flush as it's a whole layer
return fan_mover->process_gcode(in, true);
}
return in;
});
// The pipeline elements are joined using const references, thus no copying is performed.
if (m_spiral_vase)
tbb::parallel_pipeline(12, generator & spiral_mode & cooling & output);
tbb::parallel_pipeline(12, generator & spiral_mode & cooling & fan_mover & output);
else
tbb::parallel_pipeline(12, generator & cooling & output);
tbb::parallel_pipeline(12, generator & cooling & fan_mover & output);
}
std::string GCode::placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override)