From 42f1217f6eb12783f9a0c864e62e6cecb1200527 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 9 Mar 2023 14:05:04 +0100 Subject: [PATCH] Klipper: Adding the new firmware flavor: - added the new option - allowed machine limits page - added a check for Klipper + 'emit limits to gcode' (Print::validate so far) --- src/libslic3r/Print.cpp | 4 ++++ src/libslic3r/PrintConfig.cpp | 7 +++++-- src/libslic3r/PrintConfig.hpp | 2 +- src/slic3r/GUI/Tab.cpp | 5 +++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index afc039bdd..febc4956d 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -502,6 +502,10 @@ std::string Print::validate(std::string* warning) const return _u8L("The Spiral Vase option can only be used when printing single material objects."); } + if (m_config.machine_limits_usage == MachineLimitsUsage::EmitToGCode && m_config.gcode_flavor == gcfKlipper) + return L("Machine limits cannot be emitted to G-Code when Klipper firmware flavor is used. " + "Change the value of machine_limits_usage."); + // Cache of layer height profiles for checking: // 1) Whether all layers are synchronized if printing with wipe tower and / or unsynchronized supports. // 2) Whether layer height is constant for Organic supports. diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index ce5aa69b5..1adaa5430 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -48,6 +48,7 @@ static const t_config_enum_values s_keys_map_GCodeFlavor { { "makerware", gcfMakerWare }, { "marlin", gcfMarlinLegacy }, { "marlin2", gcfMarlinFirmware }, + { "klipper", gcfKlipper }, { "sailfish", gcfSailfish }, { "smoothie", gcfSmoothie }, { "mach3", gcfMach3 }, @@ -1406,6 +1407,7 @@ void PrintConfigDef::init_fff_params() { "makerware", "MakerWare (MakerBot)" }, { "marlin", "Marlin (legacy)" }, { "marlin2", "Marlin 2" }, + { "klipper", "Klipper" }, { "sailfish", "Sailfish (MakerBot)" }, { "mach3", "Mach3/LinuxCNC" }, { "machinekit", "Machinekit" }, @@ -4421,8 +4423,9 @@ std::string validate(const FullPrintConfig &cfg) cfg.gcode_flavor.value != gcfMarlinLegacy && cfg.gcode_flavor.value != gcfMarlinFirmware && cfg.gcode_flavor.value != gcfMachinekit && - cfg.gcode_flavor.value != gcfRepetier) - return "--use-firmware-retraction is only supported by Marlin, Smoothie, RepRapFirmware, Repetier and Machinekit firmware"; + cfg.gcode_flavor.value != gcfRepetier && + cfg.gcode_flavor.value != gcfKlipper) + return "--use-firmware-retraction is only supported by Marlin, Klipper, Smoothie, RepRapFirmware, Repetier and Machinekit firmware"; if (cfg.use_firmware_retraction.value) for (unsigned char wipe : cfg.wipe.values) diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 17f5e501c..3a602b7ac 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -32,7 +32,7 @@ namespace Slic3r { enum GCodeFlavor : unsigned char { - gcfRepRapSprinter, gcfRepRapFirmware, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlinLegacy, gcfMarlinFirmware, gcfSailfish, gcfMach3, gcfMachinekit, + gcfRepRapSprinter, gcfRepRapFirmware, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlinLegacy, gcfMarlinFirmware, gcfKlipper, gcfSailfish, gcfMach3, gcfMachinekit, gcfSmoothie, gcfNoExtrusion, }; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index dc3100eb2..6227fc537 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2866,7 +2866,7 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/) { size_t n_before_extruders = 2; // Count of pages before Extruder pages auto flavor = m_config->option>("gcode_flavor")->value; - bool show_mach_limits = (flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware); + bool show_mach_limits = (flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware || flavor == gcfKlipper); /* ! Freeze/Thaw in this function is needed to avoid call OnPaint() for erased pages * and be cause of application crash, when try to change Preset in moment, @@ -3102,7 +3102,8 @@ void TabPrinter::toggle_options() if (m_active_page->title() == "Machine limits" && m_machine_limits_description_line) { assert(flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware - || flavor == gcfRepRapFirmware); + || flavor == gcfRepRapFirmware + || flavor == gcfKlipper); const auto *machine_limits_usage = m_config->option>("machine_limits_usage"); bool enabled = machine_limits_usage->value != MachineLimitsUsage::Ignore; bool silent_mode = m_config->opt_bool("silent_mode");