mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 10:17:55 -06:00
semm
This commit is contained in:
parent
ee4705d6b7
commit
e624632969
142 changed files with 741 additions and 597 deletions
|
@ -128,9 +128,9 @@ public:
|
|||
}
|
||||
|
||||
WipeTowerWriter& disable_linear_advance() {
|
||||
if(m_gcode_flavor == gcfKlipper)
|
||||
if (m_gcode_flavor == gcfKlipper)
|
||||
m_gcode += "SET_PRESSURE_ADVANCE ADVANCE=0\n";
|
||||
else if(m_gcode_flavor == gcfRepRapFirmware)
|
||||
else if (m_gcode_flavor == gcfRepRapFirmware)
|
||||
m_gcode += std::string("M572 D") + std::to_string(m_current_tool) + " S0\n";
|
||||
else
|
||||
m_gcode += "M900 K0\n";
|
||||
|
@ -418,30 +418,36 @@ public:
|
|||
// Let the firmware back up the active speed override value.
|
||||
WipeTowerWriter& speed_override_backup()
|
||||
{
|
||||
// This is only supported by Prusa at this point (https://github.com/prusa3d/PrusaSlicer/issues/3114)
|
||||
// BBS: BBL machine don't support speed backup
|
||||
#if 0
|
||||
if (m_gcode_flavor == gcfMarlinLegacy || m_gcode_flavor == gcfMarlinFirmware)
|
||||
m_gcode += "M220 B\n";
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Let the firmware restore the active speed override value.
|
||||
WipeTowerWriter& speed_override_restore()
|
||||
{
|
||||
// BBS: BBL machine don't support speed restore
|
||||
#if 0
|
||||
if (m_gcode_flavor == gcfMarlinLegacy || m_gcode_flavor == gcfMarlinFirmware)
|
||||
m_gcode += "M220 R\n";
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Set digital trimpot motor
|
||||
WipeTowerWriter& set_extruder_trimpot(int current)
|
||||
{
|
||||
if (m_gcode_flavor == gcfKlipper)
|
||||
return *this;
|
||||
// BBS: don't control trimpot
|
||||
#if 0
|
||||
if (m_gcode_flavor == gcfRepRapSprinter || m_gcode_flavor == gcfRepRapFirmware)
|
||||
m_gcode += "M906 E";
|
||||
else
|
||||
m_gcode += "M907 E";
|
||||
m_gcode += std::to_string(current) + "\n";
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -1328,33 +1334,6 @@ WipeTower::ToolChangeResult WipeTower::finish_layer(bool extrude_perimeter, bool
|
|||
return construct_tcr(writer, false, old_tool, true, 0.f);
|
||||
}
|
||||
|
||||
// Static method to extract wipe_volumes[from][to] from the configuration.
|
||||
std::vector<std::vector<float>> WipeTower::extract_wipe_volumes(const PrintConfig& config)
|
||||
{
|
||||
// Get wiping matrix to get number of extruders and convert vector<double> to vector<float>:
|
||||
std::vector<float> wiping_matrix(cast<float>(config.flush_volumes_matrix.values));
|
||||
auto scale = config.flush_multiplier;
|
||||
|
||||
// Orca todo: currently we only/always support SEMM.
|
||||
// The values shall only be used when SEMM is enabled. The purging for other printers
|
||||
// is determined by filament_minimal_purge_on_wipe_tower.
|
||||
// if (! config.single_extruder_multi_material.value)
|
||||
// std::fill(wiping_matrix.begin(), wiping_matrix.end(), 0.f);
|
||||
|
||||
// Extract purging volumes for each extruder pair:
|
||||
std::vector<std::vector<float>> wipe_volumes;
|
||||
const unsigned int number_of_extruders = (unsigned int)(sqrt(wiping_matrix.size())+EPSILON);
|
||||
for (unsigned int i = 0; i<number_of_extruders; ++i)
|
||||
wipe_volumes.push_back(std::vector<float>(wiping_matrix.begin()+i*number_of_extruders, wiping_matrix.begin()+(i+1)*number_of_extruders));
|
||||
|
||||
// Also include filament_minimal_purge_on_wipe_tower. This is needed for the preview.
|
||||
for (unsigned int i = 0; i<number_of_extruders; ++i)
|
||||
for (unsigned int j = 0; j<number_of_extruders; ++j)
|
||||
wipe_volumes[i][j] = std::max<float>(wipe_volumes[i][j] * scale, config.filament_minimal_purge_on_wipe_tower.get_at(j));
|
||||
|
||||
return wipe_volumes;
|
||||
}
|
||||
|
||||
// Appends a toolchange into m_plan and calculates neccessary depth of the corresponding box
|
||||
void WipeTower::plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool,
|
||||
unsigned int new_tool, float wipe_volume, float purge_volume)
|
||||
|
|
|
@ -25,7 +25,6 @@ public:
|
|||
|
||||
// WipeTower height to minimum depth map
|
||||
static const std::map<float, float> min_depth_per_height;
|
||||
static std::vector<std::vector<float>> extract_wipe_volumes(const PrintConfig& config);
|
||||
|
||||
struct Extrusion
|
||||
{
|
||||
|
@ -256,15 +255,14 @@ public:
|
|||
bool is_support = false;
|
||||
int nozzle_temperature = 0;
|
||||
int nozzle_temperature_initial_layer = 0;
|
||||
// BBS: remove useless config
|
||||
//float loading_speed = 0.f;
|
||||
//float loading_speed_start = 0.f;
|
||||
//float unloading_speed = 0.f;
|
||||
//float unloading_speed_start = 0.f;
|
||||
//float delay = 0.f ;
|
||||
//int cooling_moves = 0;
|
||||
//float cooling_initial_speed = 0.f;
|
||||
//float cooling_final_speed = 0.f;
|
||||
float loading_speed = 0.f;
|
||||
float loading_speed_start = 0.f;
|
||||
float unloading_speed = 0.f;
|
||||
float unloading_speed_start = 0.f;
|
||||
float delay = 0.f ;
|
||||
int cooling_moves = 0;
|
||||
float cooling_initial_speed = 0.f;
|
||||
float cooling_final_speed = 0.f;
|
||||
float ramming_line_width_multiplicator = 1.f;
|
||||
float ramming_step_multiplicator = 1.f;
|
||||
float max_e_speed = std::numeric_limits<float>::max();
|
||||
|
@ -288,6 +286,7 @@ private:
|
|||
|
||||
bool m_enable_timelapse_print = false;
|
||||
bool m_semm = true; // Are we using a single extruder multimaterial printer?
|
||||
bool m_purge_in_prime_tower = false; // Do we purge in the prime tower?
|
||||
Vec2f m_wipe_tower_pos; // Left front corner of the wipe tower in mm.
|
||||
float m_wipe_tower_width; // Width of the wipe tower.
|
||||
float m_wipe_tower_depth = 0.f; // Depth of the wipe tower
|
||||
|
@ -307,15 +306,13 @@ private:
|
|||
size_t m_first_layer_idx = size_t(-1);
|
||||
|
||||
// G-code generator parameters.
|
||||
// BBS: remove useless config
|
||||
//float m_cooling_tube_retraction = 0.f;
|
||||
//float m_cooling_tube_length = 0.f;
|
||||
//float m_parking_pos_retraction = 0.f;
|
||||
//float m_extra_loading_move = 0.f;
|
||||
float m_cooling_tube_retraction = 0.f;
|
||||
float m_cooling_tube_length = 0.f;
|
||||
float m_parking_pos_retraction = 0.f;
|
||||
float m_extra_loading_move = 0.f;
|
||||
float m_bridging = 0.f;
|
||||
bool m_no_sparse_layers = false;
|
||||
// BBS: remove useless config
|
||||
//bool m_set_extruder_trimpot = false;
|
||||
bool m_set_extruder_trimpot = false;
|
||||
bool m_adhesion = true;
|
||||
GCodeFlavor m_gcode_flavor;
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Orca: This file is ported from latest PrusaSlicer
|
||||
|
||||
// Original PrusaSlicer Copyright:
|
||||
///|/ Copyright (c) Prusa Research 2017 - 2023 Lukáš Matěna @lukasmatena, Vojtěch Bubník @bubnikv, Enrico Turri @enricoturri1966
|
||||
///|/ Copyright (c) SuperSlicer 2023 Remi Durand @supermerill
|
||||
///|/ Copyright (c) 2020 Paul Arden @ardenpm
|
||||
|
@ -141,8 +144,8 @@ public:
|
|||
float get_and_reset_used_filament_length() { float temp = m_used_filament_length; m_used_filament_length = 0.f; return temp; }
|
||||
|
||||
// Extrude with an explicitely provided amount of extrusion.
|
||||
WipeTowerWriter2& extrude_explicit(float x, float y, float e, float f = 0.f, bool record_length = false, bool limit_volumetric_flow = true)
|
||||
{
|
||||
WipeTowerWriter2& extrude_explicit(float x, float y, float e, float f = 0.f, bool record_length = false, bool limit_volumetric_flow = true)
|
||||
{
|
||||
if (x == m_current_pos.x() && y == m_current_pos.y() && e == 0.f && (f == 0.f || f == m_current_feedrate))
|
||||
// Neither extrusion nor a travel move.
|
||||
return *this;
|
||||
|
@ -205,17 +208,17 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
WipeTowerWriter2& extrude_explicit(const Vec2f &dest, float e, float f = 0.f, bool record_length = false, bool limit_volumetric_flow = true)
|
||||
{ return extrude_explicit(dest.x(), dest.y(), e, f, record_length); }
|
||||
WipeTowerWriter2& extrude_explicit(const Vec2f &dest, float e, float f = 0.f, bool record_length = false, bool limit_volumetric_flow = true)
|
||||
{ return extrude_explicit(dest.x(), dest.y(), e, f, record_length); }
|
||||
|
||||
// Travel to a new XY position. f=0 means use the current value.
|
||||
// Travel to a new XY position. f=0 means use the current value.
|
||||
WipeTowerWriter2& travel(float x, float y, float f = 0.f)
|
||||
{ return extrude_explicit(x, y, 0.f, f); }
|
||||
{ return extrude_explicit(x, y, 0.f, f); }
|
||||
|
||||
WipeTowerWriter2& travel(const Vec2f &dest, float f = 0.f)
|
||||
{ return extrude_explicit(dest.x(), dest.y(), 0.f, f); }
|
||||
WipeTowerWriter2& travel(const Vec2f &dest, float f = 0.f)
|
||||
{ return extrude_explicit(dest.x(), dest.y(), 0.f, f); }
|
||||
|
||||
// Extrude a line from current position to x, y with the extrusion amount given by m_extrusion_flow.
|
||||
// Extrude a line from current position to x, y with the extrusion amount given by m_extrusion_flow.
|
||||
WipeTowerWriter2& extrude(float x, float y, float f = 0.f)
|
||||
{
|
||||
float dx = x - m_current_pos.x();
|
||||
|
@ -223,8 +226,8 @@ public:
|
|||
return extrude_explicit(x, y, std::sqrt(dx*dx+dy*dy) * m_extrusion_flow, f, true);
|
||||
}
|
||||
|
||||
WipeTowerWriter2& extrude(const Vec2f &dest, const float f = 0.f)
|
||||
{ return extrude(dest.x(), dest.y(), f); }
|
||||
WipeTowerWriter2& extrude(const Vec2f &dest, const float f = 0.f)
|
||||
{ return extrude(dest.x(), dest.y(), f); }
|
||||
|
||||
WipeTowerWriter2& rectangle(const Vec2f& ld,float width,float height,const float f = 0.f)
|
||||
{
|
||||
|
@ -310,8 +313,8 @@ public:
|
|||
// extrude quickly amount e to x2 with feed f.
|
||||
WipeTowerWriter2& ram(float x1, float x2, float dy, float e0, float e, float f)
|
||||
{
|
||||
extrude_explicit(x1, m_current_pos.y() + dy, e0, f, true, false);
|
||||
extrude_explicit(x2, m_current_pos.y(), e, 0.f, true, false);
|
||||
extrude_explicit(x1, m_current_pos.y() + dy, e0, f, true, false);
|
||||
extrude_explicit(x2, m_current_pos.y(), e, 0.f, true, false);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -505,7 +508,8 @@ private:
|
|||
|
||||
WipeTower::ToolChangeResult WipeTower2::construct_tcr(WipeTowerWriter2& writer,
|
||||
bool priming,
|
||||
size_t old_tool) const
|
||||
size_t old_tool,
|
||||
bool is_finish) const
|
||||
{
|
||||
WipeTower::ToolChangeResult result;
|
||||
result.priming = priming;
|
||||
|
@ -519,6 +523,7 @@ WipeTower::ToolChangeResult WipeTower2::construct_tcr(WipeTowerWriter2& writer,
|
|||
result.gcode = std::move(writer.gcode());
|
||||
result.extrusions = std::move(writer.extrusions());
|
||||
result.wipe_path = std::move(writer.wipe_path());
|
||||
result.is_finish_first = is_finish;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -526,6 +531,7 @@ WipeTower::ToolChangeResult WipeTower2::construct_tcr(WipeTowerWriter2& writer,
|
|||
|
||||
WipeTower2::WipeTower2(const PrintConfig& config, const PrintRegionConfig& default_region_config,int plate_idx, Vec3d plate_origin, const std::vector<std::vector<float>>& wiping_matrix, size_t initial_tool) :
|
||||
m_semm(config.single_extruder_multi_material.value),
|
||||
m_enable_filament_ramming(config.enable_filament_ramming.value),
|
||||
m_wipe_tower_pos(config.wipe_tower_x.get_at(plate_idx), config.wipe_tower_y.get_at(plate_idx)),
|
||||
m_wipe_tower_width(float(config.prime_tower_width)),
|
||||
m_wipe_tower_rotation_angle(float(config.wipe_tower_rotation_angle)),
|
||||
|
@ -752,7 +758,7 @@ std::vector<WipeTower::ToolChangeResult> WipeTower2::prime(
|
|||
"\n\n");
|
||||
}
|
||||
|
||||
results.emplace_back(construct_tcr(writer, true, old_tool));
|
||||
results.emplace_back(construct_tcr(writer, true, old_tool, true));
|
||||
}
|
||||
|
||||
m_old_temperature = -1; // If the priming is turned off in config, the temperature changing commands will not actually appear
|
||||
|
@ -839,7 +845,7 @@ WipeTower::ToolChangeResult WipeTower2::tool_change(size_t tool)
|
|||
if (m_current_tool < m_used_filament_length.size())
|
||||
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
return construct_tcr(writer, false, old_tool);
|
||||
return construct_tcr(writer, false, old_tool, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -866,7 +872,7 @@ void WipeTower2::toolchange_Unload(
|
|||
float remaining = xr - xl ; // keeps track of distance to the next turnaround
|
||||
float e_done = 0; // measures E move done from each segment
|
||||
|
||||
const bool do_ramming = m_semm || m_filpar[m_current_tool].multitool_ramming;
|
||||
const bool do_ramming = m_enable_filament_ramming && (m_semm || m_filpar[m_current_tool].multitool_ramming);
|
||||
|
||||
if (do_ramming) {
|
||||
writer.travel(ramming_start_pos); // move to starting position
|
||||
|
@ -906,6 +912,7 @@ void WipeTower2::toolchange_Unload(
|
|||
}
|
||||
|
||||
|
||||
writer.append("; Ramming\n");
|
||||
// now the ramming itself:
|
||||
while (do_ramming && i < m_filpar[m_current_tool].ramming_speed.size())
|
||||
{
|
||||
|
@ -933,6 +940,7 @@ void WipeTower2::toolchange_Unload(
|
|||
Vec2f end_of_ramming(writer.x(),writer.y());
|
||||
writer.change_analyzer_line_width(m_perimeter_width); // so the next lines are not affected by ramming_line_width_multiplier
|
||||
|
||||
writer.append("; Retract(unload)\n");
|
||||
// Retraction:
|
||||
float old_x = writer.x();
|
||||
float turning_point = (!m_left_to_right ? xl : xr );
|
||||
|
@ -957,6 +965,7 @@ void WipeTower2::toolchange_Unload(
|
|||
}
|
||||
}
|
||||
|
||||
writer.append("; Cooling\n");
|
||||
// Cooling:
|
||||
const int& number_of_moves = m_filpar[m_current_tool].cooling_moves;
|
||||
if (m_semm && number_of_moves > 0) {
|
||||
|
@ -978,6 +987,7 @@ void WipeTower2::toolchange_Unload(
|
|||
}
|
||||
|
||||
if (m_semm) {
|
||||
writer.append("; Cooling park\n");
|
||||
// let's wait is necessary:
|
||||
writer.wait(m_filpar[m_current_tool].delay);
|
||||
// we should be at the beginning of the cooling tube again - let's move to parking position:
|
||||
|
@ -1006,25 +1016,21 @@ void WipeTower2::toolchange_Change(
|
|||
if (m_current_tool < m_used_filament_length.size())
|
||||
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
// Orca TODO: handle multi extruders
|
||||
|
||||
// This is where we want to place the custom gcodes. We will use placeholders for this.
|
||||
// These will be substituted by the actual gcodes when the gcode is generated.
|
||||
//writer.append("[end_filament_gcode]\n");
|
||||
//writer.append("[toolchange_gcode]\n");
|
||||
|
||||
writer.append("[filament_end_gcode]\n");
|
||||
writer.append("[change_filament_gcode]\n");
|
||||
|
||||
// Travel to where we assume we are. Custom toolchange or some special T code handling (parking extruder etc)
|
||||
// gcode could have left the extruder somewhere, we cannot just start extruding. We should also inform the
|
||||
// postprocessor that we absolutely want to have this in the gcode, even if it thought it is the same as before.
|
||||
// Vec2f current_pos = writer.pos_rotated();
|
||||
// writer.feedrate(m_travel_speed * 60.f) // see https://github.com/prusa3d/PrusaSlicer/issues/5483
|
||||
// .append(std::string("G1 X") + Slic3r::float_to_string_decimal_point(current_pos.x())
|
||||
// + " Y" + Slic3r::float_to_string_decimal_point(current_pos.y())
|
||||
// + never_skip_tag() + "\n");
|
||||
// Orca todo: handle deretraction_from_wipe_tower_generator
|
||||
// writer.append("[deretraction_from_wipe_tower_generator]");
|
||||
Vec2f current_pos = writer.pos_rotated();
|
||||
writer.feedrate(m_travel_speed * 60.f) // see https://github.com/prusa3d/PrusaSlicer/issues/5483
|
||||
.append(std::string("G1 X") + Slic3r::float_to_string_decimal_point(current_pos.x())
|
||||
+ " Y" + Slic3r::float_to_string_decimal_point(current_pos.y())
|
||||
+ never_skip_tag() + "\n");
|
||||
writer.append("[deretraction_from_wipe_tower_generator]");
|
||||
|
||||
// Orca TODO: handle multi extruders
|
||||
// The toolchange Tn command will be inserted later, only in case that the user does
|
||||
|
@ -1379,7 +1385,7 @@ WipeTower::ToolChangeResult WipeTower2::finish_layer()
|
|||
m_current_height += m_layer_info->height;
|
||||
}
|
||||
|
||||
return construct_tcr(writer, false, old_tool);
|
||||
return construct_tcr(writer, false, old_tool, true);
|
||||
}
|
||||
|
||||
// Static method to get the radius and x-scaling of the stabilizing cone base.
|
||||
|
@ -1404,10 +1410,12 @@ std::vector<std::vector<float>> WipeTower2::extract_wipe_volumes(const PrintConf
|
|||
{
|
||||
// Get wiping matrix to get number of extruders and convert vector<double> to vector<float>:
|
||||
std::vector<float> wiping_matrix(cast<float>(config.flush_volumes_matrix.values));
|
||||
auto scale = config.flush_multiplier;
|
||||
|
||||
// Orca todo: currently we only/always support SEMM.
|
||||
// The values shall only be used when SEMM is enabled. The purging for other printers
|
||||
// is determined by filament_minimal_purge_on_wipe_tower.
|
||||
if (! config.single_extruder_multi_material.value)
|
||||
if (! config.purge_in_prime_tower.value)
|
||||
std::fill(wiping_matrix.begin(), wiping_matrix.end(), 0.f);
|
||||
|
||||
// Extract purging volumes for each extruder pair:
|
||||
|
@ -1419,7 +1427,7 @@ std::vector<std::vector<float>> WipeTower2::extract_wipe_volumes(const PrintConf
|
|||
// Also include filament_minimal_purge_on_wipe_tower. This is needed for the preview.
|
||||
for (unsigned int i = 0; i<number_of_extruders; ++i)
|
||||
for (unsigned int j = 0; j<number_of_extruders; ++j)
|
||||
wipe_volumes[i][j] = std::max<float>(wipe_volumes[i][j], config.filament_minimal_purge_on_wipe_tower.get_at(j));
|
||||
wipe_volumes[i][j] = std::max<float>(wipe_volumes[i][j] * scale, config.filament_minimal_purge_on_wipe_tower.get_at(j));
|
||||
|
||||
return wipe_volumes;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Orca: This file is ported from latest PrusaSlicer
|
||||
|
||||
// Original PrusaSlicer Copyright:
|
||||
///|/ Copyright (c) Prusa Research 2017 - 2023 Lukáš Matěna @lukasmatena, Vojtěch Bubník @bubnikv
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
|
@ -31,7 +34,8 @@ public:
|
|||
// WipeTowerWriter2 is moved from !
|
||||
WipeTower::ToolChangeResult construct_tcr(WipeTowerWriter2& writer,
|
||||
bool priming,
|
||||
size_t old_tool) const;
|
||||
size_t old_tool,
|
||||
bool is_finish) const;
|
||||
|
||||
// x -- x coordinates of wipe tower in mm ( left bottom corner )
|
||||
// y -- y coordinates of wipe tower in mm ( left bottom corner )
|
||||
|
@ -168,6 +172,7 @@ private:
|
|||
|
||||
|
||||
bool m_semm = true; // Are we using a single extruder multimaterial printer?
|
||||
bool m_enable_filament_ramming = true;
|
||||
Vec2f m_wipe_tower_pos; // Left front corner of the wipe tower in mm.
|
||||
float m_wipe_tower_width; // Width of the wipe tower.
|
||||
float m_wipe_tower_depth = 0.f; // Depth of the wipe tower
|
||||
|
@ -314,9 +319,6 @@ private:
|
|||
float wipe_volume);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // WipeTowerPrusaMM_hpp_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue