ENH: sync voron profile from orca

Thanks OrcaSlicer.

Signed-off-by: salt.wei <salt.wei@bambulab.com>
Change-Id: I02f6b712cc07907ae7cae4284fb75ddef053dfea
This commit is contained in:
salt.wei 2023-06-14 20:46:53 +08:00 committed by Lane.Wei
parent 4e778539b8
commit 8905121af5
45 changed files with 171 additions and 64 deletions

View file

@ -1759,6 +1759,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_placeholder_parser.set("bed_temperature", new ConfigOptionInts(*bed_temp_opt));
m_placeholder_parser.set("bed_temperature_initial_layer_single", new ConfigOptionInt(first_bed_temp_opt->get_at(initial_extruder_id)));
m_placeholder_parser.set("bed_temperature_initial_layer_vector", new ConfigOptionString(""));
m_placeholder_parser.set("chamber_temperature", new ConfigOptionInt(m_config.chamber_temperature));
//support variables `first_layer_temperature` and `first_layer_bed_temperature`
m_placeholder_parser.set("first_layer_bed_temperature", new ConfigOptionInts(*first_bed_temp_opt));
@ -1784,11 +1785,12 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
}
std::string machine_start_gcode = this->placeholder_parser_process("machine_start_gcode", print.config().machine_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, machine_start_gcode, initial_extruder_id, true);
// Set extruder(s) temperature before and after start G-code.
this->_print_first_layer_extruder_temperatures(file, print, machine_start_gcode, initial_extruder_id, false);
if (print.config().gcode_flavor != gcfKlipper) {
// 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, machine_start_gcode, initial_extruder_id, true);
// Set extruder(s) temperature before and after start G-code.
this->_print_first_layer_extruder_temperatures(file, print, machine_start_gcode, initial_extruder_id, false);
}
// adds tag for processor
file.write_format(";%s%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role).c_str(), ExtrusionEntity::role_to_string(erCustom).c_str());

View file

@ -921,7 +921,7 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
m_result.filament_vitrification_temperature[i] = static_cast<float>(config.temperature_vitrification.get_at(i));
}
if (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware) {
if (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware || m_flavor == gcfKlipper) {
m_time_processor.machine_limits = reinterpret_cast<const MachineEnvelopeConfig&>(config);
if (m_flavor == gcfMarlinLegacy) {
// Legacy Marlin does not have separate travel acceleration, it uses the 'extruding' value instead.
@ -1116,7 +1116,7 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
if (machine_unload_filament_time != nullptr)
m_time_processor.filament_unload_times = static_cast<float>(machine_unload_filament_time->value);
if (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware) {
if (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware || m_flavor == gcfKlipper) {
const ConfigOptionFloats* machine_max_acceleration_x = config.option<ConfigOptionFloats>("machine_max_acceleration_x");
if (machine_max_acceleration_x != nullptr)
m_time_processor.machine_limits.machine_max_acceleration_x.values = machine_max_acceleration_x->values;
@ -1659,6 +1659,16 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line, bool
m_start_position = m_end_position;
const std::string_view cmd = line.cmd();
//softfever
if (m_flavor == gcfKlipper)
{
if (boost::iequals(cmd, "SET_VELOCITY_LIMIT"))
{
process_SET_VELOCITY_LIMIT(line);
return;
}
}
if (cmd.length() > 1) {
// process command lines
switch (cmd[0])
@ -3719,7 +3729,7 @@ void GCodeProcessor::process_M203(const GCodeReader::GCodeLine& line)
// see http://reprap.org/wiki/G-code#M203:_Set_maximum_feedrate
// http://smoothieware.org/supported-g-codes
float factor = (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware || m_flavor == gcfSmoothie) ? 1.0f : MMMIN_TO_MMSEC;
float factor = (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware || m_flavor == gcfSmoothie || m_flavor == gcfKlipper) ? 1.0f : MMMIN_TO_MMSEC;
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
if (static_cast<PrintEstimatedStatistics::ETimeMode>(i) == PrintEstimatedStatistics::ETimeMode::Normal ||
@ -3798,6 +3808,54 @@ void GCodeProcessor::process_M205(const GCodeReader::GCodeLine& line)
}
}
void GCodeProcessor::process_SET_VELOCITY_LIMIT(const GCodeReader::GCodeLine& line)
{
// handle SQUARE_CORNER_VELOCITY
std::regex pattern("\\sSQUARE_CORNER_VELOCITY\\s*=\\s*([0-9]*\\.*[0-9]*)");
std::smatch matches;
if (std::regex_search(line.raw(), matches, pattern) && matches.size() == 2) {
float _jerk = 0;
try
{
_jerk = std::stof(matches[1]);
}
catch (...) {}
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
set_option_value(m_time_processor.machine_limits.machine_max_jerk_x, i, _jerk);
set_option_value(m_time_processor.machine_limits.machine_max_jerk_y, i, _jerk);
}
}
pattern = std::regex("\\sACCEL\\s*=\\s*([0-9]*\\.*[0-9]*)");
if (std::regex_search(line.raw(), matches, pattern) && matches.size() == 2) {
float _accl = 0;
try
{
_accl = std::stof(matches[1]);
}
catch (...) {}
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
set_acceleration(static_cast<PrintEstimatedStatistics::ETimeMode>(i), _accl);
set_travel_acceleration(static_cast<PrintEstimatedStatistics::ETimeMode>(i), _accl);
}
}
pattern = std::regex("\\sVELOCITY\\s*=\\s*([0-9]*\\.*[0-9]*)");
if (std::regex_search(line.raw(), matches, pattern) && matches.size() == 2) {
float _speed = 0;
try
{
_speed = std::stof(matches[1]);
}
catch (...) {}
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
set_option_value(m_time_processor.machine_limits.machine_max_speed_x, i, _speed);
set_option_value(m_time_processor.machine_limits.machine_max_speed_y, i, _speed);
}
}
}
void GCodeProcessor::process_M221(const GCodeReader::GCodeLine& line)
{
float value_s;

View file

@ -837,6 +837,9 @@ namespace Slic3r {
// Advanced settings
void process_M205(const GCodeReader::GCodeLine& line);
// Klipper SET_VELOCITY_LIMIT
void process_SET_VELOCITY_LIMIT(const GCodeReader::GCodeLine& line);
// Set extrude factor override percentage
void process_M221(const GCodeReader::GCodeLine& line);

View file

@ -128,9 +128,13 @@ 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")
: std::string("M900 K0\n"));
if (m_gcode_flavor == gcfKlipper)
m_gcode += "SET_PRESSURE_ADVANCE ADVANCE=0\n";
else if (m_gcode_flavor == gcfRepRapFirmware)
m_gcode += std::string("M572 D") + std::to_string(m_current_tool) + " S0\n";
else
m_gcode += "M900 K0\n";
return *this;
}

View file

@ -22,7 +22,9 @@ 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);
}
@ -54,7 +56,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";

