Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Jun 3, 2024
2 parents 40d87ac + 6cdc5c9 commit 5c8cc63
Show file tree
Hide file tree
Showing 20 changed files with 157 additions and 42 deletions.
10 changes: 5 additions & 5 deletions resources/calibration/over-bridge_tuning/over-bridge_tuning.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ <h1>Ironing Pattern Calibration</h1>
</table>

<p><strong>You need to do the filament flow calibration and the bridge flow ratio before this one.</strong> It's better if you have done the filament temperature calibration as well.</p>
<p>This calibration method will print test samples with various levels of over-bridge flow ratio, between 100 and 125. Choose the lowest value on which the top surface is smooth without rough "holes". Begin with the over-bridge calibraiton.</p>
<p>If the over-bridge calibration is not conclusive (same holes on all samples), then set it to 110% and use the top flow calibration. This setting is a bit more unpredictable so it's best to not move it far away from 100%.</p>
<p>This calibration method will print test samples with various levels of above-bridge flow ratio, between 100 and 125. Choose the lowest value on which the top surface is smooth without rough "holes". Begin with the above-bridge calibraiton.</p>
<p>If the above-bridge calibration is not conclusive (same holes on all samples), then set it to 110% and use the top flow calibration. This setting is a bit more unpredictable so it's best to not move it far away from 100%.</p>
<h2>Results</h2>
<table width="100%">
<tbody>
Expand All @@ -46,10 +46,10 @@ <h4>Example:</h4>
<td style="text-align: center;">Flat</td>
</tr>
</table>
Here, we can see that artifacts exist until the over-bridge flow was set to 115. It was flat from the flow calibration, if it's not now, it's because the bridges below the top surfaces are dropping a bit, and so it leaves more volume to fill afterwards. Here, 115 should be enough, but 120 is a more safe bet.
Here, we can see that artifacts exist until the above-bridge flow was set to 115. It was flat from the flow calibration, if it's not now, it's because the bridges below the top surfaces are dropping a bit, and so it leaves more volume to fill afterwards. Here, 115 should be enough, but 120 is a more safe bet.

<h2>Advice</h2>
<p>TODO</p>
<!-- <h2>Advice</h2> -->
<!-- <p>TODO</p> -->
</ul>
<h2>Notes</h2>
<p>This test set the setting "Complete individual objects" to true, so you may want to reset your print settings afterwards</p>
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/ExtrusionEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ class ExtrusionMultiEntity : public ExtrusionEntity {
std::vector<THING> paths;

ExtrusionMultiEntity(): ExtrusionEntity(false) {};
ExtrusionMultiEntity(const ExtrusionMultiEntity &rhs) : paths(rhs.paths), ExtrusionEntity(false) {}
ExtrusionMultiEntity(ExtrusionMultiEntity &&rhs) : paths(std::move(rhs.paths)), ExtrusionEntity(false) {}
ExtrusionMultiEntity(const ExtrusionMultiEntity &rhs) : paths(rhs.paths), ExtrusionEntity(rhs.m_can_reverse) {}
ExtrusionMultiEntity(ExtrusionMultiEntity &&rhs) : paths(std::move(rhs.paths)), ExtrusionEntity(rhs.m_can_reverse) {}
ExtrusionMultiEntity(const std::vector<THING> &paths) : paths(paths), ExtrusionEntity(false) {};
ExtrusionMultiEntity(const THING &path): ExtrusionEntity(false) { this->paths.push_back(path); }

Expand Down
21 changes: 13 additions & 8 deletions src/libslic3r/Fill/Fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,14 +844,18 @@ void Layer::make_ironing()
}
if (ironing_params.extruder != -1) {
//TODO just_infill is currently not used.
ironing_params.type = config.ironing_type;
ironing_params.just_infill = false;
ironing_params.type = config.ironing_type;
ironing_params.just_infill = false;
ironing_params.line_spacing = config.ironing_spacing;
ironing_params.height = default_layer_height * 0.01 * config.ironing_flowrate;
ironing_params.speed = config.ironing_speed;
ironing_params.angle = config.ironing_angle <0 ?
compute_fill_angle(config, layerm->layer()->id()) :
float(Geometry::deg2rad(config.ironing_angle.value));
ironing_params.height = default_layer_height * 0.01 * config.ironing_flowrate;
ironing_params.speed = config.ironing_speed;
if (config.ironing_angle.value >= 0) {
ironing_params.angle = float(Geometry::deg2rad(config.ironing_angle.value));
} else {
ironing_params.angle = compute_fill_angle(config, layerm->layer()->id());
if (config.ironing_angle.value < -1)
ironing_params.angle += float(Geometry::deg2rad(-config.ironing_angle.value));
}
ironing_params.layerm = layerm;
by_extruder.emplace_back(ironing_params);
}
Expand Down Expand Up @@ -933,7 +937,8 @@ void Layer::make_ironing()

