support klipper gcode flavor

This commit is contained in:
SoftFever 2022-10-23 19:42:01 +08:00
parent ff760815ca
commit cd71a86d3f
6 changed files with 24 additions and 13 deletions

View file

@ -1636,7 +1636,11 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_config.pressure_advance.values.front());
} else {
if (m_config.enable_pressure_advance.value) {
file.write_format("M900 K%.3f ; Override pressure advance value\n",
if(print.config().gcode_flavor.value == gcfKlipper)
file.write_format("SET_PRESSURE_ADVANCE ADVANCE=%.3f ; Override pressure advance value\n",
m_config.pressure_advance.values.front());
else
file.write_format("M900 K%.3f ; Override pressure advance value\n",
m_config.pressure_advance.values.front());
}
}

View file

@ -99,8 +99,7 @@ public:
}
WipeTowerWriter& disable_linear_advance() {
m_gcode += (m_gcode_flavor == gcfRepRapSprinter || m_gcode_flavor == gcfRepRapFirmware
? (std::string("M572 D") + std::to_string(m_current_tool) + " S0\n")
m_gcode += (m_gcode_flavor == gcfKlipper ? (std::string("SET_PRESSURE_ADVANCE ADVANCE=0\n"))
: std::string("M900 K0\n"));
return *this;
}

View file

@ -22,7 +22,7 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config)
{
this->config.apply(print_config, true);
m_single_extruder_multi_material = print_config.single_extruder_multi_material.value;
bool is_marlin = print_config.gcode_flavor.value == gcfMarlinLegacy || print_config.gcode_flavor.value == gcfMarlinFirmware;
bool is_marlin = print_config.gcode_flavor.value == gcfMarlinLegacy || print_config.gcode_flavor.value == gcfMarlinFirmware || print_config.gcode_flavor.value == gcfKlipper;
m_max_acceleration = std::lrint(is_marlin ? print_config.machine_max_acceleration_extruding.values.front() : 0);
m_max_jerk = std::lrint(is_marlin ? std::min(print_config.machine_max_jerk_x.values.front(), print_config.machine_max_jerk_y.values.front()) : 0);
}
@ -55,7 +55,8 @@ std::string GCodeWriter::preamble()
FLAVOR_IS(gcfMarlinFirmware) ||
FLAVOR_IS(gcfTeacup) ||
FLAVOR_IS(gcfRepetier) ||
FLAVOR_IS(gcfSmoothie))
FLAVOR_IS(gcfSmoothie) ||
FLAVOR_IS(gcfKlipper))
{
if (RELATIVE_E_AXIS) {
gcode << "M83 ; only support relative e\n";
@ -196,7 +197,11 @@ std::string GCodeWriter::set_jerk_xy(unsigned int jerk)
m_last_jerk = jerk;
std::ostringstream gcode;
gcode << "M205 X" << jerk << " Y" << jerk;
if(FLAVOR_IS(gcfKlipper))
gcode << "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=" << jerk;
else
gcode << "M205 X" << jerk << " Y" << jerk;
if (GCodeWriter::full_gcode_comment) gcode << " ; adjust jerk";
gcode << "\n";

View file

@ -98,6 +98,7 @@ static t_config_enum_values s_keys_map_GCodeFlavor {
{ "makerware", gcfMakerWare },
{ "marlin2", gcfMarlinFirmware },
{ "sailfish", gcfSailfish },
{ "klipper", gcfKlipper },
{ "smoothie", gcfSmoothie },
{ "mach3", gcfMach3 },
{ "machinekit", gcfMachinekit },
@ -1529,7 +1530,7 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("What kind of gcode the printer is compatible with");
def->enum_keys_map = &ConfigOptionEnum<GCodeFlavor>::get_enum_values();
def->enum_values.push_back("marlin");
//def->enum_values.push_back("reprap");
def->enum_values.push_back("klipper");
//def->enum_values.push_back("reprapfirmware");
//def->enum_values.push_back("repetier");
//def->enum_values.push_back("teacup");

View file

@ -32,8 +32,8 @@
namespace Slic3r {
enum GCodeFlavor : unsigned char {
gcfMarlinLegacy, gcfRepRapSprinter, gcfRepRapFirmware, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlinFirmware, gcfSailfish, gcfMach3, gcfMachinekit,
gcfSmoothie, gcfNoExtrusion,
gcfMarlinLegacy, gcfKlipper, gcfRepRapSprinter, gcfRepRapFirmware, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlinFirmware, gcfSailfish, gcfMach3, gcfMachinekit,
gcfSmoothie, gcfNoExtrusion
};
enum class FuzzySkinType {