View file

@ -781,7 +781,9 @@ static std::vector<std::string> s_Preset_filament_options {
"filament_vendor", "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits",
//BBS
"filament_wipe_distance", "additional_cooling_fan_speed",
"bed_temperature_difference", "nozzle_temperature_range_low", "nozzle_temperature_range_high"
"bed_temperature_difference", "nozzle_temperature_range_low", "nozzle_temperature_range_high",
//softfever
"chamber_temperature"
};
static std::vector<std::string> s_Preset_machine_limits_options {

View file

@ -141,6 +141,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"wipe_distance",
"curr_bed_type",
"nozzle_volume",
"chamber_temperature",
"nozzle_hrc",
"required_nozzle_HRC",
"upward_compatible_machine"
@ -180,6 +181,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
osteps.emplace_back(posSlice);
} else if (
opt_key == "print_sequence"
|| opt_key == "chamber_temperature"
|| opt_key == "filament_type"
|| opt_key == "nozzle_temperature_initial_layer"
|| opt_key == "filament_minimal_purge_on_wipe_tower"

View file

@ -91,6 +91,7 @@ CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(AuthorizationType)
static t_config_enum_values s_keys_map_GCodeFlavor {
{ "marlin", gcfMarlinLegacy },
{ "klipper", gcfKlipper },
{ "reprap", gcfRepRapSprinter },
{ "reprapfirmware", gcfRepRapFirmware },
{ "repetier", gcfRepetier },
@ -1551,29 +1552,31 @@ 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("reprapfirmware");
def->enum_values.push_back("repetier");
def->enum_values.push_back("teacup");
def->enum_values.push_back("makerware");
def->enum_values.push_back("marlin2");
def->enum_values.push_back("sailfish");
def->enum_values.push_back("mach3");
def->enum_values.push_back("machinekit");
def->enum_values.push_back("smoothie");
def->enum_values.push_back("no-extrusion");*/
def->enum_values.push_back("klipper");
//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");
//def->enum_values.push_back("marlin2");
//def->enum_values.push_back("sailfish");
//def->enum_values.push_back("mach3");
//def->enum_values.push_back("machinekit");
//def->enum_values.push_back("smoothie");
//def->enum_values.push_back("no-extrusion");
def->enum_labels.push_back("Marlin(legacy)");
/*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)");
def->enum_labels.push_back("Marlin 2");
def->enum_labels.push_back("Sailfish (MakerBot)");
def->enum_labels.push_back("Mach3/LinuxCNC");
def->enum_labels.push_back("Machinekit");
def->enum_labels.push_back("Smoothie");
def->enum_labels.push_back(L("No extrusion"));*/
def->enum_labels.push_back("Klipper");
//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)");
//def->enum_labels.push_back("Marlin 2");
//def->enum_labels.push_back("Sailfish (MakerBot)");
//def->enum_labels.push_back("Mach3/LinuxCNC");
//def->enum_labels.push_back("Machinekit");
//def->enum_labels.push_back("Smoothie");
//def->enum_labels.push_back(L("No extrusion"));
def->mode = comAdvanced;
def->readonly = false;
def->set_default_value(new ConfigOptionEnum<GCodeFlavor>(gcfMarlinLegacy));
@ -2879,6 +2882,15 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("chamber_temperature", coInt);
def->label = L("Chamber temperature");
def->tooltip = L("Target chamber temperature");
def->sidetext = L("°C");
def->full_label = L("Chamber temperature");
def->min = 0;
def->max = max_temp;
def->set_default_value(new ConfigOptionInt(0));
def = this->add("nozzle_temperature", coInts);
def->label = L("Other layers");
def->tooltip = L("Nozzle temperature for layers after the initial one");

View file

@ -32,8 +32,8 @@
namespace Slic3r {
enum GCodeFlavor : unsigned char {
gcfMarlinLegacy, gcfRepRapSprinter, gcfRepRapFirmware, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlinFirmware, gcfSailfish, gcfMach3, gcfMachinekit,
gcfSmoothie, gcfNoExtrusion, gcfKlipper
gcfMarlinLegacy, gcfKlipper, gcfRepRapSprinter, gcfRepRapFirmware, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlinFirmware, gcfSailfish, gcfMach3, gcfMachinekit,
gcfSmoothie, gcfNoExtrusion
};
enum class FuzzySkinType {
@ -925,6 +925,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
((ConfigOptionBool, spiral_mode))
((ConfigOptionInt, standby_temperature_delta))
((ConfigOptionInts, nozzle_temperature))
((ConfigOptionInt, chamber_temperature))
((ConfigOptionBools, wipe))
// BBS
((ConfigOptionInts, bed_temperature_difference))