From a42bf8602fb09da1dbceeaf08c93377d2648a86c Mon Sep 17 00:00:00 2001 From: supermerill Date: Thu, 20 Aug 2020 12:17:50 +0200 Subject: [PATCH] Create sprinter firmware option to decouple it from reprap, because of the changes in reprap-firmware. also add g10 to temperature detection --- src/libslic3r/GCode.cpp | 14 +++++++------- src/libslic3r/GCode/Analyzer.cpp | 10 +++++++++- src/libslic3r/GCode/WipeTower.cpp | 4 ++-- src/libslic3r/GCodeTimeEstimator.cpp | 7 ++++--- src/libslic3r/GCodeWriter.cpp | 4 ++-- src/libslic3r/Print.cpp | 2 +- src/libslic3r/PrintConfig.cpp | 5 ++++- src/libslic3r/PrintConfig.hpp | 3 ++- 8 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index ad5b9d31f..85dfe5f91 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -527,7 +527,7 @@ std::string WipeTowerIntegration::prime(GCode &gcodegen) // Disable linear advance for the wipe tower operations. - //gcode += (gcodegen.config().gcode_flavor == gcfRepRap ? std::string("M572 D0 S0\n") : std::string("M900 K0\n")); + //gcode += (gcodegen.config().gcode_flavor == gcfRepRap || m_gcode_flavor == gcfSprinter ? std::string("M572 D0 S0\n") : std::string("M900 K0\n")); for (const WipeTower::ToolChangeResult& tcr : m_priming) { if (!tcr.extrusions.empty()) @@ -1774,10 +1774,10 @@ static bool custom_gcode_sets_temperature(const std::string &gcode, const int mc // Do not process this piece of G-code by the time estimator, it already knows the values through another sources. void GCode::print_machine_envelope(FILE *file, Print &print) { - // gcfRepRap, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlin, gcfKlipper, gcfSailfish, gcfMach3, gcfMachinekit, + // gcfRepRap, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlin, gcfKlipper, gcfSailfish, gcfSprinter, gcfMach3, gcfMachinekit, /// gcfSmoothie, gcfNoExtrusion, gcfLerdge, if (print.config().print_machine_envelope) { - if (std::set{gcfMarlin, gcfLerdge, gcfRepetier, gcfRepRap}.count(print.config().gcode_flavor.value) > 0) + if (std::set{gcfMarlin, gcfLerdge, gcfRepetier, gcfRepRap, gcfSprinter}.count(print.config().gcode_flavor.value) > 0) fprintf(file, "M201 X%d Y%d Z%d E%d ; sets maximum accelerations, mm/sec^2\n", int(print.config().machine_max_acceleration_x.values.front() + 0.5), int(print.config().machine_max_acceleration_y.values.front() + 0.5), @@ -1787,7 +1787,7 @@ void GCode::print_machine_envelope(FILE *file, Print &print) fprintf(file, "M202 X%d Y%d ; sets maximum travel speed\n", int(print.config().travel_speed.value), int(print.config().travel_speed.value)); - if (std::set{gcfMarlin, gcfLerdge, gcfRepetier, gcfRepRap, gcfSmoothie}.count(print.config().gcode_flavor.value) > 0) + if (std::set{gcfMarlin, gcfLerdge, gcfRepetier, gcfRepRap, gcfSmoothie, gcfSprinter}.count(print.config().gcode_flavor.value) > 0) fprintf(file, "M203 X%d Y%d Z%d E%d ; sets maximum feedrates, mm/sec\n", int(print.config().machine_max_feedrate_x.values.front() + 0.5), int(print.config().machine_max_feedrate_y.values.front() + 0.5), @@ -1798,7 +1798,7 @@ void GCode::print_machine_envelope(FILE *file, Print &print) int(print.config().machine_max_acceleration_extruding.values.front() + 0.5), int(print.config().machine_max_acceleration_retracting.values.front() + 0.5), int(print.config().machine_max_acceleration_travel.values.front() + 0.5)); - if (std::set{gcfRepRap, gcfKlipper}.count(print.config().gcode_flavor.value) > 0) + if (std::set{gcfRepRap, gcfKlipper, gcfSprinter}.count(print.config().gcode_flavor.value) > 0) fprintf(file, "M204 P%d T%d ; sets acceleration (P, T), mm/sec^2\n", int(print.config().machine_max_acceleration_extruding.values.front() + 0.5), int(print.config().machine_max_acceleration_travel.values.front() + 0.5)); @@ -1828,8 +1828,8 @@ void GCode::print_machine_envelope(FILE *file, Print &print) // Write 1st layer bed temperatures into the G-code. // Only do that if the start G-code does not already contain any M-code controlling an extruder temperature. -// M140 - Set Extruder Temperature -// M190 - Set Extruder Temperature and Wait +// M140 - Set Bed Temperature +// M190 - Set Bed Temperature and Wait void GCode::_print_first_layer_bed_temperature(FILE *file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait) { // Initial bed temperature based on the first extruder. diff --git a/src/libslic3r/GCode/Analyzer.cpp b/src/libslic3r/GCode/Analyzer.cpp index f16cb5617..c3cd16eee 100644 --- a/src/libslic3r/GCode/Analyzer.cpp +++ b/src/libslic3r/GCode/Analyzer.cpp @@ -421,8 +421,16 @@ void GCodeAnalyzer::_processG1(const GCodeReader::GCodeLine& line) void GCodeAnalyzer::_processG10(const GCodeReader::GCodeLine& line) { + //special case for reprap (temp done, TODO: offsets) + float new_temp; + if (m_gcode_flavor == gcfRepRap && line.has_value('S', new_temp)) + { + _set_extruder_temp(new_temp); + } // stores retract move - _store_move(GCodeMove::Retract); + else { + _store_move(GCodeMove::Retract); + } } void GCodeAnalyzer::_processG11(const GCodeReader::GCodeLine& line) diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index c3c05f172..70a2b677d 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -103,7 +103,7 @@ public: } WipeTowerWriter& disable_linear_advance() { - if(m_gcode_flavor == gcfRepRap) + if(m_gcode_flavor == gcfRepRap || m_gcode_flavor == gcfSprinter) m_gcode += std::string("M572 D0 S0\n"); else if(m_gcode_flavor == gcfKlipper) m_gcode += std::string("SET_PRESSURE_ADVANCE ADVANCE=0\n"); @@ -407,7 +407,7 @@ public: { if (m_gcode_flavor == gcfKlipper) return *this; - if (m_gcode_flavor == gcfRepRap) + if (m_gcode_flavor == gcfRepRap || m_gcode_flavor == gcfSprinter) m_gcode += "M906 E"; else m_gcode += "M907 E"; diff --git a/src/libslic3r/GCodeTimeEstimator.cpp b/src/libslic3r/GCodeTimeEstimator.cpp index 55cb078a7..229441b6c 100644 --- a/src/libslic3r/GCodeTimeEstimator.cpp +++ b/src/libslic3r/GCodeTimeEstimator.cpp @@ -687,7 +687,7 @@ namespace Slic3r { void GCodeTimeEstimator::set_default() { set_units(Millimeters); - set_dialect(gcfRepRap); + set_dialect(gcfSprinter); set_global_positioning_type(Absolute); set_e_local_positioning_type(Absolute); @@ -1261,7 +1261,8 @@ namespace Slic3r { (dialect == gcfKlipper) || (dialect == gcfSmoothie) || (dialect == gcfLerdge) || - (dialect == gcfRepRap)) + (dialect == gcfRepRap)|| + (dialect == gcfSprinter)) { if (line.has_value('S', value)) add_additional_time(value); @@ -1373,7 +1374,7 @@ namespace Slic3r { GCodeFlavor dialect = get_dialect(); // see http://reprap.org/wiki/G-code#M201:_Set_max_printing_acceleration - float factor = ((dialect != gcfRepRap) && (get_units() == GCodeTimeEstimator::Inches)) ? INCHES_TO_MM : 1.0f; + float factor = ((dialect != gcfRepRap) && (dialect != gcfSprinter) && (get_units() == GCodeTimeEstimator::Inches)) ? INCHES_TO_MM : 1.0f; if (line.has_x()) set_axis_max_acceleration(X, line.x() * factor); diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index c0fb67559..1ac899f77 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -62,7 +62,7 @@ std::string GCodeWriter::preamble() gcode << "G90 ; use absolute coordinates\n"; } if (FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfMarlin) || FLAVOR_IS(gcfLerdge) || FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepetier) || FLAVOR_IS(gcfSmoothie) - || FLAVOR_IS(gcfKlipper) || FLAVOR_IS(gcfLerdge)) { + || FLAVOR_IS(gcfSprinter) || FLAVOR_IS(gcfKlipper) || FLAVOR_IS(gcfLerdge)) { if (this->config.use_relative_e_distances) { gcode << "M83 ; use relative distances for extrusion\n"; } else { @@ -88,7 +88,7 @@ std::string GCodeWriter::set_temperature(unsigned int temperature, bool wait, in return ""; std::string code, comment; - if (wait && FLAVOR_IS_NOT(gcfTeacup) && FLAVOR_IS_NOT(gcfRepRap)) { + if (wait && FLAVOR_IS_NOT(gcfTeacup) && FLAVOR_IS_NOT(gcfRepRap) && FLAVOR_IS_NOT(gcfSprinter)) { code = "M109"; comment = "set temperature and wait for it to be reached"; } else { diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 0547e2327..509419db6 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1336,7 +1336,7 @@ std::pair Print::validate() const "and use filaments of the same diameter.") }; } - if (m_config.gcode_flavor != gcfRepRap && m_config.gcode_flavor != gcfRepetier && m_config.gcode_flavor != gcfMarlin + if (m_config.gcode_flavor != gcfRepRap && m_config.gcode_flavor != gcfSprinter && m_config.gcode_flavor != gcfRepetier && m_config.gcode_flavor != gcfMarlin && m_config.gcode_flavor != gcfKlipper) return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is currently only supported for the Marlin, RepRap/Sprinter and Repetier G-code flavors.") }; if (! m_config.use_relative_e_distances) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index b784ff09b..8e46a0804 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1642,9 +1642,10 @@ void PrintConfigDef::init_fff_params() def->enum_values.push_back("mach3"); def->enum_values.push_back("machinekit"); def->enum_values.push_back("smoothie"); + def->enum_values.push_back("sprinter"); def->enum_values.push_back("lerdge"); def->enum_values.push_back("no-extrusion"); - def->enum_labels.push_back("RepRap/Sprinter"); + def->enum_labels.push_back("RepRap"); def->enum_labels.push_back("Repetier"); def->enum_labels.push_back("Teacup"); def->enum_labels.push_back("MakerWare (MakerBot)"); @@ -1654,6 +1655,7 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back("Mach3/LinuxCNC"); def->enum_labels.push_back("Machinekit"); def->enum_labels.push_back("Smoothie"); + def->enum_labels.push_back("Sprinter"); def->enum_labels.push_back("Lerdge"); def->enum_labels.push_back(L("No extrusion")); def->mode = comAdvanced; @@ -4716,6 +4718,7 @@ std::string FullPrintConfig::validate() if (this->use_firmware_retraction.value && this->gcode_flavor.value != gcfSmoothie && + this->gcode_flavor.value != gcfSprinter && this->gcode_flavor.value != gcfRepRap && this->gcode_flavor.value != gcfMarlin && this->gcode_flavor.value != gcfMachinekit && diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 8639bb68d..698b3d3d0 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -49,7 +49,7 @@ enum WipeAlgo { enum GCodeFlavor : uint8_t { gcfRepRap, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlin, gcfKlipper, gcfSailfish, gcfMach3, gcfMachinekit, - gcfSmoothie, gcfNoExtrusion, gcfLerdge, + gcfSmoothie, gcfSprinter, gcfNoExtrusion, gcfLerdge, }; enum PrintHostType { @@ -142,6 +142,7 @@ template<> inline const t_config_enum_values& ConfigOptionEnum::get keys_map["klipper"] = gcfKlipper; keys_map["sailfish"] = gcfSailfish; keys_map["smoothie"] = gcfSmoothie; + keys_map["sprinter"] = gcfSprinter; keys_map["mach3"] = gcfMach3; keys_map["machinekit"] = gcfMachinekit; keys_map["no-extrusion"] = gcfNoExtrusion;