Check value of the parameter "How to apply limits", when Klipper is selected

+ Suppress silent mode for G-code flavor that is different from MarlinFirmware or MarlinLegacy
This commit is contained in:
YuSanka 2023-03-22 15:42:34 +01:00 committed by Lukas Matena
parent 4b27210b6e
commit dcfbff5ec8

View File

@ -2377,14 +2377,44 @@ void TabPrinter::build_fff()
} }
} }
if (opt_key == "gcode_flavor") { if (opt_key == "gcode_flavor") {
const int flavor = boost::any_cast<int>(value); const GCodeFlavor flavor = static_cast<GCodeFlavor>(boost::any_cast<int>(value));
bool supports_travel_acceleration = (flavor == int(gcfMarlinFirmware) || flavor == int(gcfRepRapFirmware)); bool supports_travel_acceleration = (flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware);
bool supports_min_feedrates = (flavor == int(gcfMarlinFirmware) || flavor == int(gcfMarlinLegacy)); bool supports_min_feedrates = (flavor == gcfMarlinFirmware || flavor == gcfMarlinLegacy);
if (supports_travel_acceleration != m_supports_travel_acceleration || supports_min_feedrates != m_supports_min_feedrates) { if (supports_travel_acceleration != m_supports_travel_acceleration || supports_min_feedrates != m_supports_min_feedrates) {
m_rebuild_kinematics_page = true; m_rebuild_kinematics_page = true;
m_supports_travel_acceleration = supports_travel_acceleration; m_supports_travel_acceleration = supports_travel_acceleration;
m_supports_min_feedrates = supports_min_feedrates; m_supports_min_feedrates = supports_min_feedrates;
} }
const bool is_silent_mode = m_config->option("silent_mode")->getBool();
const bool is_emit_to_gcode = m_config->option("machine_limits_usage")->getInt() == static_cast<int>(MachineLimitsUsage::EmitToGCode);
if ((flavor == gcfKlipper && is_emit_to_gcode) || (!m_supports_min_feedrates && is_silent_mode)) {
DynamicPrintConfig new_conf = *m_config;
wxString msg;
if (flavor == gcfKlipper && is_emit_to_gcode) {
msg = _L("Emitting machine limits to G-code is not supported with Klipper G-code flavor.\n"
"The option was switched to \"Use for time estimate\".");
auto machine_limits_usage = static_cast<ConfigOptionEnum<MachineLimitsUsage>*>(m_config->option("machine_limits_usage")->clone());
machine_limits_usage->value = MachineLimitsUsage::TimeEstimateOnly;
new_conf.set_key_value("machine_limits_usage", machine_limits_usage);
}
if (!m_supports_min_feedrates && is_silent_mode) {
if (!msg.IsEmpty())
msg += "\n\n";
msg += _L("Stealth mode for machine limits to G-code is not supported with selected G-code flavor.\n"
"The Stealth mode was suppressed.");
auto silent_mode = static_cast<ConfigOptionBool*>(m_config->option("silent_mode")->clone());
silent_mode->value = false;
new_conf.set_key_value("silent_mode", silent_mode);
}
InfoDialog(parent(), _L("G-code flavor is switched"), msg).ShowModal();
load_config(new_conf);
}
} }
build_unregular_pages(); build_unregular_pages();
update_dirty(); update_dirty();