From f6d25d0634c0c40855aafce02bad4c3de734eea2 Mon Sep 17 00:00:00 2001 From: Paul Arden Date: Fri, 21 Aug 2020 14:07:50 +1000 Subject: [PATCH] Rework G10 temperature support to be enabled only for a new Firmware type `RepRapFirmware` leaving the `RepRap/Sprinter` behaviour alone. Rename the enum for `gcfRepRap` to `gcfRepRapSprinter` and add new `gcfRepRapFirmware` enum value. Also adds code to only use the G10 searching in custom G-code if the flavour is RepRapFirmware. --- src/libslic3r/GCode.cpp | 5 +++-- src/libslic3r/GCode/WipeTower.cpp | 4 ++-- src/libslic3r/GCodeTimeEstimator.cpp | 7 ++++--- src/libslic3r/GCodeWriter.cpp | 16 +++++++++++----- src/libslic3r/Print.cpp | 5 +++-- src/libslic3r/PrintConfig.cpp | 9 ++++++--- src/libslic3r/PrintConfig.hpp | 5 +++-- 7 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 975e15c6c..f863fd3ee 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -500,7 +500,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 == gcfRepRapSprinter ? std::string("M572 D0 S0\n") : std::string("M900 K0\n")); for (const WipeTower::ToolChangeResult& tcr : m_priming) { if (!tcr.extrusions.empty()) @@ -1720,7 +1720,8 @@ void GCode::_print_first_layer_extruder_temperatures(FILE *file, Print &print, c { // Is the bed temperature set by the provided custom G-code? int temp_by_gcode = -1; - if (custom_gcode_sets_temperature(gcode, 104, 109, true, temp_by_gcode)) { + bool include_g10 = (print.config().gcode_flavor == gcfRepRapFirmware); + if (custom_gcode_sets_temperature(gcode, 104, 109, include_g10, temp_by_gcode)) { // Set the extruder temperature at m_writer, but throw away the generated G-code as it will be written with the custom G-code. int temp = print.config().first_layer_temperature.get_at(first_printing_extruder_id); if (temp_by_gcode >= 0 && temp_by_gcode < 1000) diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index c0f778687..b2534361f 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -102,7 +102,7 @@ public: } WipeTowerWriter& disable_linear_advance() { - m_gcode += (m_gcode_flavor == gcfRepRap + m_gcode += (m_gcode_flavor == gcfRepRapSprinter || m_gcode_flavor == gcfRepRapFirmware ? (std::string("M572 D") + std::to_string(m_current_tool) + " S0\n") : std::string("M900 K0\n")); return *this; @@ -351,7 +351,7 @@ public: // Set digital trimpot motor WipeTowerWriter& set_extruder_trimpot(int current) { - if (m_gcode_flavor == gcfRepRap) + if (m_gcode_flavor == gcfRepRapSprinter || m_gcode_flavor == gcfRepRapFirmware) m_gcode += "M906 E"; else m_gcode += "M907 E"; diff --git a/src/libslic3r/GCodeTimeEstimator.cpp b/src/libslic3r/GCodeTimeEstimator.cpp index 9e8137ef0..795fecbeb 100644 --- a/src/libslic3r/GCodeTimeEstimator.cpp +++ b/src/libslic3r/GCodeTimeEstimator.cpp @@ -622,7 +622,7 @@ namespace Slic3r { void GCodeTimeEstimator::set_default() { set_units(Millimeters); - set_dialect(gcfRepRap); + set_dialect(gcfRepRapSprinter); set_global_positioning_type(Absolute); set_e_local_positioning_type(Absolute); @@ -1201,7 +1201,8 @@ namespace Slic3r { if ((dialect == gcfRepetier) || (dialect == gcfMarlin) || (dialect == gcfSmoothie) || - (dialect == gcfRepRap)) + (dialect == gcfRepRapSprinter) || + (dialect == gcfRepRapFirmware)) { if (line.has_value('S', value)) extra_time += value; @@ -1313,7 +1314,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 != gcfRepRapSprinter && dialect != gcfRepRapFirmware) && (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 98a6ed4a4..569ae65e5 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -46,7 +46,13 @@ std::string GCodeWriter::preamble() gcode << "G21 ; set units to millimeters\n"; gcode << "G90 ; use absolute coordinates\n"; } - if (FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfMarlin) || FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepetier) || FLAVOR_IS(gcfSmoothie)) { + if (FLAVOR_IS(gcfRepRapSprinter) || + FLAVOR_IS(gcfRepRapFirmware) || + FLAVOR_IS(gcfMarlin) || + FLAVOR_IS(gcfTeacup) || + FLAVOR_IS(gcfRepetier) || + FLAVOR_IS(gcfSmoothie)) + { if (this->config.use_relative_e_distances) { gcode << "M83 ; use relative distances for extrusion\n"; } else { @@ -72,11 +78,11 @@ 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(gcfRepRapFirmware)) { code = "M109"; comment = "set temperature and wait for it to be reached"; } else { - if (FLAVOR_IS(gcfRepRap)) { // M104 is deprecated on RepRapFirmware + if (FLAVOR_IS(gcfRepRapFirmware)) { // M104 is deprecated on RepRapFirmware code = "G10"; } else { code = "M104"; @@ -94,7 +100,7 @@ std::string GCodeWriter::set_temperature(unsigned int temperature, bool wait, in 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)) { + if (FLAVOR_IS(gcfRepRapFirmware)) { gcode << " P" << tool; } else { gcode << " T" << tool; @@ -102,7 +108,7 @@ std::string GCodeWriter::set_temperature(unsigned int temperature, bool wait, in } gcode << " ; " << comment << "\n"; - if ((FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepRap)) && wait) + if ((FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepRapFirmware)) && wait) gcode << "M116 ; wait for temperature to be reached\n"; return gcode.str(); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 0c8a11fcf..878380955 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1259,8 +1259,9 @@ std::string 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) - return L("The Wipe Tower is currently only supported for the Marlin, RepRap/Sprinter and Repetier G-code flavors."); + if (m_config.gcode_flavor != gcfRepRapSprinter && m_config.gcode_flavor != gcfRepRapFirmware && + m_config.gcode_flavor != gcfRepetier && m_config.gcode_flavor != gcfMarlin) + return L("The Wipe Tower is currently only supported for the Marlin, RepRap/Sprinter, RepRapFirmware and Repetier G-code flavors."); if (! m_config.use_relative_e_distances) return L("The Wipe Tower is currently only supported with the relative extruder addressing (use_relative_e_distances=1)."); if (m_config.ooze_prevention) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index d6a23d75d..0d7ddeecd 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -953,6 +953,7 @@ void PrintConfigDef::init_fff_params() "The \"No extrusion\" flavor prevents PrusaSlicer from exporting any extrusion value at all."); def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); def->enum_values.push_back("reprap"); + def->enum_values.push_back("reprapfirmware"); def->enum_values.push_back("repetier"); def->enum_values.push_back("teacup"); def->enum_values.push_back("makerware"); @@ -963,6 +964,7 @@ void PrintConfigDef::init_fff_params() def->enum_values.push_back("smoothie"); def->enum_values.push_back("no-extrusion"); def->enum_labels.push_back("RepRap/Sprinter"); + def->enum_labels.push_back("RepRapFirmware"); def->enum_labels.push_back("Repetier"); def->enum_labels.push_back("Teacup"); def->enum_labels.push_back("MakerWare (MakerBot)"); @@ -973,7 +975,7 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back("Smoothie"); def->enum_labels.push_back(L("No extrusion")); def->mode = comExpert; - def->set_default_value(new ConfigOptionEnum(gcfRepRap)); + def->set_default_value(new ConfigOptionEnum(gcfRepRapSprinter)); def = this->add("gcode_label_objects", coBool); def->label = L("Label objects"); @@ -3290,11 +3292,12 @@ std::string FullPrintConfig::validate() if (this->use_firmware_retraction.value && this->gcode_flavor.value != gcfSmoothie && - this->gcode_flavor.value != gcfRepRap && + this->gcode_flavor.value != gcfRepRapSprinter && + this->gcode_flavor.value != gcfRepRapFirmware && this->gcode_flavor.value != gcfMarlin && this->gcode_flavor.value != gcfMachinekit && this->gcode_flavor.value != gcfRepetier) - return "--use-firmware-retraction is only supported by Marlin, Smoothie, Repetier and Machinekit firmware"; + return "--use-firmware-retraction is only supported by Marlin, Smoothie, RepRapFirmware, Repetier and Machinekit firmware"; if (this->use_firmware_retraction.value) for (unsigned char wipe : this->wipe.values) diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index f28ef2a22..0ab51718b 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -25,7 +25,7 @@ namespace Slic3r { enum GCodeFlavor : unsigned char { - gcfRepRap, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlin, gcfSailfish, gcfMach3, gcfMachinekit, + gcfRepRapSprinter, gcfRepRapFirmware, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlin, gcfSailfish, gcfMach3, gcfMachinekit, gcfSmoothie, gcfNoExtrusion, }; @@ -84,7 +84,8 @@ template<> inline const t_config_enum_values& ConfigOptionEnum inline const t_config_enum_values& ConfigOptionEnum::get_enum_values() { static t_config_enum_values keys_map; if (keys_map.empty()) { - keys_map["reprap"] = gcfRepRap; + keys_map["reprap"] = gcfRepRapSprinter; + keys_map["reprapfirmware"] = gcfRepRapFirmware; keys_map["repetier"] = gcfRepetier; keys_map["teacup"] = gcfTeacup; keys_map["makerware"] = gcfMakerWare;