// Create the filler object.
fill.init_spacing(ironing_params.line_spacing, fill_params);
fill.angle = float(ironing_params.angle + 0.25 * M_PI);
fill.can_angle_cross = region_config.fill_angle_cross.value;
fill.angle = float(ironing_params.angle);
fill.link_max_length = (coord_t)scale_(3. * fill.get_spacing());
double extrusion_height = ironing_params.height * fill.get_spacing() / nozzle_dmr;
//FIXME FLOW decide if it's good
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/Fill/FillBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ std::pair<float, Point> Fill::_infill_direction(const Surface *surface) const
// printf("Layer_ID undefined!\n");
}

//why?
out_angle += float(M_PI/2.);
return std::pair<float, Point>(out_angle, out_shift);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Fill/FillSmooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace Slic3r {
f2->init_spacing(this->get_spacing(), params);
f2->layer_id = this->layer_id;
f2->z = this->z;
f2->angle = anglePass[idx] + this->angle;
f2->angle = (this->can_angle_cross ? anglePass[idx] : 0) + this->angle;
// Maximum length of the perimeter segment linking two infill lines.
f2->link_max_length = this->link_max_length;
// Used by the concentric infill pattern to clip the loops to create extrusion paths.
Expand Down
29 changes: 29 additions & 0 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,11 @@ void GCode::_do_export(Print& print_mod, GCodeOutputStream &file, ThumbnailsGene
start_filament_gcode = this->placeholder_parser_process("start_filament_gcode", m_config.start_filament_gcode.get_at(initial_extruder_id), initial_extruder_id, &config);
}
std::string start_all_gcode = start_gcode + "\"n" + start_filament_gcode;

// Set chamber temperature
if((initial_extruder_id != (uint16_t)-1) && !this->config().start_gcode_manual && print.config().chamber_temperature.get_at(initial_extruder_id) != 0)
this->_print_first_layer_chamber_temperature(preamble_to_put_start_layer, print, start_all_gcode, initial_extruder_id, false);

// Set bed temperature if the start G-code does not contain any bed temp control G-codes.
if((initial_extruder_id != (uint16_t)-1) && !this->config().start_gcode_manual && this->config().gcode_flavor != gcfKlipper && print.config().first_layer_bed_temperature.get_at(initial_extruder_id) != 0)
this->_print_first_layer_bed_temperature(preamble_to_put_start_layer, print, start_all_gcode, initial_extruder_id, false);
Expand Down Expand Up @@ -2155,6 +2160,8 @@ void GCode::_do_export(Print& print_mod, GCodeOutputStream &file, ThumbnailsGene
}
}
file.writeln(this->placeholder_parser_process("end_gcode", print.config().end_gcode, m_writer.tool()->id(), &config));
} else {
assert(false); // what is the use-case?
}
file.write(m_writer.update_progress(m_layer_count, m_layer_count, true)); // 100%
file.write(m_writer.postamble());
Expand Down Expand Up @@ -2695,6 +2702,28 @@ void GCode::_print_first_layer_bed_temperature(std::string &out, const Print &pr
out += (set_temp_gcode);
}

