Add a new option "emit_machine_limits_to_gcode" (#3236)

This commit is contained in:
SoftFever 2023-12-23 15:02:27 +08:00 committed by GitHub
parent 01706eff84
commit cc23ec6626
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 4 deletions

View file

@ -3026,7 +3026,8 @@ static bool custom_gcode_sets_temperature(const std::string &gcode, const int mc
void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print)
{
const auto flavor = print.config().gcode_flavor.value;
if (flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware) {
if ((flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware) &&
print.config().emit_machine_limits_to_gcode.value == true) {
int factor = flavor == gcfRepRapFirmware ? 60 : 1; // RRF M203 and M566 are in mm/min
file.write_format("M201 X%d Y%d Z%d E%d\n",
int(print.config().machine_max_acceleration_x.values.front() + 0.5),
@ -3069,7 +3070,6 @@ void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print)
print.config().machine_max_jerk_y.values.front() * factor,
print.config().machine_max_jerk_z.values.front() * factor,
print.config().machine_max_jerk_e.values.front() * factor);
}
}

View file

@ -878,7 +878,7 @@ static std::vector<std::string> s_Preset_printer_options {
"cooling_tube_retraction",
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "purge_in_prime_tower", "enable_filament_ramming",
"z_offset",
"disable_m73", "preferred_orientation"
"disable_m73", "preferred_orientation", "emit_machine_limits_to_gcode"
};
static std::vector<std::string> s_Preset_sla_print_options {

View file

@ -2564,6 +2564,14 @@ def = this->add("filament_loading_speed", coFloats);
def->mode = comDevelop;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("emit_machine_limits_to_gcode", coBool);
def->label = L("Emit limits to G-code");
def->category = L("Machine limits");
def->tooltip = L("If enabled, the machine limits will be emitted to G-code file.\nThis option will be ignored if the g-code flavor is "
"set to Klipper.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(true));
def = this->add("machine_pause_gcode", coString);
def->label = L("Pause G-code");
def->tooltip = L("This G-code will be used as a code for the pause print. User can insert pause G-code in gcode viewer");

View file

@ -907,6 +907,8 @@ PRINT_CONFIG_CLASS_DEFINE(
PRINT_CONFIG_CLASS_DEFINE(
MachineEnvelopeConfig,
// Orca: whether emit machine limits into the beginning of the G-code.
((ConfigOptionBool, emit_machine_limits_to_gcode))
// M201 X... Y... Z... E... [mm/sec^2]
((ConfigOptionFloats, machine_max_acceleration_x))
((ConfigOptionFloats, machine_max_acceleration_y))

View file

@ -3684,6 +3684,8 @@ PageShp TabPrinter::build_kinematics_page()
optgroup->append_line(line);
}
auto optgroup = page->new_optgroup(L("Advanced"), "param_advanced");
optgroup->append_single_option_line("emit_machine_limits_to_gcode");
const std::vector<std::string> speed_axes{
"machine_max_speed_x",
@ -3691,7 +3693,7 @@ PageShp TabPrinter::build_kinematics_page()
"machine_max_speed_z",
"machine_max_speed_e"
};
auto optgroup = page->new_optgroup(L("Speed limitation"), "param_speed");
optgroup = page->new_optgroup(L("Speed limitation"), "param_speed");
for (const std::string &speed_axis : speed_axes) {
append_option_line(optgroup, speed_axis);
}