mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-12 21:19:03 +08:00
updates for reprap extruder heating
wipe tower code is a mess that don't use gcodewriter, so it's a bit complicated, on this side. May need more work
This commit is contained in:
parent
7e1d236890
commit
15385c45ee
@ -1188,6 +1188,51 @@ std::vector<const PrintInstance*> sort_object_instances_by_model_order(const Pri
|
||||
return instances;
|
||||
}
|
||||
|
||||
// set standby temp for extruders
|
||||
// Parse the custom G-code, try to find T, and add it if not present
|
||||
static void init_multiextruders(FILE *file, Print &print, GCodeWriter & writer, ToolOrdering &tool_ordering, const std::string &custom_gcode )
|
||||
{
|
||||
|
||||
//set standby temp for reprap
|
||||
if (std::set<uint8_t>{gcfRepRap}.count(print.config().gcode_flavor.value) > 0) {
|
||||
for (uint16_t tool_id : tool_ordering.all_extruders()) {
|
||||
fprintf(file, "G10 P%d R%d S%d ; sets the standby temperature\n",
|
||||
tool_id,
|
||||
int(print.config().filament_toolchange_temp.get_at(tool_id)),
|
||||
int(print.config().temperature.get_at(tool_id)));
|
||||
}
|
||||
}
|
||||
//activate first extruder is multi-extruder and not in start-gcode
|
||||
if (writer.multiple_extruders) {
|
||||
if (std::set<uint8_t>{gcfRepRap}.count(print.config().gcode_flavor.value) > 0) {
|
||||
//if not in gcode
|
||||
bool find = false;
|
||||
if (!custom_gcode.empty()) {
|
||||
const char *ptr = custom_gcode.data();
|
||||
while (*ptr != 0) {
|
||||
// Skip whitespaces.
|
||||
for (; *ptr == ' ' || *ptr == '\t'; ++ptr);
|
||||
if (*ptr == 'T') {
|
||||
find = true;
|
||||
break;
|
||||
} else if (*ptr == 'A') {
|
||||
//TODO: ACTIVATE_EXTRUDER for klipper (if used)
|
||||
}
|
||||
// Skip the rest of the line.
|
||||
for (; *ptr != 0 && *ptr != '\r' && *ptr != '\n'; ++ptr);
|
||||
// Skip the end of line indicators.
|
||||
for (; *ptr == '\r' || *ptr == '\n'; ++ptr);
|
||||
}
|
||||
}
|
||||
if (!find) {
|
||||
fprintf(file, writer.toolchange(tool_ordering.first_extruder()).c_str());
|
||||
}
|
||||
}
|
||||
writer.toolchange(tool_ordering.first_extruder());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thumbnail_cb)
|
||||
#else
|
||||
@ -1431,6 +1476,10 @@ void GCode::_do_export(Print &print, FILE *file)
|
||||
std::string start_gcode = this->placeholder_parser_process("start_gcode", print.config().start_gcode.value, initial_extruder_id);
|
||||
// Set bed temperature if the start G-code does not contain any bed temp control G-codes.
|
||||
this->_print_first_layer_bed_temperature(file, print, start_gcode, initial_extruder_id, true);
|
||||
|
||||
//init extruders
|
||||
init_multiextruders(file, print, m_writer, tool_ordering, start_gcode);
|
||||
|
||||
// Set extruder(s) temperature before and after start G-code.
|
||||
this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, false);
|
||||
|
||||
|
@ -330,12 +330,13 @@ public:
|
||||
//add toolchange_temp -skinnydip
|
||||
WipeTowerWriter& wait_for_toolchange_temp(int tc_temp, bool fan_on, int fan_speed, bool fast)
|
||||
{
|
||||
char all[128];
|
||||
//char all[128];
|
||||
if (fan_on == true){
|
||||
set_fan(fan_speed, " ;Part fan on to cool hotend");
|
||||
}
|
||||
sprintf(all, "M109 S%d ;SKINNYDIP TOOLCHANGE WAIT FOR TEMP %s\n", tc_temp, fast ? "FAST MODE":"NORMAL MODE");
|
||||
this->append(all);
|
||||
//sprintf(all, "M109 S%d ;SKINNYDIP TOOLCHANGE WAIT FOR TEMP %s\n", tc_temp, fast ? "FAST MODE":"NORMAL MODE");
|
||||
//this->append(all);
|
||||
set_extruder_temp(tc_temp, this->m_current_tool, true, ";SKINNYDIP TOOLCHANGE WAIT FOR TEMP " + fast ? "FAST MODE" : "NORMAL MODE");
|
||||
if (fan_on == true){
|
||||
set_fan(m_last_fan_speed, " ;restore cooling");
|
||||
}
|
||||
@ -345,25 +346,65 @@ public:
|
||||
//begin toolchange_temp -skinnydip
|
||||
WipeTowerWriter& begin_toolchange_temp(int tc_temp, bool fast)
|
||||
{
|
||||
char tdbuf[128];
|
||||
sprintf(tdbuf, "M104 S%d ;SKINNYDIP BEGIN TOOLCHANGE TEMP %s\n", tc_temp, fast ? "FAST MODE":"NORMAL MODE");
|
||||
m_gcode += tdbuf;
|
||||
return *this;
|
||||
//char tdbuf[128];
|
||||
//sprintf(tdbuf, "M104 S%d ;SKINNYDIP BEGIN TOOLCHANGE TEMP %s\n", tc_temp, fast ? "FAST MODE":"NORMAL MODE");
|
||||
//m_gcode += tdbuf;
|
||||
set_extruder_temp(tc_temp, this->m_current_tool, false, ";SKINNYDIP BEGIN TOOLCHANGE TEMP " + fast ? "FAST MODE" : "NORMAL MODE");
|
||||
return *this;
|
||||
}
|
||||
|
||||
//restore toolchange_temp -skinnydip
|
||||
WipeTowerWriter& restore_pre_toolchange_temp(int tc_temp, bool fast)
|
||||
{
|
||||
char tdbuf[128];
|
||||
sprintf(tdbuf, "M104 S%d ;RESTORE PRE-TOOLCHANGE TEMP %s\n", tc_temp, fast ? "FAST MODE":"NORMAL MODE");
|
||||
m_gcode += tdbuf;
|
||||
return *this;
|
||||
//char tdbuf[128];
|
||||
//sprintf(tdbuf, "M104 S%d ;RESTORE PRE-TOOLCHANGE TEMP %s\n", tc_temp, fast ? "FAST MODE":"NORMAL MODE");
|
||||
//m_gcode += tdbuf;
|
||||
set_extruder_temp(tc_temp, this->m_current_tool , false, ";RESTORE PRE-TOOLCHANGE TEMP " + fast ? "FAST MODE" : "NORMAL MODE");
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Set extruder temperature, don't wait by default.
|
||||
WipeTowerWriter& set_extruder_temp(int temperature, bool wait = false)
|
||||
{
|
||||
m_gcode += "M" + std::to_string(wait ? 109 : 104) + " S" + std::to_string(temperature) + "\n";
|
||||
WipeTowerWriter& set_extruder_temp(unsigned int temperature, size_t tool, bool wait = false, std::string comment = "")
|
||||
{
|
||||
if (wait && (this->m_gcode_flavor == gcfMakerWare || this->m_gcode_flavor == (gcfSailfish)))
|
||||
return *this;
|
||||
|
||||
std::string code;
|
||||
if (wait && this->m_gcode_flavor != (gcfTeacup) && this->m_gcode_flavor != (gcfRepRap) && this->m_gcode_flavor != (gcfSprinter)) {
|
||||
code = "M109";
|
||||
} else {
|
||||
if (this->m_gcode_flavor == (gcfRepRap)) { // M104 is deprecated on RepRapFirmware
|
||||
code = "G10";
|
||||
} else {
|
||||
code = "M104";
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream gcode;
|
||||
gcode << code << " ";
|
||||
if (this->m_gcode_flavor == (gcfMach3) || this->m_gcode_flavor == (gcfMachinekit)) {
|
||||
gcode << "P";
|
||||
} else if (this->m_gcode_flavor == (gcfRepRap)) {
|
||||
gcode << "P" << tool << " S";
|
||||
} else {
|
||||
gcode << "S";
|
||||
}
|
||||
gcode << temperature;
|
||||
bool multiple_tools = false; // ?
|
||||
if (this->m_current_tool != -1 && (multiple_tools || this->m_gcode_flavor == (gcfMakerWare) || this->m_gcode_flavor == (gcfSailfish))) {
|
||||
if (this->m_gcode_flavor != (gcfRepRap)) {
|
||||
gcode << " T" << tool;
|
||||
}
|
||||
}
|
||||
|
||||
if(!comment.empty())
|
||||
gcode << " ; " << comment << "\n";
|
||||
|
||||
if ((this->m_gcode_flavor == (gcfTeacup) || this->m_gcode_flavor == (gcfRepRap)) && wait)
|
||||
gcode << "M116 ; wait for temperature to be reached\n";
|
||||
|
||||
gcode << "\n";
|
||||
m_gcode += gcode.str();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -685,7 +726,7 @@ std::vector<WipeTower::ToolChangeResult> WipeTower::prime(
|
||||
toolchange_Wipe(writer, cleaning_box , 20.f);
|
||||
box_coordinates box = cleaning_box;
|
||||
box.translate(0.f, writer.y() - cleaning_box.ld.y() + m_perimeter_width);
|
||||
toolchange_Unload(writer, box , m_filpar[m_current_tool].material, m_filpar[tools[idx_tool + 1]].first_layer_temperature);
|
||||
toolchange_Unload(writer, box , m_filpar[m_current_tool].material, m_filpar[tools[idx_tool + 1]].first_layer_temperature, idx_tool + 1);
|
||||
cleaning_box.translate(prime_section_width, 0.f);
|
||||
writer.travel(cleaning_box.ld, 7200);
|
||||
}
|
||||
@ -793,14 +834,14 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool, bool last_in_lay
|
||||
// Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool.
|
||||
if (tool != (unsigned int)-1){ // This is not the last change.
|
||||
toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material,
|
||||
m_is_first_layer ? m_filpar[tool].first_layer_temperature : m_filpar[tool].temperature);
|
||||
m_is_first_layer ? m_filpar[tool].first_layer_temperature : m_filpar[tool].temperature, tool);
|
||||
toolchange_Change(writer, tool, m_filpar[tool].material); // Change the tool, set a speed override for soluble and flex materials.
|
||||
toolchange_Load(writer, cleaning_box);
|
||||
writer.travel(writer.x(), writer.y()-m_perimeter_width); // cooling and loading were done a bit down the road
|
||||
toolchange_Wipe(writer, cleaning_box, wipe_volume); // Wipe the newly loaded filament until the end of the assigned wipe area.
|
||||
++ m_num_tool_changes;
|
||||
} else
|
||||
toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, m_filpar[m_current_tool].temperature);
|
||||
toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, m_filpar[m_current_tool].temperature, m_current_tool);
|
||||
|
||||
m_depth_traversed += wipe_area;
|
||||
|
||||
@ -912,7 +953,8 @@ void WipeTower::toolchange_Unload(
|
||||
WipeTowerWriter &writer,
|
||||
const box_coordinates &cleaning_box,
|
||||
const std::string& current_material,
|
||||
const int new_temperature)
|
||||
const int new_temperature,
|
||||
const size_t next_tool)
|
||||
{
|
||||
float xl = cleaning_box.ld.x() + 1.f * m_perimeter_width;
|
||||
float xr = cleaning_box.rd.x() - 1.f * m_perimeter_width;
|
||||
@ -1039,7 +1081,7 @@ void WipeTower::toolchange_Unload(
|
||||
if (new_temperature != 0 && (new_temperature != m_old_temperature || m_is_first_layer)) { // Set the extruder temperature, but don't wait.
|
||||
// If the required temperature is the same as last time, don't emit the M104 again (if user adjusted the value, it would be reset)
|
||||
// However, always change temperatures on the first layer (this is to avoid issues with priming lines turned off).
|
||||
writer.set_extruder_temp(new_temperature, false);
|
||||
writer.set_extruder_temp(new_temperature, next_tool, false);
|
||||
m_old_temperature = new_temperature;
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +367,8 @@ private:
|
||||
WipeTowerWriter &writer,
|
||||
const box_coordinates &cleaning_box,
|
||||
const std::string& current_material,
|
||||
const int new_temperature);
|
||||
const int new_temperature,
|
||||
const size_t temp_tool);
|
||||
|
||||
void toolchange_Change(
|
||||
WipeTowerWriter &writer,
|
||||
|
@ -104,15 +104,15 @@ std::string GCodeWriter::set_temperature(unsigned int temperature, bool wait, in
|
||||
gcode << code << " ";
|
||||
if (FLAVOR_IS(gcfMach3) || FLAVOR_IS(gcfMachinekit)) {
|
||||
gcode << "P";
|
||||
} else if (FLAVOR_IS(gcfRepRap)) {
|
||||
gcode << "P" << tool << " S";
|
||||
} else {
|
||||
gcode << "S";
|
||||
}
|
||||
gcode << temperature;
|
||||
bool multiple_tools = this->multiple_extruders && ! m_single_extruder_multi_material;
|
||||
if (tool != -1 && (multiple_tools || FLAVOR_IS(gcfMakerWare) || FLAVOR_IS(gcfSailfish)) ) {
|
||||
if (FLAVOR_IS(gcfRepRap)) {
|
||||
gcode << " P" << tool;
|
||||
} else {
|
||||
if (FLAVOR_IS_NOT(gcfRepRap)) {
|
||||
gcode << " T" << tool;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user