// Write 1st layer chamber temperatures into the G-code.
// Only do that if the start G-code does not already contain any M-code controlling an extruder temperature.
// M141 - Set chamber Temperature
// M191 - Set chamber Temperature and Wait
void GCode::_print_first_layer_chamber_temperature(std::string &out, const Print &print, const std::string &gcode, uint16_t first_printing_extruder_id, bool wait)
{
// Initial bed temperature based on the first extruder.
int temp = print.config().chamber_temperature.get_at(first_printing_extruder_id);
//disable bed temp control if 0
if (temp == 0) return;
// Is the bed temperature set by the provided custom G-code?
int temp_by_gcode = -1;
bool temp_set_by_gcode = custom_gcode_sets_temperature(gcode, 141, 191, false, temp_by_gcode);
if (temp_set_by_gcode && temp_by_gcode >= 0 && temp_by_gcode < 1000)
temp = temp_by_gcode;
// Always call m_writer.set_chamber_temperature() so it will set the internal "current" state of the chamber temp as if
// the custom start G-code emited these.
std::string set_temp_gcode = m_writer.set_chamber_temperature(temp, wait);
if (!temp_set_by_gcode && !set_temp_gcode.empty())
out += (set_temp_gcode);
}

// Write 1st layer extruder temperatures into the G-code.
// Only do that if the start G-code does not already contain any M-code controlling an extruder temperature.
// M104 - Set Extruder Temperature
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/GCode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ class GCode : ExtrusionVisitorConst {
std::string _after_extrude(const ExtrusionPath &path);
void print_machine_envelope(GCodeOutputStream &file, const Print &print);
void _print_first_layer_bed_temperature(std::string &out, const Print &print, const std::string &gcode, uint16_t first_printing_extruder_id, bool wait);
void _print_first_layer_chamber_temperature(std::string &out, const Print &print, const std::string &gcode, uint16_t first_printing_extruder_id, bool wait);
void _print_first_layer_extruder_temperatures(std::string &out, const Print &print, const std::string &gcode, uint16_t first_printing_extruder_id, bool wait);
// On the first printing layer. This flag triggers first layer speeds.
bool on_first_layer() const { return m_layer != nullptr && m_layer->id() == 0; }
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/GCode/WipeTower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ class WipeTowerWriter
assert(comment.empty() || comment[0] == ';' || (comment.size() > 1 && comment[0] == ' ' && comment[1] == ';'));
if (speed == m_last_fan_speed)
return *this;
if (speed == 0)
if (speed == 0 && (gcfTeacup != m_gcode_flavor && gcfRepRap != m_gcode_flavor))
m_gcode += "M107" + comment + "\n";
else
m_gcode += "M106 S" + std::to_string(unsigned(255.0 * speed / 100.0)) + comment + "\n";
Expand Down
29 changes: 28 additions & 1 deletion src/libslic3r/GCodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,34 @@ std::string GCodeWriter::set_bed_temperature(uint32_t temperature, bool wait)
return gcode.str();
}

std::string GCodeWriter::set_chamber_temperature(uint32_t temperature, bool wait)
{
if (temperature == m_last_chamber_temperature && !wait)
return std::string();

if (FLAVOR_IS(gcfMarlinFirmware) || FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfMachinekit)) {
// ok
} else {
return std::string();
}

m_last_chamber_temperature = temperature;

std::string code, comment;
if (wait) {
code = "M191";
comment = "set chamber temperature and wait for it to be reached";
} else {
code = "M141";
comment = "set chamber temperature";
}

std::ostringstream gcode;
gcode << code << " " << "S";
gcode << temperature << " ; " << comment << "\n";

return gcode.str();
}

void GCodeWriter::set_acceleration(uint32_t acceleration)
{
Expand Down Expand Up @@ -926,7 +953,7 @@ std::string GCodeWriter::set_fan(const GCodeFlavor gcode_flavor, bool gcode_comm

// write it
if (fan_speed == 0) {
if ((gcfTeacup == gcode_flavor)) {
if ((gcfTeacup == gcode_flavor || gcfRepRap == gcode_flavor)) {
gcode << "M106 S0";
} else if ((gcfMakerWare == gcode_flavor) || (gcfSailfish == gcode_flavor)) {
gcode << "M127";
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/GCodeWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class GCodeWriter {
std::string postamble() const;
std::string set_temperature(int16_t temperature, bool wait = false, int tool = -1);
std::string set_bed_temperature(uint32_t temperature, bool wait = false);
std::string set_chamber_temperature(uint32_t temperature, bool wait = false);
void set_acceleration(uint32_t acceleration);
void set_travel_acceleration(uint32_t acceleration);
uint32_t get_acceleration() const;
Expand Down Expand Up @@ -103,6 +104,7 @@ class GCodeWriter {
int16_t m_last_temperature_with_offset = 0;
int16_t m_last_bed_temperature = 0;
bool m_last_bed_temperature_reached = true;
int16_t m_last_chamber_temperature = 0;
// if positive, it's set, and the next lift wil have this extra lift
double m_extra_lift = 0;
// current lift, to remove from m_pos to have the current height.
Expand Down
19 changes: 19 additions & 0 deletions src/libslic3r/MultiPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,25 @@ bool MultiPoint::first_intersection(const Line& line, Point* intersection) const
}
}
}
/*last-to-first line */{
assert(!points.back().coincides_with_epsilon(points.front()));
l.a = points.back();
l.b = points.front();
Point ip;
if (l.intersection(line, &ip)) {
if (!found) {
found = true;
dmin = (line.a - ip).cast<double>().norm();
*intersection = ip;
} else {
double d = (line.a - ip).cast<double>().norm();
if (d < dmin) {
dmin = d;
*intersection = ip;
}
}
}
}
return found;
}

Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/MultiPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class MultiPoint
}

bool intersection(const Line& line, Point* intersection) const;
// if the line cross multiple times, it will return the poitn nearest from line.a
bool first_intersection(const Line& line, Point* intersection) const;
bool intersections(const Line &line, Points *intersections) const;
// Projection of a point onto the lines defined by the points.
Expand Down
14 changes: 9 additions & 5 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3339,11 +3339,14 @@ void PrintConfigDef::init_fff_params()
def = this->add("ironing_angle", coFloat);
def->label = L("Ironing angle");
def->category = OptionCategory::ironing;
def->tooltip = L("Ironing angle. if negative, it will use the fill angle.");
def->tooltip = L("Ironing post-process angle."
"\nIf positive, the ironing will use this angle."
"\nIf -1, it will use the fill angle."
"\nIf lower than -1, it will use the fill angle minus this angle.");
def->sidetext = L("°");
def->min = -1;
def->min = -360;
def->mode = comExpert | comSuSi;
def->set_default_value(new ConfigOptionFloat(-1));
def->set_default_value(new ConfigOptionFloat(-45));

def = this->add("ironing_type", coEnum);
def->label = L("Ironing Type");
Expand Down Expand Up @@ -5224,7 +5227,8 @@ void PrintConfigDef::init_fff_params()
def->label = L("Only custom Start G-code");
def->category = OptionCategory::customgcode;
def->tooltip = L("Ensure that the slicer won't add heating, fan, extruder... commands before or just after your start-gcode."
"If set to true, you have to write a good and complete start_gcode, as no checks are made anymore.");
"\nIf set to true, you have to write a good and complete start_gcode, as no checks are made anymore."
"\nExemple:\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\n{if use_relative_e_distances}M83{else}M82{endif}\nG92 E0 ; reset extrusion distance");
def->mode = comExpert | comPrusa;
def->set_default_value(new ConfigOptionBool(false));

Expand Down Expand Up @@ -6219,7 +6223,7 @@ void PrintConfigDef::init_fff_params()
def = this->add("wipe_only_crossing", coBools);
def->label = L("Wipe only when crossing perimeters");
def->category = OptionCategory::extruders;
def->tooltip = L("Don't wipe when you don't cross a perimeter. Need 'only_retract_when_crossing_perimeters'and 'wipe' enabled.");
def->tooltip = L("Don't wipe when you don't cross a perimeter. Need 'avoid_crossing_perimeters' and 'wipe' enabled.");
def->mode = comAdvancedE | comSuSi;
def->is_vector_extruder = true;
def->set_default_value(new ConfigOptionBools{ true });
Expand Down
17 changes: 15 additions & 2 deletions src/slic3r/GUI/CalibrationFlowDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,25 @@ void CalibrationFlowDialog::create_buttons(wxStdDialogButtonSizer* buttons){
buttons->Add(bt);
}

void CalibrationFlowDialog::create_geometry_10(wxCommandEvent &event_args)
{
Plater *plat = this->main_frame->plater();
if (!plat->new_project(L("Flow 10 percent calibration")))
return;
create_geometry(80.f, 10.f);
}

void CalibrationFlowDialog::create_geometry_2_5(wxCommandEvent &event_args)
{
Plater *plat = this->main_frame->plater();
if (!plat->new_project(L("Flow 2 percent calibration")))
return;
create_geometry(92.f, 2.F);
}

void CalibrationFlowDialog::create_geometry(float start, float delta) {
Plater* plat = this->main_frame->plater();
Model& model = plat->model();
if (!plat->new_project(L("Flow calibration")))
return;

//GLCanvas3D::set_warning_freeze(true);
bool autocenter = gui_app->app_config->get("autocenter") == "1";
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/CalibrationFlowDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class CalibrationFlowDialog : public CalibrationAbstractDialog
protected:
void create_buttons(wxStdDialogButtonSizer* sizer) override;
void create_geometry(float start, float delta);
void create_geometry_10(wxCommandEvent& event_args) { create_geometry(80.f, 10.f); }
void create_geometry_2_5(wxCommandEvent& event_args) { create_geometry(92.f, 2.F); }
void create_geometry_10(wxCommandEvent& event_args);
void create_geometry_2_5(wxCommandEvent& event_args);

};

Expand Down
12 changes: 8 additions & 4 deletions src/slic3r/GUI/CalibrationOverBridgeDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,29 @@ namespace Slic3r {
namespace GUI {

void CalibrationOverBridgeDialog::create_buttons(wxStdDialogButtonSizer* buttons){
wxButton* bt1 = new wxButton(this, wxID_FILE1, _L("Over-Bridge calibration"));
wxButton* bt2 = new wxButton(this, wxID_FILE1, _L("Top flow calibration"));
wxButton* bt1 = new wxButton(this, wxID_FILE1, _L("'Above the Bridges' flow calibration"));
wxButton* bt2 = new wxButton(this, wxID_FILE1, _L("'Top Fill' flow calibration"));
bt1->Bind(wxEVT_BUTTON, &CalibrationOverBridgeDialog::create_geometry1, this);
bt2->Bind(wxEVT_BUTTON, &CalibrationOverBridgeDialog::create_geometry2, this);
buttons->Add(bt1);
buttons->Add(bt2);
}

void CalibrationOverBridgeDialog::create_geometry1(wxCommandEvent& event_args) {
Plater* plat = this->main_frame->plater();
if (!plat->new_project(L("'Above the Bridges flow calibration")))
return;
create_geometry(true);
}
void CalibrationOverBridgeDialog::create_geometry2(wxCommandEvent& event_args) {
Plater* plat = this->main_frame->plater();
if (!plat->new_project(L("Top Fill flow calibration")))
return;
create_geometry(false);
}
void CalibrationOverBridgeDialog::create_geometry(bool over_bridge) {
Plater* plat = this->main_frame->plater();
Model& model = plat->model();
if (!plat->new_project(L("Over-bridge calibration")))
return;

//GLCanvas3D::set_warning_freeze(true);
bool autocenter = gui_app->app_config->get("autocenter") == "1";
Expand Down
8 changes: 5 additions & 3 deletions src/slic3r/GUI/GLCanvas3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2264,10 +2264,12 @@ bool GLCanvas3D::is_gcode_preview_dirty(const GCodeProcessorResult& gcode_result
return last_showned_gcode != gcode_result.computed_timestamp;
}

void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)
void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult &gcode_result,
const std::vector<std::string> &str_tool_colors,
bool force_gcode_color_recompute)
{
if (last_showned_gcode != gcode_result.computed_timestamp
|| !m_gcode_viewer.is_loaded(gcode_result)) {
if (last_showned_gcode != gcode_result.computed_timestamp || force_gcode_color_recompute ||
!m_gcode_viewer.is_loaded(gcode_result)) {
last_showned_gcode = gcode_result.computed_timestamp;
m_gcode_viewer.load(gcode_result, *this->fff_print(), m_initialized);

Expand Down
Loading

0 comments on commit 5c8cc63

Please sign in to comment.